Skip to content

Commit 62c8a5f

Browse files
Merge branch 'master' into new-title
2 parents 1474dca + 9dfe1ea commit 62c8a5f

File tree

10 files changed

+72
-11
lines changed

10 files changed

+72
-11
lines changed

.npmignore

+1-7
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,22 @@
33

44
# dependencies
55
/node_modules
6-
/.pnp
7-
.pnp.js
86

97
# production
10-
webpack*
11-
rollup*
12-
.babelrc.js
8+
/.github
139

1410
#development
1511
/build
1612
/sandbox
1713

1814
#demo
1915
/example
20-
index.html
2116
/demo
2217

2318
# testing
2419
/coverage
2520

2621
# misc
27-
.DS_Store
2822
.env.local
2923
.env.development.local
3024
.env.test.local

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v6.2.0
2+
3+
Adding new option `tablistStyle`
4+
15
# v6.1.1
26

37
- Fix `ssr` rendering issue of `element-resize-detector` package

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Create responsive and dynamic tabs in React. This library supports ARIA accessib
4343
- [accessibility](#accessibility)
4444
- [isVertical](#isvertical)
4545
- [theme](#theme)
46+
- [tablistStyle](#tabliststyle)
4647
- [onLoad](#onload)
4748
- [onInit](#oninit)
4849
- [onChange](#onchange)
@@ -480,6 +481,33 @@ const [TabList, PanelList, ready] = useDynTabs({isVertical: true});
480481
useDynTabs({theme:'classic'});
481482
```
482483

484+
### tablistStyle
485+
486+
<table>
487+
<tbody>
488+
<tr>
489+
<th>type</th>
490+
<th>default value</th>
491+
<th>required</th>
492+
<th>description</th>
493+
</tr>
494+
<tr>
495+
<td>object</td>
496+
<td>{}</td>
497+
<td>no</td>
498+
<td>sets the style object for root element of Tablist</td>
499+
</tr>
500+
</tbody>
501+
</table>
502+
503+
**Example**
504+
505+
```js
506+
const [TabList, PanelList, ready] = useDynTabs({
507+
tablistStyle: {backgroundColor: 'blue'},
508+
});
509+
```
510+
483511
### onLoad
484512

485513
<table>

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-dyn-tabs",
3-
"version": "6.1.1",
3+
"version": "6.2.0",
44
"private": false,
55
"description": "Create responsive and dynamic tabs in React. This library supports ARIA accessibility and provides complete control over tab management using hooks.",
66
"keywords": [

src/tablistView/__snapshots__/tablistView.test.js.snap

+17
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ exports[`TabListView structure : children props 1`] = `
44
<div>
55
<div
66
className="rc-dyn-tabs-tablist-view rc-dyn-tabs-ltr all-themes"
7+
style={{}}
78
>
89
<div
910
className="rc-dyn-tabs-tablist-container"
@@ -16,6 +17,7 @@ exports[`TabListView structure : default options 1`] = `
1617
<div>
1718
<div
1819
className="rc-dyn-tabs-tablist-view rc-dyn-tabs-ltr all-themes"
20+
style={{}}
1921
/>
2022
</div>
2123
`;
@@ -24,6 +26,7 @@ exports[`TabListView structure : isVertical option 1`] = `
2426
<div>
2527
<div
2628
className="rc-dyn-tabs-tablist-view rc-dyn-tabs-ltr rc-dyn-tabs-vertical all-themes"
29+
style={{}}
2730
/>
2831
</div>
2932
`;
@@ -32,6 +35,20 @@ exports[`TabListView structure : rtl option 1`] = `
3235
<div>
3336
<div
3437
className="rc-dyn-tabs-tablist-view rc-dyn-tabs-rtl all-themes"
38+
style={{}}
39+
/>
40+
</div>
41+
`;
42+
43+
exports[`TabListView structure : style option 1`] = `
44+
<div>
45+
<div
46+
className="rc-dyn-tabs-tablist-view rc-dyn-tabs-ltr all-themes"
47+
style={
48+
{
49+
"backgroundColor": "red",
50+
}
51+
}
3552
/>
3653
</div>
3754
`;

src/tablistView/tablistView.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ export const tablistViewPropsManager = function (ins) {
88
if (themeName) {
99
className += ' ' + themeName;
1010
}
11-
return {className};
11+
const tablistStyle = ins.getOption('tablistStyle') || {};
12+
const result = {className};
13+
if (typeof tablistStyle === 'object') {
14+
result.style = tablistStyle;
15+
}
16+
return result;
1217
};
1318
export default TablistView.bind(undefined, (ins) => ({
1419
tablistViewPropsManager: () => tablistViewPropsManager(ins),

src/tablistView/tablistView.test.js

+11
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,15 @@ describe('TabListView structure : ', () => {
7070
.toJSON();
7171
expect(tree).toMatchSnapshot();
7272
});
73+
test('style option', () => {
74+
setMockUseContext({tablistStyle: {backgroundColor: 'red'}});
75+
const tree = renderer
76+
.create(
77+
<div>
78+
<TablistView></TablistView>
79+
</div>,
80+
)
81+
.toJSON();
82+
expect(tree).toMatchSnapshot();
83+
});
7384
});

src/utils/api/optionManager/defaultOptions.js

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default Helper.module(
1616
tabs: [],
1717
selectedTabID: '',
1818
theme: 'all-themes',
19+
tablistStyle: {},
1920
beforeSelect: function () {
2021
return true;
2122
},

src/utils/api/optionManager/defaultOptions.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ describe('DefaultOptions.prototype.getOptions : ', () => {
66
tabs: [],
77
selectedTabID: '',
88
theme: 'all-themes',
9+
tablistStyle: {},
910
beforeSelect: expect.any(Function),
1011
beforeClose: expect.any(Function),
1112
onOpen: expect.any(Function),

0 commit comments

Comments
 (0)