Skip to content

Commit

Permalink
feat: Tab Item support icon prop
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jia-nan committed Nov 24, 2023
1 parent b919db3 commit 3d42819
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion docs/examples/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import Tabs from'../../src';
import '../../assets/index.less';
import Tabs from '../../src';

export default () => {
const [destroy, setDestroy] = React.useState(false);
Expand All @@ -9,17 +9,20 @@ export default () => {
label: 'Light',
key: 'light',
children: 'Light!',
icon: <span>🌞</span>,
},
{
label: 'Bamboo',
key: 'bamboo',
children: 'Bamboo!',
icon: <span>🎋</span>,
},
{
label: 'Cute',
key: 'cute',
children: 'Cute!',
disabled: true,
icon: <span>🐼</span>,
},
]);

Expand All @@ -38,6 +41,7 @@ export default () => {
key: 'yo',
label: 'Yo',
children: 'Yo!',
icon: <span>👋</span>,
},
]);
}}
Expand Down
3 changes: 2 additions & 1 deletion src/TabNavList/TabNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function TabNode({
prefixCls,
id,
active,
tab: { key, label, disabled, closeIcon },
tab: { key, label, disabled, closeIcon, icon },
closable,
renderWrapper,
removeAriaLabel,
Expand Down Expand Up @@ -87,6 +87,7 @@ function TabNode({
}}
onFocus={onFocus}
>
{icon}
{label}
</div>

Expand Down
3 changes: 2 additions & 1 deletion src/TabPanelList/TabPane.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import classNames from 'classnames';
import * as React from 'react';

export interface TabPaneProps {
tab?: React.ReactNode;
Expand All @@ -10,6 +10,7 @@ export interface TabPaneProps {
forceRender?: boolean;
closable?: boolean;
closeIcon?: React.ReactNode;
icon?: React.ReactNode;

// Pass by TabPaneList
prefixCls?: string;
Expand Down
8 changes: 6 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@
]
}
},
"include": [".dumi/**/*", ".dumirc.ts", "**/*.ts", "**/*.tsx"]
}
"include": [
".dumirc.ts",
"**/*.ts",
"**/*.tsx"
]
}

0 comments on commit 3d42819

Please sign in to comment.