Skip to content

Commit d17c8ff

Browse files
committed
fix: CSidebar wrapper components fixes
- render nodes, even if there are no children, - delete 'tag' from divider and title - clean components
1 parent b933237 commit d17c8ff

6 files changed

+55
-120
lines changed

src/CSidebarClose.js

+6-32
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,17 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import classNames from 'classnames';
4-
import CButtonClose from './CButtonClose';
1+
import React from 'react'
2+
import CButtonClose from './CButtonClose'
53

64
//component - CoreUI / CSidebarClose
75

8-
const CSidebarClose = props=>{
9-
10-
const {
11-
className,
12-
...attributes
13-
} = props;
14-
15-
// render
16-
17-
const classes = classNames(
18-
'c-sidebar-close',
19-
className
20-
);
21-
6+
const CSidebarClose = props => {
227
return (
23-
<CButtonClose {...attributes} buttonClass={classes}>
8+
<CButtonClose {...props} buttonClass={'c-sidebar-close'}>
249
<svg className="c-icon" width="24" height="24" viewBox="0 0 24 24">
2510
<title>x</title>
2611
<path d="M20.030 5.030l-1.061-1.061-6.97 6.97-6.97-6.97-1.061 1.061 6.97 6.97-6.97 6.97 1.061 1.061 6.97-6.97 6.97 6.97 1.061-1.061-6.97-6.97 6.97-6.97z"></path>
2712
</svg>
2813
</CButtonClose>
29-
);
30-
14+
)
3115
}
3216

33-
CSidebarClose.propTypes = {
34-
children: PropTypes.node,
35-
className: PropTypes.string,
36-
//
37-
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string])
38-
};
39-
40-
CSidebarClose.defaultProps = {
41-
};
42-
43-
export default CSidebarClose;
17+
export default CSidebarClose

src/CSidebarFooter.js

+9-17
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,29 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import classNames from 'classnames';
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import classNames from 'classnames'
44

55
//component - CoreUI / CSidebarFooter
66

7-
const CSidebarFooter = props=>{
7+
const CSidebarFooter = props => {
88

99
const {
1010
tag: Tag,
11-
children,
1211
className,
1312
//
1413
innerRef,
1514
...attributes
16-
} = props;
15+
} = props
1716

1817
// render
19-
20-
const classes = classNames(className, 'c-sidebar-footer');
18+
const classes = classNames('c-sidebar-footer', className)
2119

2220
return (
23-
children ?
24-
<Tag className={classes} {...attributes} ref={innerRef}>
25-
{children}
26-
</Tag>
27-
: null
28-
);
29-
21+
<Tag className={classes} {...attributes} ref={innerRef}/>
22+
)
3023
}
3124

3225
CSidebarFooter.propTypes = {
3326
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
34-
children: PropTypes.node,
3527
className: PropTypes.string,
3628
//
3729
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string])
@@ -41,4 +33,4 @@ CSidebarFooter.defaultProps = {
4133
tag: 'div'
4234
};
4335

44-
export default CSidebarFooter;
36+
export default CSidebarFooter

src/CSidebarForm.js

+9-16
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,30 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import classNames from 'classnames';
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import classNames from 'classnames'
44

55
//component - CoreUI / CSidebarForm
66

7-
const CSidebarForm = props=>{
7+
const CSidebarForm = props => {
88

99
const {
1010
tag: Tag,
11-
children,
1211
className,
1312
//
1413
innerRef,
1514
...attributes
16-
} = props;
15+
} = props
1716

1817
//render
1918

20-
const classes = classNames(className, 'c-sidebar-form');
19+
const classes = classNames('c-sidebar-form', className)
2120

2221
return (
23-
children ?
24-
<Tag className={classes} {...attributes} ref={innerRef}>
25-
{children}
26-
</Tag>
27-
: null
28-
);
29-
22+
<Tag className={classes} {...attributes} ref={innerRef}/>
23+
)
3024
}
3125

3226
CSidebarForm.propTypes = {
3327
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
34-
children: PropTypes.node,
3528
className: PropTypes.string,
3629
//
3730
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string])
@@ -41,4 +34,4 @@ CSidebarForm.defaultProps = {
4134
tag: 'div'
4235
};
4336

44-
export default CSidebarForm;
37+
export default CSidebarForm

src/CSidebarHeader.js

+9-19
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,30 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import classNames from 'classnames';
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import classNames from 'classnames'
44

55
//component - CoreUI / CSidebarHeader
66

7-
const CSidebarHeader = props=>{
7+
const CSidebarHeader = props => {
88

99
const {
1010
tag: Tag,
11-
children,
1211
className,
1312
//
1413
innerRef,
1514
...attributes
16-
} = props;
15+
} = props
1716

1817
//render
1918

20-
const classes = classNames(
21-
className,
22-
'c-sidebar-header'
23-
);
19+
const classes = classNames('c-sidebar-header', className)
2420

2521
return (
26-
children ?
27-
<Tag className={classes} {...attributes} ref={innerRef}>
28-
{children}
29-
</Tag>
30-
: null
31-
);
32-
22+
<Tag className={classes} {...attributes} ref={innerRef}/>
23+
)
3324
}
3425

3526
CSidebarHeader.propTypes = {
3627
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
37-
children: PropTypes.node,
3828
className: PropTypes.string,
3929
//
4030
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string])
@@ -44,4 +34,4 @@ CSidebarHeader.defaultProps = {
4434
tag: 'div'
4535
};
4636

47-
export default CSidebarHeader;
37+
export default CSidebarHeader

src/CSidebarNavDivider.js

+11-17
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,36 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import classNames from 'classnames';
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import classNames from 'classnames'
44

55
//component - CoreUI / CSidebarNavDivider
66

7-
const CSidebarNavDivider = props=>{
7+
const CSidebarNavDivider = props => {
88

99
const {
10-
tag: Tag,
1110
className,
1211
//
1312
innerRef,
1413
...attributes
15-
} = props;
14+
} = props
1615

1716
//render
1817

1918
const classes = classNames(
20-
className,
21-
'c-sidebar-nav-divider'
22-
);
19+
'c-sidebar-nav-divider',
20+
className
21+
)
2322

2423
return (
25-
<Tag className={classes} {...attributes} ref={innerRef} />
26-
);
24+
<li className={classes} {...attributes} ref={innerRef} />
25+
)
2726

2827
}
2928

3029
CSidebarNavDivider.propTypes = {
31-
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
32-
children: PropTypes.node,
3330
className: PropTypes.string,
3431
//
3532
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string])
3633
};
3734

38-
CSidebarNavDivider.defaultProps = {
39-
tag: 'li'
40-
};
4135

42-
export default CSidebarNavDivider;
36+
export default CSidebarNavDivider

src/CSidebarNavTitle.js

+11-19
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,34 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import classNames from 'classnames';
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import classNames from 'classnames'
44

55
//component - CoreUI / CSidebarNavTitle
66

7-
const CSidebarNavTitle = props=>{
7+
const CSidebarNavTitle = props => {
88

99
const {
10-
tag: Tag,
1110
className,
1211
//
1312
innerRef,
1413
...attributes
15-
} = props;
14+
} = props
1615

1716
//render
18-
1917
const classes = classNames(
20-
className,
21-
'c-sidebar-nav-title'
22-
);
18+
'c-sidebar-nav-title',
19+
className
20+
)
2321

2422
return (
25-
<Tag className={classes} {...attributes} ref={innerRef} />
26-
);
27-
23+
<li className={classes} {...attributes} ref={innerRef}/>
24+
)
2825
}
2926

3027
CSidebarNavTitle.propTypes = {
31-
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
32-
children: PropTypes.node,
3328
className: PropTypes.string,
3429
//
3530
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string])
3631
};
3732

38-
CSidebarNavTitle.defaultProps = {
39-
tag: 'li'
40-
};
4133

42-
export default CSidebarNavTitle;
34+
export default CSidebarNavTitle

0 commit comments

Comments
 (0)