Skip to content

Commit 4827eb9

Browse files
author
Tomasz John
committed
- update: custom is true by default
- update: internal check and change call (custom prop) - fix: for alert, badge, link ; after prop added (for lib requirements)
1 parent 5117daa commit 4827eb9

24 files changed

+67
-40
lines changed

src/CAlert.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ const CAlert = props => {
2929
'alert-dismissible': closeButton
3030
}
3131
), cssModule)
32-
32+
3333
const alertTransition = {
3434
...CFade.defaultProps,
3535
...transition,
3636
baseClass: fade ? transition.baseClass : '',
3737
timeout: fade ? transition.timeout : 0
3838
}
3939
const [isOpen, setIsOpen] = useState(show)
40-
40+
4141
useEffect(() => {
4242
setIsOpen(show)
4343
}, [show])
@@ -58,22 +58,22 @@ const CAlert = props => {
5858
}, [isOpen])
5959

6060
return (
61-
<CFade
62-
{...alertTransition}
61+
<CFade
62+
{...alertTransition}
6363
tag="div"
64-
className={classes}
65-
in={Boolean(isOpen)}
64+
className={classes}
65+
in={Boolean(isOpen)}
6666
role="alert"
67-
{...attributes}
67+
{...attributes}
6868
>
6969
{children}
7070
{
7171
closeButton ?
72-
<button
73-
type="button"
72+
<button
73+
type="button"
7474
className="close"
7575
aria-label="Close"
76-
onClick={() => setIsOpen(false)}
76+
onClick={() => setIsOpen(false)}
7777
>
7878
<span aria-hidden="true">&times;</span>
7979
</button>
@@ -82,6 +82,7 @@ const CAlert = props => {
8282
</CFade>
8383
)
8484
}
85+
8586
CAlert.propTypes = {
8687
children: PropTypes.node,
8788
className: PropTypes.string,
@@ -94,7 +95,8 @@ CAlert.propTypes = {
9495
fade: PropTypes.bool,
9596
show: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]),
9697
transition: PropTypes.shape(CFade.propTypes),
97-
}
98+
};
99+
98100
CAlert.defaultProps = {
99101
tag: 'div',
100102
//

src/CBadge.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const CBadge = props => {
2424
const classes = mapToCssModules(classNames(
2525
className,
2626
'badge',
27-
{
27+
{
2828
[`badge-${color}`]: color,
2929
[`badge-${shape}`]: shape
3030
}
@@ -50,7 +50,7 @@ CBadge.propTypes = {
5050
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
5151
color: PropTypes.string,
5252
shape: PropTypes.oneOf(['', 'pill'])
53-
}
53+
};
5454

5555
CBadge.defaultProps = {
5656
tag: 'span'

src/CBreadcrumb.js

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ const CBreadcrumb = props=>{
118118
}
119119

120120
CBreadcrumb.propTypes = {
121+
...CBreadcrumbCustom.propTypes,
121122
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
122123
children: PropTypes.node,
123124
className: PropTypes.string,
@@ -130,6 +131,7 @@ CBreadcrumb.propTypes = {
130131
};
131132

132133
CBreadcrumb.defaultProps = {
134+
custom: true,
133135
tag: 'div',
134136
className: '',
135137
appRoutes: [{ path: '/', exact: true, name: 'Home', component: null }]

src/CCarousel.js

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ const CCarousel = props=>{
102102
}
103103

104104
CCarousel.propTypes = {
105+
...CCarouselCustom.propTypes,
106+
//
105107
custom: PropTypes.bool,
106108
//
107109
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
@@ -117,6 +119,7 @@ CCarousel.propTypes = {
117119
};
118120

119121
CCarousel.defaultProps = {
122+
custom: true,
120123
controls: true,
121124
indicators: true,
122125
autoPlay: true,

src/CCollapse.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ const CCollapse = props=>{
6161
}
6262

6363
CCollapse.propTypes = {
64+
...CCollapseCustom.propTypes,
65+
//
6466
custom: PropTypes.bool,
6567
//
6668
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
@@ -72,7 +74,8 @@ CCollapse.propTypes = {
7274
};
7375

7476
CCollapse.defaultProps = {
75-
toggleEvents: defaultToggleEvents
77+
toggleEvents: defaultToggleEvents,
78+
custom: true
7679
};
7780

7881
export default CCollapse;

src/CDropdown.js

+5
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,14 @@ const CDropdown = props=>{
4141

4242
CDropdown.propTypes = {
4343
...CDropdownCustom.propTypes,
44+
//
4445
custom: PropTypes.bool,
4546
//
4647
defaultOpen: PropTypes.bool,
4748
};
4849

50+
CDropdown.defaultProps = {
51+
custom: true
52+
}
53+
4954
export default CDropdown;

src/CEmbed.js

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ CEmbed.propTypes = {
6565
};
6666

6767
CEmbed.defaultProps = {
68+
custom: true,
6869
tag: 'span',
6970
ratio: '16by9',
7071
type: 'iframe',

src/CHeaderNavItem.js

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ CHeaderNavItem.propTypes = {
6161
};
6262

6363
CHeaderNavItem.defaultProps = {
64+
custom: true,
6465
tag: 'li'
6566
};
6667

src/CLink.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const CLink = props => {
2222
const click = e => {
2323
if (!href && !to) {
2424
e.preventDefault()
25-
}
25+
}
2626
onClick && onClick(e)
2727
}
2828

@@ -32,7 +32,7 @@ const CLink = props => {
3232
className,
3333
active ? 'active' : null
3434
), cssModule)
35-
35+
3636
return to ? (
3737
<NavLink
3838
{...rest}
@@ -43,9 +43,9 @@ const CLink = props => {
4343
) : (
4444
<a
4545
href={href || '#'}
46-
className={classes}
46+
className={classes}
4747
{...rest}
48-
onClick={click}
48+
onClick={click}
4949
ref={innerRef}
5050
/>
5151
)
@@ -61,7 +61,7 @@ CLink.propTypes = {
6161
onClick: PropTypes.func,
6262
...NavLink.propTypes,
6363
to: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.func])
64-
}
64+
};
6565

6666
CLink.sortAttributes = (attributesToSort) => {
6767
const attributes = {}

src/CPagination.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,18 @@ const CPagination = props=>{
7272
pageAutoTo > pageMax ? (pageAutoTo = pageMax) : null;
7373
}
7474
for (let i=pageAutoFrom;i<=pageAutoTo;i++)
75-
list.push(<CPaginationItem custom key={i} active={activePage==i?true:false}><CPaginationLink type="number" n={i}>{i}</CPaginationLink></CPaginationItem>);
75+
list.push(<CPaginationItem key={i} active={activePage==i?true:false}><CPaginationLink type="number" n={i}>{i}</CPaginationLink></CPaginationItem>);
7676
const pagesBefore = pageAutoFrom>pageMin;
7777
const pagesAfter = pageAutoTo<pageMax;
7878
autoChildren = (
7979
<React.Fragment>
80-
{pagesBefore&&firstButtonHtml?<CPaginationItem custom><CPaginationLink type="first">{firstButtonHtml}</CPaginationLink></CPaginationItem>:''}
81-
{pagesBefore&&previousButtonHtml?<CPaginationItem custom><CPaginationLink type="previous">{previousButtonHtml}</CPaginationLink></CPaginationItem>:''}
82-
{!hideDots&&pagesBefore?<CPaginationItem custom><CPaginationLink type="less">...</CPaginationLink></CPaginationItem>:''}
80+
{pagesBefore&&firstButtonHtml?<CPaginationItem><CPaginationLink type="first">{firstButtonHtml}</CPaginationLink></CPaginationItem>:''}
81+
{pagesBefore&&previousButtonHtml?<CPaginationItem><CPaginationLink type="previous">{previousButtonHtml}</CPaginationLink></CPaginationItem>:''}
82+
{!hideDots&&pagesBefore?<CPaginationItem><CPaginationLink type="less">...</CPaginationLink></CPaginationItem>:''}
8383
{list}
84-
{!hideDots&&pagesAfter?<CPaginationItem custom><CPaginationLink type="more">...</CPaginationLink></CPaginationItem>:''}
85-
{pagesAfter&&nextButtonHtml?<CPaginationItem custom><CPaginationLink type="next">{nextButtonHtml}</CPaginationLink></CPaginationItem>:''}
86-
{pagesAfter&&lastButtonHtml?<CPaginationItem custom><CPaginationLink type="last">{lastButtonHtml}</CPaginationLink></CPaginationItem>:''}
84+
{!hideDots&&pagesAfter?<CPaginationItem><CPaginationLink type="more">...</CPaginationLink></CPaginationItem>:''}
85+
{pagesAfter&&nextButtonHtml?<CPaginationItem><CPaginationLink type="next">{nextButtonHtml}</CPaginationLink></CPaginationItem>:''}
86+
{pagesAfter&&lastButtonHtml?<CPaginationItem><CPaginationLink type="last">{lastButtonHtml}</CPaginationLink></CPaginationItem>:''}
8787
</React.Fragment>
8888
)
8989
}
@@ -131,6 +131,7 @@ CPagination.propTypes = {
131131
};
132132

133133
CPagination.defaultProps = {
134+
custom: true,
134135
tag: 'nav',
135136
listTag: 'ul',
136137
'aria-label': 'pagination',

src/CPaginationItem.js

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ CPaginationItem.propTypes = {
7171
};
7272

7373
CPaginationItem.defaultProps = {
74+
custom: true,
7475
tag: 'li',
7576
active: false
7677
};

src/CSidebarBrand.js

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ CSidebarBrand.propTypes = {
116116
};
117117

118118
CSidebarBrand.defaultProps = {
119+
custom: true,
119120
tag: 'div'
120121
};
121122

src/CSidebarNav.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const CSidebarNav = props=>{
103103
badge = {badgeProps}
104104
linkClassName={props.location&&props.location.pathname.indexOf(item.url)>-1 ? 'c-active' : null}
105105
linkProps={linkProps}
106+
custom={false}
106107
>
107108
{item.name}
108109
</CSidebarNavItem>
@@ -132,13 +133,14 @@ const CSidebarNav = props=>{
132133
)
133134

134135
return <CSidebarNavItem
135-
key={key}
136-
linkClassName={classes}
137-
linkProps={{
138-
icon: item.icon ? item.icon : 'user',
139-
to: item.url,
140-
label: true
141-
}}
136+
key={key}
137+
linkClassName={classes}
138+
linkProps={{
139+
icon: item.icon ? item.icon : 'user',
140+
to: item.url,
141+
label: true
142+
}}
143+
custom={false}
142144
>
143145
{item.name}
144146
</CSidebarNavItem>

src/CSidebarNavItem.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const CSidebarNavItem = props=>{
4646
return (
4747
!custom ?
4848
<Tag className={classes} {...attributes} ref={innerRef}>
49-
<CSidebarNavLink className={linkClasses} {...link}>
49+
<CSidebarNavLink custom={false} className={linkClasses} {...link}>
5050
{children}
5151
</CSidebarNavLink>
5252
</Tag> :
@@ -74,6 +74,7 @@ CSidebarNavItem.propTypes = {
7474
};
7575

7676
CSidebarNavItem.defaultProps = {
77+
custom: true,
7778
tag: 'li'
7879
};
7980

src/CSidebarNavLink.js

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ CSidebarNavLink.propTypes = {
7373
};
7474

7575
CSidebarNavLink.defaultProps = {
76+
custom: true
7677
};
7778

7879
export default CSidebarNavLink;

src/CTable.js

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ CTable.propTypes = {
8282
};
8383

8484
CTable.defaultProps = {
85+
custom: true,
8586
tag: 'table',
8687
responsiveTag: 'div',
8788
};

src/CToast.js

+1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ CToast.propTypes = {
135135
};
136136

137137
CToast.defaultProps = {
138+
custom: true,
138139
tag: 'div',
139140
autohide: 1500,
140141
closeButton: true,

src/CToggler.js

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ CToggler.propTypes = {
7676
};
7777

7878
CToggler.defaultProps = {
79+
custom: true,
7980
tag: 'button',
8081
type: 'button'
8182
};

src/CWidgetBrand.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const CWidgetBrand = props=>{
4444
);
4545

4646
return (
47-
<CCard {...attributes} custom>
47+
<CCard {...attributes}>
4848
<CCardHeader
4949
className={classes}
5050
>

src/CWidgetDropdown.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const CWidgetDropdown = props=>{
2323
} = props;
2424

2525
return (
26-
<CCard {...attributes} custom className="text-white" color={color}>
26+
<CCard {...attributes} className="text-white" color={color}>
2727
<CCardBody className="pb-0 d-flex justify-content-between">
2828
<div>
2929
{header?<div className="text-value-lg">{header}</div>:''}

src/CWidgetIcon.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const CWidgetIcon = props=>{
5858
};
5959

6060
return (
61-
<CCard {...attributes} custom>
61+
<CCard {...attributes}>
6262
<CCardBody className={card.classes} {...attributes}>
6363
<div>
6464
{blockIcon(card.icon)}

src/CWidgetProgress.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const CWidgetProgress = props=>{
4242
progress.style = classNames('progress-xs my-3', progress.style);
4343

4444
return (
45-
<CCard {...attributes} className={classes}>
45+
<CCard {...attributes} className={classes} custom={false}>
4646
<div className="h4 m-0">{header}</div>
4747
<div>{mainText}</div>
4848
<CProgress className={progress.style} color={progress.color} value={progress.value} />

src/CWidgetProgressIcon.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const CWidgetProgressIcon = props=>{
3939
progress.style = classNames('progress-xs mt-3 mb-0', progress.style);
4040

4141
return (
42-
<CCard {...attributes} className={classes}>
42+
<CCard {...attributes} className={classes} custom={false}>
4343
<div className="text-muted text-right mb-4">
4444
<CIcon name={card.icon} size="xl" />
4545
</div>

src/CWidgetSimple.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const CWidgetSimple = props=>{
3636
const classes = mapToCssModules(classNames(className, card.style, card.bgColor), cssModule);
3737

3838
return (
39-
<CCard {...attributes} custom className={classes}>
39+
<CCard {...attributes} className={classes}>
4040
<CCardBody className="text-center">
4141
{/*
4242
<CButtonGroup className="float-right">

0 commit comments

Comments
 (0)