@@ -3,37 +3,25 @@ import React, { PropTypes } from 'react'
3
3
4
4
import {
5
5
AutoControlledComponent as Component ,
6
- META ,
7
6
customPropTypes ,
8
7
getUnhandledProps ,
9
8
getElementType ,
9
+ META ,
10
10
useKeyOnly ,
11
11
} from '../../lib'
12
12
import SidebarPushable from './SidebarPushable'
13
13
import SidebarPusher from './SidebarPusher'
14
14
15
- const _meta = {
16
- name : 'Sidebar' ,
17
- type : META . TYPES . MODULE ,
18
- props : {
19
- animation : [ 'overlay' , 'push' , 'scale down' , 'uncover' , 'slide out' , 'slide along' ] ,
20
- direction : [ 'top' , 'right' , 'bottom' , 'left' ] ,
21
- width : [ 'very thin' , 'thin' , 'wide' , 'very wide' ] ,
22
- } ,
23
- }
24
-
25
15
/**
26
16
* A sidebar hides additional content beside a page.
27
17
*/
28
18
class Sidebar extends Component {
29
- static _meta = _meta
30
-
31
19
static propTypes = {
32
20
/** An element type to render as (string or function). */
33
21
as : customPropTypes . as ,
34
22
35
23
/** Animation style. */
36
- animation : PropTypes . oneOf ( Sidebar . _meta . props . animation ) ,
24
+ animation : PropTypes . oneOf ( [ 'overlay' , 'push' , 'scale down' , 'uncover' , 'slide out' , 'slide along' ] ) ,
37
25
38
26
/** Primary content. */
39
27
children : PropTypes . node ,
@@ -44,20 +32,16 @@ class Sidebar extends Component {
44
32
/** Initial value of visible. */
45
33
defaultVisible : PropTypes . bool ,
46
34
47
- /** Direction the sidebar should appear on */
48
- direction : PropTypes . oneOf ( Sidebar . _meta . props . direction ) ,
35
+ /** Direction the sidebar should appear on. */
36
+ direction : PropTypes . oneOf ( [ 'top' , 'right' , 'bottom' , 'left' ] ) ,
49
37
50
38
/** Controls whether or not the sidebar is visible on the page. */
51
39
visible : PropTypes . bool ,
52
40
53
- /** Sidebar width */
54
- width : PropTypes . oneOf ( Sidebar . _meta . props . width ) ,
41
+ /** Sidebar width. */
42
+ width : PropTypes . oneOf ( [ 'very thin' , 'thin' , 'wide' , 'very wide' ] ) ,
55
43
}
56
44
57
- static Pushable = SidebarPushable
58
-
59
- static Pusher = SidebarPusher
60
-
61
45
static defaultProps = {
62
46
direction : 'left' ,
63
47
}
@@ -66,6 +50,15 @@ class Sidebar extends Component {
66
50
'visible' ,
67
51
]
68
52
53
+ static _meta = {
54
+ name : 'Sidebar' ,
55
+ type : META . TYPES . MODULE ,
56
+ }
57
+
58
+ static Pushable = SidebarPushable
59
+
60
+ static Pusher = SidebarPusher
61
+
69
62
state = { }
70
63
71
64
startAnimating = ( duration = 500 ) => {
@@ -83,17 +76,24 @@ class Sidebar extends Component {
83
76
}
84
77
85
78
render ( ) {
79
+ const {
80
+ animation,
81
+ className,
82
+ children,
83
+ direction,
84
+ visible,
85
+ width,
86
+ } = this . props
86
87
const { animating } = this . state
87
- const { animation, className, children, direction, visible, width } = this . props
88
88
89
89
const classes = cx (
90
90
'ui' ,
91
- 'sidebar' ,
92
- useKeyOnly ( animating , 'animating' ) ,
91
+ animation ,
93
92
direction ,
94
93
width ,
95
- animation ,
94
+ useKeyOnly ( animating , 'animating' ) ,
96
95
useKeyOnly ( visible , 'visible' ) ,
96
+ 'sidebar' ,
97
97
className
98
98
)
99
99
0 commit comments