Skip to content

Commit a4188a9

Browse files
authored
Merge branch 'master' into patch-1
2 parents 7b3aacf + 2fa1d36 commit a4188a9

37 files changed

+932
-511
lines changed

.dumirc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export default defineConfig({
55
name: 'Tabs',
66
},
77
mfsu: false,
8-
});
8+
});

.github/FUNDING.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# These are supported funding model platforms
2+
3+
github: ant-design # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: ant-design # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12+
polar: # Replace with a single Polar username
13+
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
14+
thanks_dev: # Replace with a single thanks.dev username
15+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/workflows/main.yml

Lines changed: 5 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,6 @@
1-
name: CI
2-
3-
on:
4-
push:
5-
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
8-
1+
name: ✅ test
2+
on: [push, pull_request]
93
jobs:
10-
setup:
11-
runs-on: ubuntu-latest
12-
steps:
13-
- name: checkout
14-
uses: actions/checkout@master
15-
16-
- uses: actions/setup-node@v1
17-
with:
18-
node-version: '12'
19-
20-
- name: cache package-lock.json
21-
uses: actions/cache@v2
22-
with:
23-
path: package-temp-dir
24-
key: lock-${{ github.sha }}
25-
26-
- name: create package-lock.json
27-
run: npm i --package-lock-only
28-
29-
- name: hack for singe file
30-
run: |
31-
if [ ! -d "package-temp-dir" ]; then
32-
mkdir package-temp-dir
33-
fi
34-
cp package-lock.json package-temp-dir
35-
36-
- name: cache node_modules
37-
id: node_modules_cache_id
38-
uses: actions/cache@v2
39-
with:
40-
path: node_modules
41-
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
42-
43-
- name: install
44-
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
45-
run: npm ci
46-
47-
lint:
48-
runs-on: ubuntu-latest
49-
steps:
50-
- name: checkout
51-
uses: actions/checkout@master
52-
53-
- name: restore cache from package-lock.json
54-
uses: actions/cache@v2
55-
with:
56-
path: package-temp-dir
57-
key: lock-${{ github.sha }}
58-
59-
- name: restore cache from node_modules
60-
uses: actions/cache@v2
61-
with:
62-
path: node_modules
63-
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
64-
65-
- name: lint
66-
run: npm run lint
67-
68-
needs: setup
69-
70-
compile:
71-
runs-on: ubuntu-latest
72-
steps:
73-
- name: checkout
74-
uses: actions/checkout@master
75-
76-
- name: restore cache from package-lock.json
77-
uses: actions/cache@v2
78-
with:
79-
path: package-temp-dir
80-
key: lock-${{ github.sha }}
81-
82-
- name: restore cache from node_modules
83-
uses: actions/cache@v2
84-
with:
85-
path: node_modules
86-
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
87-
88-
- name: compile
89-
run: npm run compile
90-
91-
needs: setup
92-
93-
coverage:
94-
runs-on: ubuntu-latest
95-
steps:
96-
- name: checkout
97-
uses: actions/checkout@master
98-
99-
- name: restore cache from package-lock.json
100-
uses: actions/cache@v2
101-
with:
102-
path: package-temp-dir
103-
key: lock-${{ github.sha }}
104-
105-
- name: restore cache from node_modules
106-
uses: actions/cache@v2
107-
with:
108-
path: node_modules
109-
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
110-
111-
- name: coverage
112-
run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash)
113-
114-
needs: setup
4+
test:
5+
uses: react-component/rc-test/.github/workflows/test.yml@main
6+
secrets: inherit

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ es
3131
coverage
3232
yarn.lock
3333
package-lock.json
34+
pnpm-lock.yaml
3435

3536
# umi
3637
.umi
3738
.umi-production
3839
.umi-test
3940
.env.local
40-
.dumi
41+
.dumi
42+
43+
bun.lockb

README.md

Lines changed: 88 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,53 @@ online example: https://tabs.react-component.now.sh/
4141

4242
## Usage
4343

44-
```js
45-
import Tabs, { TabPane } from 'rc-tabs';
46-
47-
var callback = function(key) {};
48-
49-
React.render(
50-
<Tabs defaultActiveKey="2" onChange={callback}>
51-
<TabPane tab="tab 1" key="1">
52-
first
53-
</TabPane>
54-
<TabPane tab="tab 2" key="2">
55-
second
56-
</TabPane>
57-
<TabPane tab="tab 3" key="3">
58-
third
59-
</TabPane>
60-
</Tabs>,
61-
document.getElementById('t2'),
44+
```tsx | pure
45+
import Tabs from 'rc-tabs';
46+
import ReactDom from 'react-dom';
47+
48+
const callback = (key) => {
49+
console.log(key);
50+
};
51+
52+
const items = [
53+
{
54+
key: '1',
55+
label: 'Google',
56+
children: (
57+
<div className="text-xl">
58+
<p>Lorem Ipsum is simply dummy text of the printing and typesetting</p>
59+
</div>
60+
),
61+
},
62+
{
63+
key: '2',
64+
label: <p>Amazon</p>,
65+
children:
66+
'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...',
67+
disabled: true,
68+
},
69+
{
70+
key: '3',
71+
label: <p>Twitter</p>,
72+
children: (
73+
<div>
74+
"There is no one who loves pain itself, who seeks after it and wants to have it, simply
75+
because it is pain..."
76+
</div>
77+
),
78+
},
79+
];
80+
81+
ReactDom.render(
82+
<Tabs
83+
tabPosition="bottom"
84+
items={items}
85+
defaultActiveKey="1"
86+
className="md:w-[70%] w-full mx-auto p-2 border-0"
87+
onChange={callback}
88+
style={{ color: 'yellow' }}
89+
/>,
90+
root,
6291
);
6392
```
6493

@@ -68,29 +97,57 @@ React.render(
6897

6998
| name | type | default | description |
7099
| --- | --- | --- | --- |
100+
| prefixCls | string | `'rc-tabs'` | prefix class name, use to custom style |
101+
| className | string | - | to define a class name for an element |
102+
| style | CSS properties | - | object with css properties for styling |
103+
| items | TabItem[] | [] | configure tab content |
104+
| id | string | - | unique identifier |
105+
| defaultActiveKey | string | - | initial active tabPanel's key if activeKey is absent |
71106
| activeKey | string | - | current active tabPanel's key |
107+
| direction | `'ltr' or 'rtl'` | `'ltr'` | Layout direction of tabs component |
72108
| animated | boolean \| { inkBar: boolean, tabPane: boolean } | `{ inkBar: true, tabPane: false }` | config animation |
73-
| defaultActiveKey | string | - | initial active tabPanel's key if activeKey is absent |
74-
| destroyInactiveTabPane | boolean | false | whether destroy inactive TabPane when change tab |
75-
| direction | `'ltr' | 'rlt'` | `'ltr'` | Layout direction of tabs component |
76-
| editable | { onEdit(type: 'add' | 'remove', info: { key, event }), showAdd: boolean, removeIcon: ReactNode, addIcon: ReactNode } | - | config tab editable |
77-
| locale | { dropdownAriaLabel: string, removeAriaLabel: string, addAriaLabel: string } | - | Accessibility locale help text |
78-
| moreIcon | ReactNode | - | collapse icon |
109+
| renderTabBar | (props, TabBarComponent) => ReactElement | - | How to render tab bar |
110+
| tabBarExtraContent | ReactNode \| `{ left: ReactNode, right: ReactNode }` | - | config extra content |
79111
| tabBarGutter | number | 0 | config tab bar gutter |
80-
| tabBarPosition | `'left' | 'right' | 'top' | 'bottom'` | `'top'` | tab nav 's position |
112+
| tabBarPosition | `'left' \| 'right' \| 'top' \| 'bottom'` | `'top'` | tab nav 's position |
81113
| tabBarStyle | style | - | tab nav style |
82-
| tabBarExtraContent | ReactNode \| `{ left: ReactNode, right: ReactNode }` | - | config extra content |
83-
| renderTabBar | (props, TabBarComponent) => ReactElement | - | How to render tab bar |
84-
| prefixCls | string | `'rc-tabs'` | prefix class name, use to custom style |
114+
| tabPosition | `'left' or 'right' or 'top' or 'bottom'` | `'top'` | tab nav 's position |
115+
| destroyInactiveTabPane | boolean | false | whether destroy inactive TabPane when change tab |
85116
| onChange | (key) => void | - | called when tabPanel is changed |
86117
| onTabClick | (key) => void | - | called when tab click |
87118
| onTabScroll | ({ direction }) => void | - | called when tab scroll |
119+
| editable | { onEdit(type: 'add' \| 'remove', info: { key, event }), showAdd: boolean, removeIcon: ReactNode, addIcon: ReactNode } | - | config tab editable |
120+
| locale | { dropdownAriaLabel: string, removeAriaLabel: string, addAriaLabel: string } | - | Accessibility locale help text |
121+
| moreIcon | ReactNode | - | collapse icon |
88122

89-
### TabPane
123+
### TabItem
90124

91125
| name | type | default | description |
92126
| --- | --- | --- | --- |
93127
| key | string | - | corresponding to activeKey, should be unique |
128+
| label | string | - | TabPane's head display text |
129+
| tab | ReactNode | - | current tab's title corresponding to current tabPane |
130+
| className | string | - | to define a class name for an element |
131+
| style | CSS properties | - | object with css properties for styling |
132+
| disabled | boolean | false | set TabPane disabled |
133+
| children | ReactNode | - | TabPane's head display content |
134+
| forceRender | boolean | false | forced render of content in tabs, not lazy render after clicking on tabs |
135+
| closable | boolean | false | closable feature of tab item |
136+
| closeIcon | ReactNode | - | Config close icon |
137+
| prefixCls | string | `'rc-tabs-tab'` | prefix class name, use to custom style |
138+
| id | string | - | unique identifier |
139+
| animated | boolean \| { inkBar: boolean, tabPane: boolean } | `{ inkBar: true, tabPane: false }` | config animation |
140+
| destroyInactiveTabPane | boolean | false | whether destroy inactive TabPane when change tab |
141+
| active | boolean | false | active feature of tab item |
142+
| tabKey | string | - | key linked to tab |
143+
144+
145+
### TabPane(support in older versions)
146+
147+
| name | type | default | description |
148+
| --- | --- | --- | --- |
149+
| destroyInactiveTabPane | boolean | false | whether destroy inactive TabPane when change tab |
150+
| key | string | - | corresponding to activeKey, should be unique |
94151
| forceRender | boolean | false | forced render of content in tabs, not lazy render after clicking on tabs |
95152
| tab | ReactNode | - | current tab's title corresponding to current tabPane |
96153
| closeIcon | ReactNode | - | Config close icon |
@@ -123,9 +180,9 @@ rc-tabs is released under the MIT license.
123180

124181
## FAQ
125182

126-
### Resposive Tabs
183+
### Responsive Tabs
127184

128-
There are 3 cases when handling resposive tabs:
185+
There are 3 cases when handling responsive tabs:
129186
![image](https://user-images.githubusercontent.com/27722486/156315099-7e6eda9d-ab77-4b16-9b49-1727c5ec8b26.png)
130187

131188
We get hidden tabs through [useVisibleRange.ts](https://github.com/react-component/tabs/blob/master/src/hooks/useVisibleRange.ts).

assets/position.less

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
flex-direction: column;
5353
min-width: 50px;
5454

55-
&-list, &-operations {
55+
&-list,
56+
&-operations {
5657
flex: 1 0 auto; // fix safari scroll problem
5758
flex-direction: column;
5859
}

docs/demo/dynamic-extra.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: dynamic-extra
3+
nav:
4+
title: Demo
5+
path: /demo
6+
---
7+
8+
<code src="../examples/dynamic-extra.tsx"></code>

docs/demo/indicator.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Indicator
3+
nav:
4+
title: Demo
5+
path: /demo
6+
---
7+
8+
<code src="../examples/indicator.tsx"></code>

docs/examples/basic.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
2-
import Tabs from'../../src';
32
import '../../assets/index.less';
3+
import Tabs from '../../src';
44

55
export default () => {
66
const [destroy, setDestroy] = React.useState(false);
@@ -9,17 +9,20 @@ export default () => {
99
label: 'Light',
1010
key: 'light',
1111
children: 'Light!',
12+
icon: <span>🌞</span>,
1213
},
1314
{
1415
label: 'Bamboo',
1516
key: 'bamboo',
1617
children: 'Bamboo!',
18+
icon: <span>🎋</span>,
1719
},
1820
{
1921
label: 'Cute',
2022
key: 'cute',
2123
children: 'Cute!',
2224
disabled: true,
25+
icon: <span>🐼</span>,
2326
},
2427
]);
2528

@@ -38,6 +41,7 @@ export default () => {
3841
key: 'yo',
3942
label: 'Yo',
4043
children: 'Yo!',
44+
icon: <span>👋</span>,
4145
},
4246
]);
4347
}}

0 commit comments

Comments
 (0)