Skip to content

Commit 41449d4

Browse files
update readme
1 parent b581210 commit 41449d4

File tree

1 file changed

+66
-62
lines changed

1 file changed

+66
-62
lines changed

README.md

Lines changed: 66 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ React Dynamic Tabs with full API
8080
```js
8181
$ npm install react-dyn-tabs --save
8282
```
83+
8384
or
8485

8586
```js
@@ -89,7 +90,7 @@ $ yarn add react-dyn-tabs
8990
## Syntax
9091

9192
```js
92-
[TabList,PanelList,ready] = useDynTabs(initialOptions,plugins);
93+
[TabList, PanelList, ready] = useDynTabs(initialOptions, plugins);
9394
```
9495

9596
## Minimal Usage Example
@@ -155,14 +156,14 @@ export default () => {
155156
const [TabList, PanelList, ready] = useDynTabs(initialOptions);
156157
const addTab3 = function () {
157158
ready((instance) => {
158-
// open tab 3
159-
instance.open({id: '3', title: 'Tab 3', panelComponent: (porps) => <p> panel 3 </p>}).then(() => {
160-
console.log('tab 3 is open');
161-
});
162-
// switch to tab 3
163-
instance.select('3').then(() => {
164-
console.log('tab 3 is selected');
165-
});
159+
// open tab 3
160+
instance.open({id: '3', title: 'Tab 3', panelComponent: (porps) => <p> panel 3 </p>}).then(() => {
161+
console.log('tab 3 is open');
162+
});
163+
// switch to tab 3
164+
instance.select('3').then(() => {
165+
console.log('tab 3 is selected');
166+
});
166167
});
167168
};
168169

@@ -180,12 +181,11 @@ export default () => {
180181

181182
- Use `ready` function to access the `instance` object
182183

183-
```js
184-
ready((instance) => {
185-
// manipulate tabs using instance object here
186-
});
187-
188-
```
184+
```js
185+
ready((instance) => {
186+
// manipulate tabs using instance object here
187+
});
188+
```
189189

190190
- `ready` function accepts a `callback` as its parameter and executes it as soon as Tabs get mounted.
191191

@@ -372,8 +372,6 @@ const [TabList, PanelList, ready] = useDynTabs({
372372
});
373373
```
374374

375-
376-
377375
### accessibility
378376

379377
<table>
@@ -886,7 +884,7 @@ Parameters:
886884
**Example**
887885

888886
```js
889-
const {id,title,tooltip,disable,lazy,iconClass,closable,panelComponent} = instance.getTab('contactID');
887+
const {id, title, tooltip, disable, lazy, iconClass, closable, panelComponent} = instance.getTab('contactID');
890888
console.log(id); //contactID
891889
```
892890

@@ -1197,7 +1195,6 @@ export default () => {
11971195
</div>
11981196
);
11991197
};
1200-
12011198
```
12021199

12031200
**Options**
@@ -1207,69 +1204,76 @@ export default () => {
12071204
<tr>
12081205
<th>option name</th>
12091206
<th>type</th>
1210-
<th>default value</th>
12111207
<th>description</th>
12121208
</tr>
12131209
<tr>
1214-
<td>moreButtonPlugin_buttonComponent *</td>
1215-
<td>React Component</td>
1216-
<td></td>
1217-
<td>customize button component of more button plugin</td>
1210+
<td>moreButtonPlugin_buttonComponent</td>
1211+
<td>React Function Component</td>
1212+
<td>customize root component of more button</td>
12181213
</tr>
12191214
<tr>
1220-
<td>moreButtonPlugin_iconComponent *</td>
1221-
<td>React Component</td>
1215+
<td>moreButtonPlugin_iconComponent</td>
1216+
<td>React Function Component</td>
1217+
<td>customize icon component of more button</td>
1218+
</tr>
1219+
<tr>
1220+
<td>moreButtonPlugin_buttonTooltip</td>
1221+
<td>string</td>
12221222
<td></td>
1223-
<td>customize icon component of more button plugin</td>
12241223
</tr>
12251224
</tbody>
12261225
</table>
12271226

12281227
**Example**
12291228

12301229
```js
1231-
useDynamicTabs({
1232-
moreButtonPlugin_iconComponent: ({ instance }) => {
1233-
return <i className={`fa fa-chevron-${instance.getOption('direction') === 'rtl' ? 'left' : 'right'}`} />
1234-
}
1235-
}, [MoreButtonPlugin]);
1230+
useDynamicTabs(
1231+
{
1232+
moreButtonPlugin_iconComponent: ({instance}) => {
1233+
return <i className={`fa fa-chevron-${instance.getOption('direction') === 'rtl' ? 'left' : 'right'}`} />;
1234+
},
1235+
},
1236+
[MoreButtonPlugin],
1237+
);
12361238
```
12371239

12381240
## Render custom components at the end of the Tablist
12391241

12401242
- render `new tab` button example :
1241-
```js
1242-
const [TabList, PanelList, ready] = useDynTabs(initialOptions, [MoreButtonPlugin]);
1243-
return (
1244-
<div>
1245-
<TabList>
1246-
<button onClick={()=>{ ready(instance => instance.open({title:'new tab'})) }}>
1247-
NEW
1248-
</button>
1249-
</TabList>
1250-
<PanelList></PanelList>
1251-
</div>
1252-
);
1253-
};
1254-
1255-
```
1243+
1244+
```js
1245+
const [TabList, PanelList, ready] = useDynTabs(initialOptions, [MoreButtonPlugin]);
1246+
return (
1247+
<div>
1248+
<TabList>
1249+
<button onClick={()=>{ ready(instance => instance.open({title:'new tab'})) }}>
1250+
NEW
1251+
</button>
1252+
</TabList>
1253+
<PanelList></PanelList>
1254+
</div>
1255+
);
1256+
};
1257+
1258+
```
12561259

12571260
- render `close all` button example :
1258-
```js
1259-
const [TabList, PanelList, ready] = useDynTabs(initialOptions, [MoreButtonPlugin]);
1260-
return (
1261-
<div>
1262-
<TabList>
1263-
<button onClick={()=>{ ready(instance=>{ instance.getData().openTabIDs.forEach(id=>instance.close(id,false)); })}}>
1264-
CLOSE ALL
1265-
</button>
1266-
</TabList>
1267-
<PanelList></PanelList>
1268-
</div>
1269-
);
1270-
};
1271-
1272-
```
1261+
1262+
```js
1263+
const [TabList, PanelList, ready] = useDynTabs(initialOptions, [MoreButtonPlugin]);
1264+
return (
1265+
<div>
1266+
<TabList>
1267+
<button onClick={()=>{ ready(instance=>{ instance.getData().openTabIDs.forEach(id=>instance.close(id,false)); })}}>
1268+
CLOSE ALL
1269+
</button>
1270+
</TabList>
1271+
<PanelList></PanelList>
1272+
</div>
1273+
);
1274+
};
1275+
1276+
```
12731277

12741278
## Styling
12751279

0 commit comments

Comments
 (0)