Skip to content

Commit 131cb2e

Browse files
committed
Allow overwritting of classnames
Allow arrays and objects of classnames
1 parent 27911f1 commit 131cb2e

File tree

6 files changed

+28
-24
lines changed

6 files changed

+28
-24
lines changed

src/components/Tab.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import cx from 'classnames';
55
export default class Tab extends Component {
66

77
static defaultProps = {
8+
className: 'ReactTabs__Tab',
89
focus: false,
910
id: null,
1011
panelId: null,
@@ -19,7 +20,7 @@ export default class Tab extends Component {
1920
PropTypes.object,
2021
PropTypes.string,
2122
]),
22-
className: PropTypes.string,
23+
className: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.object]),
2324
disabled: PropTypes.bool,
2425
focus: PropTypes.bool, // private
2526
id: PropTypes.string, // private
@@ -60,7 +61,6 @@ export default class Tab extends Component {
6061
<li
6162
{...attributes}
6263
className={cx(
63-
'ReactTabs__Tab',
6464
className,
6565
{
6666
[activeClassName]: selected,

src/components/TabList.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ import cx from 'classnames';
44

55
export default class TabList extends Component {
66

7+
static defaultProps = {
8+
className: 'ReactTabs__TabList',
9+
};
10+
711
static propTypes = {
812
children: PropTypes.oneOfType([
913
PropTypes.object,
1014
PropTypes.array,
1115
]),
12-
className: PropTypes.string,
16+
className: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.object]),
1317
};
1418

1519
render() {
@@ -21,10 +25,7 @@ export default class TabList extends Component {
2125
return (
2226
<ul
2327
{...attributes}
24-
className={cx(
25-
'ReactTabs__TabList',
26-
className,
27-
)}
28+
className={cx(className)}
2829
role="tablist"
2930
>
3031
{children}

src/components/TabPanel.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import cx from 'classnames';
55
export default class TabPanel extends Component {
66

77
static defaultProps = {
8+
className: 'ReactTabs__TabPanel',
89
style: {},
910
};
1011

1112
static propTypes = {
1213
activeClassName: PropTypes.string, // private
1314
children: PropTypes.node,
14-
className: PropTypes.string,
15+
className: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.object]),
1516
forceRenderTabPanel: PropTypes.bool, // private
1617
id: PropTypes.string, // private
1718
selected: PropTypes.bool, // private
@@ -35,7 +36,6 @@ export default class TabPanel extends Component {
3536
<div
3637
{...attributes}
3738
className={cx(
38-
'ReactTabs__TabPanel',
3939
className,
4040
{
4141
[activeClassName]: selected,
@@ -44,7 +44,6 @@ export default class TabPanel extends Component {
4444
role="tabpanel"
4545
id={id}
4646
aria-labelledby={tabId}
47-
style={{ ...style, display: selected ? null : 'none' }}
4847
>
4948
{(forceRenderTabPanel || selected) ? children : null}
5049
</div>

src/components/Tabs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default class Tabs extends Component {
1717
activeTabClassName: PropTypes.string,
1818
activeTabPanelClassName: PropTypes.string,
1919
children: childrenPropType,
20-
className: PropTypes.string,
20+
className: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.object]),
2121
defaultFocus: PropTypes.bool,
2222
defaultIndex: PropTypes.number,
2323
disabledTabClassName: PropTypes.string,

src/components/UncontrolledTabs.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class UncontrolledTabs extends Component {
2323
static defaultProps = {
2424
activeTabClassName: 'ReactTabs__Tab--selected',
2525
activeTabPanelClassName: 'ReactTabs__TabPanel--selected',
26-
className: '',
26+
className: 'ReactTabs',
2727
disabledTabClassName: 'ReactTabs__Tab--disabled',
2828
focus: false,
2929
forceRenderTabPanel: false,
@@ -33,7 +33,7 @@ export default class UncontrolledTabs extends Component {
3333
activeTabClassName: PropTypes.string,
3434
activeTabPanelClassName: PropTypes.string,
3535
children: childrenPropType,
36-
className: PropTypes.string,
36+
className: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
3737
disabledTabClassName: PropTypes.string,
3838
focus: PropTypes.bool,
3939
forceRenderTabPanel: PropTypes.bool,
@@ -270,10 +270,7 @@ export default class UncontrolledTabs extends Component {
270270
return (
271271
<div
272272
{...attributes}
273-
className={cx(
274-
'ReactTabs',
275-
className,
276-
)}
273+
className={cx(className)}
277274
onClick={this.handleClick}
278275
onKeyDown={this.handleKeyDown}
279276
ref={(node) => { this.node = node; }}

style/react-tabs.css

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
.react-tabs [role=tablist] {
1+
.ReactTabs__TabList {
22
border-bottom: 1px solid #aaa;
33
margin: 0 0 10px;
44
padding: 0;
55
}
66

7-
.react-tabs [role=tab] {
7+
.ReactTabs__Tab {
88
display: inline-block;
99
border: 1px solid transparent;
1010
border-bottom: none;
@@ -15,7 +15,7 @@
1515
cursor: pointer;
1616
}
1717

18-
.react-tabs [role=tab][aria-selected=true] {
18+
.ReactTabs__Tab--selected {
1919
background: #fff;
2020
border-color: #aaa;
2121
color: black;
@@ -24,18 +24,26 @@
2424
-webkit-border-radius: 5px 5px 0 0;
2525
}
2626

27-
.react-tabs [role=tab][aria-disabled=true] {
27+
.ReactTabs__TabPanel {
28+
display: none;
29+
}
30+
31+
.ReactTabs__TabPanel--selected {
32+
display: block;
33+
}
34+
35+
.ReactTabs__Tab--disabled {
2836
color: GrayText;
2937
cursor: default;
3038
}
3139

32-
.react-tabs [role=tab]:focus {
40+
.ReactTabs__Tab:focus {
3341
box-shadow: 0 0 5px hsl(208, 99%, 50%);
3442
border-color: hsl(208, 99%, 50%);
3543
outline: none;
3644
}
3745

38-
.react-tabs [role=tab]:focus:after {
46+
.ReactTabs__Tab:focus:after {
3947
content: "";
4048
position: absolute;
4149
height: 5px;
@@ -44,4 +52,3 @@
4452
bottom: -5px;
4553
background: #fff;
4654
}
47-

0 commit comments

Comments
 (0)