@@ -5,13 +5,11 @@ import classNames from 'classnames'
5
5
export const Context = React . createContext ( { } )
6
6
7
7
//component - CoreUI / CSidebar
8
-
9
- const CSidebar = props => {
8
+ const CSidebar = props => {
10
9
11
10
const {
12
11
children,
13
12
className,
14
- //
15
13
innerRef,
16
14
breakpoint,
17
15
show,
@@ -35,12 +33,11 @@ const CSidebar = props=>{
35
33
const [ openDropdown , setOpenDropdown ] = useState ( )
36
34
37
35
const node = useRef ( { } ) . current
38
- const reference = ( r ) => {
36
+ const reference = r => {
39
37
node . current = r
40
38
innerRef && innerRef ( r )
41
39
}
42
40
43
-
44
41
const [ minimized , setIsMinimized ] = useState ( minimize )
45
42
useMemo ( ( ) => {
46
43
setIsMinimized ( minimize )
@@ -51,8 +48,6 @@ const CSidebar = props=>{
51
48
onMinimizeChange && onMinimizeChange ( minimized )
52
49
}
53
50
54
- // compData.nextRender = true
55
-
56
51
useMemo ( ( ) => {
57
52
setIsOpen ( show )
58
53
} , [ show ] )
@@ -63,7 +58,7 @@ const CSidebar = props=>{
63
58
} , [ isOpen ] )
64
59
65
60
//methods
66
- const sidebarCloseListener = ( e ) => {
61
+ const sidebarCloseListener = e => {
67
62
if (
68
63
document . getElementById ( key + 'backdrop' ) &&
69
64
! node . current . contains ( e . target )
@@ -98,13 +93,12 @@ const CSidebar = props=>{
98
93
setIsOpen ( overlaid ? false : 'responsive' )
99
94
}
100
95
101
- const isOnMobile = ( ) => {
96
+ const isOnMobile = ( ) => {
102
97
return Boolean ( getComputedStyle ( node . current ) . getPropertyValue ( '--is-mobile' ) )
103
98
}
104
99
105
100
const onSidebarClick = e => {
106
101
const sidebarItemClicked = String ( e . target . className ) . includes ( 'c-sidebar-nav-link' )
107
-
108
102
if (
109
103
sidebarItemClicked &&
110
104
hideOnMobileClick &&
@@ -115,20 +109,19 @@ const CSidebar = props=>{
115
109
}
116
110
117
111
// render
118
-
119
112
const haveResponsiveClass = breakpoint && isOpen === 'responsive'
120
113
const classes = classNames (
121
- className ,
122
114
'c-sidebar' ,
123
- colorScheme ? `c-sidebar-${ colorScheme } ` : null ,
124
- isOpen === true ? 'c-sidebar-show' : null ,
125
- haveResponsiveClass ? `c-sidebar-${ breakpoint } -show` : null ,
126
- fixed && ! overlaid ? 'c-sidebar-fixed' : null ,
127
- aside ? 'c-sidebar-right' : null ,
128
- minimized && ! unfoldable ? 'c-sidebar-minimized' : null ,
129
- minimized && unfoldable ? 'c-sidebar-unfoldable' : null ,
130
- overlaid ? 'c-sidebar-overlaid' : null ,
131
- size ? `c-sidebar-${ size } ` : null
115
+ colorScheme && `c-sidebar-${ colorScheme } ` ,
116
+ isOpen === true && 'c-sidebar-show' ,
117
+ haveResponsiveClass && `c-sidebar-${ breakpoint } -show` ,
118
+ fixed && ! overlaid && 'c-sidebar-fixed' ,
119
+ aside && 'c-sidebar-right' ,
120
+ minimized && ! unfoldable && 'c-sidebar-minimized' ,
121
+ minimized && unfoldable && 'c-sidebar-unfoldable' ,
122
+ overlaid && 'c-sidebar-overlaid' ,
123
+ size && `c-sidebar-${ size } ` ,
124
+ className
132
125
)
133
126
134
127
return (
@@ -140,8 +133,8 @@ const CSidebar = props=>{
140
133
setOpenDropdown
141
134
} } >
142
135
< div
143
- { ...attributes }
144
136
className = { classes }
137
+ { ...attributes }
145
138
ref = { reference }
146
139
onClick = { onSidebarClick }
147
140
>
@@ -155,7 +148,6 @@ const CSidebar = props=>{
155
148
CSidebar . propTypes = {
156
149
children : PropTypes . node ,
157
150
className : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . array , PropTypes . object ] ) ,
158
- //
159
151
innerRef : PropTypes . oneOfType ( [ PropTypes . object , PropTypes . func ] ) ,
160
152
fixed : PropTypes . bool ,
161
153
unfoldable : PropTypes . bool ,
0 commit comments