1
1
import { mediaQuery } from "../hooks/media-query" ;
2
- import { FC } from "react"
2
+ import { FC } from "react" ;
3
3
import { Divider , IconButton , Typography } from "@material-ui/core" ;
4
4
import styled from "styled-components" ;
5
5
6
6
import AppIcon from "./AppIcon" ;
7
7
8
8
const Header = styled . div `
9
- display: flex;
10
- align-items: center;
11
- justify-content: space-between;
12
- padding-left: 16px;
9
+ display: flex;
10
+ align-items: center;
11
+ justify-content: space-between;
12
+ padding-left: 16px;
13
13
` ;
14
14
15
15
const SidebarWrapper = styled . aside < { closed : boolean } > `
16
- display: flex;
17
- flex-direction: column;
18
- z-index: 2;
19
- background: white;
20
- height: 100%;
21
- overflow-x: hidden;
22
- transition: width 125ms ease-in;
23
- width: ${ p => p . closed ? '0px' : '320px' } ;
24
- box-shadow: ${ p => p . closed ? '' : '1px 0px 4px 1px #bbb' } ;
25
-
26
- /* Override so the sidebar takes all screen on mobile */
27
- ${ p => p . closed
28
- ? mediaQuery ( 'sm' ) `width: 0px`
29
- : mediaQuery ( 'sm' ) `width: 100vw`
30
- }
16
+ display: flex;
17
+ flex-direction: column;
18
+ z-index: 2;
19
+ background: white;
20
+ height: 100%;
21
+ overflow-x: hidden;
22
+ transition: width 125ms ease-in;
23
+ width: ${ ( p ) => ( p . closed ? "0px" : "320px" ) } ;
24
+ box-shadow: ${ ( p ) => ( p . closed ? "" : "1px 0px 4px 1px #bbb" ) } ;
25
+
26
+ /* Override so the sidebar takes all screen on mobile */
27
+ ${ ( p ) =>
28
+ p . closed ? mediaQuery ( "sm" ) `width: 0px` : mediaQuery ( "sm" ) `width: 100vw` }
31
29
` ;
32
30
33
31
export interface SidebarProps {
34
- open : boolean ;
35
- title : string ;
36
- onClose : ( ) => void ;
32
+ open : boolean ;
33
+ title : string ;
34
+ onClose : ( ) => void ;
37
35
}
38
36
39
- export const Sidebar : FC < SidebarProps > = ( { children, title, onClose, open = false , ...props } ) => {
40
- return < SidebarWrapper closed = { ! open } { ...props } >
41
- < Header >
42
- < Typography variant = "overline" >
43
- { title }
44
- </ Typography >
45
- < IconButton
46
- style = { { width : '40px' , height : '40px' } }
47
- size = "small"
48
- onClick = { onClose }
49
- >
50
- < AppIcon name = 'chevron-left' />
51
- </ IconButton >
52
- </ Header >
53
-
54
- < Divider />
55
- { children }
37
+ export const Sidebar : FC < SidebarProps > = ( {
38
+ children,
39
+ title,
40
+ onClose,
41
+ open = false ,
42
+ ...props
43
+ } ) => {
44
+ return (
45
+ < SidebarWrapper closed = { ! open } { ...props } >
46
+ < Header >
47
+ < Typography variant = "overline" > { title } </ Typography >
48
+ </ Header >
49
+
50
+ < Divider />
51
+ { children }
56
52
</ SidebarWrapper >
57
- }
53
+ ) ;
54
+ } ;
58
55
59
- export default Sidebar ;
56
+ export default Sidebar ;
0 commit comments