From 3d42819603f9a94c76f1d8a837a4da44fc763077 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Sat, 25 Nov 2023 02:55:06 +0800 Subject: [PATCH 1/5] feat: Tab Item support icon prop --- docs/examples/basic.tsx | 6 +++++- src/TabNavList/TabNode.tsx | 3 ++- src/TabPanelList/TabPane.tsx | 3 ++- tsconfig.json | 8 ++++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/examples/basic.tsx b/docs/examples/basic.tsx index 5864bc88..f38970ee 100644 --- a/docs/examples/basic.tsx +++ b/docs/examples/basic.tsx @@ -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); @@ -9,17 +9,20 @@ export default () => { label: 'Light', key: 'light', children: 'Light!', + icon: 🌞, }, { label: 'Bamboo', key: 'bamboo', children: 'Bamboo!', + icon: 🎋, }, { label: 'Cute', key: 'cute', children: 'Cute!', disabled: true, + icon: 🐼, }, ]); @@ -38,6 +41,7 @@ export default () => { key: 'yo', label: 'Yo', children: 'Yo!', + icon: 👋, }, ]); }} diff --git a/src/TabNavList/TabNode.tsx b/src/TabNavList/TabNode.tsx index a76d57ac..460f1e3f 100644 --- a/src/TabNavList/TabNode.tsx +++ b/src/TabNavList/TabNode.tsx @@ -24,7 +24,7 @@ function TabNode({ prefixCls, id, active, - tab: { key, label, disabled, closeIcon }, + tab: { key, label, disabled, closeIcon, icon }, closable, renderWrapper, removeAriaLabel, @@ -87,6 +87,7 @@ function TabNode({ }} onFocus={onFocus} > + {icon} {label} diff --git a/src/TabPanelList/TabPane.tsx b/src/TabPanelList/TabPane.tsx index e153623d..fdb4ba60 100644 --- a/src/TabPanelList/TabPane.tsx +++ b/src/TabPanelList/TabPane.tsx @@ -1,5 +1,5 @@ -import * as React from 'react'; import classNames from 'classnames'; +import * as React from 'react'; export interface TabPaneProps { tab?: React.ReactNode; @@ -10,6 +10,7 @@ export interface TabPaneProps { forceRender?: boolean; closable?: boolean; closeIcon?: React.ReactNode; + icon?: React.ReactNode; // Pass by TabPaneList prefixCls?: string; diff --git a/tsconfig.json b/tsconfig.json index f279d1b9..aeeacaa4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,5 +23,9 @@ ] } }, - "include": [".dumi/**/*", ".dumirc.ts", "**/*.ts", "**/*.tsx"] -} + "include": [ + ".dumirc.ts", + "**/*.ts", + "**/*.tsx" + ] +} \ No newline at end of file From a1e5acdeffca16459faf559be70a07bcd88f9974 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Sat, 25 Nov 2023 22:56:02 +0800 Subject: [PATCH 2/5] fix: add span Tag for icon --- src/TabNavList/TabNode.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TabNavList/TabNode.tsx b/src/TabNavList/TabNode.tsx index 460f1e3f..f2298749 100644 --- a/src/TabNavList/TabNode.tsx +++ b/src/TabNavList/TabNode.tsx @@ -87,7 +87,7 @@ function TabNode({ }} onFocus={onFocus} > - {icon} + {icon} {label} From c66f08d8da740c1a05b3451b9b40b0c81d827c0d Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Sat, 25 Nov 2023 23:08:08 +0800 Subject: [PATCH 3/5] test: update snap --- tests/__snapshots__/index.test.tsx.snap | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/__snapshots__/index.test.tsx.snap b/tests/__snapshots__/index.test.tsx.snap index 7fb34117..ae2295e1 100644 --- a/tests/__snapshots__/index.test.tsx.snap +++ b/tests/__snapshots__/index.test.tsx.snap @@ -27,6 +27,9 @@ exports[`Tabs.Basic Normal 1`] = ` role="tab" tabindex="0" > + light @@ -42,6 +45,9 @@ exports[`Tabs.Basic Normal 1`] = ` role="tab" tabindex="0" > + bamboo @@ -57,6 +63,9 @@ exports[`Tabs.Basic Normal 1`] = ` role="tab" tabindex="0" > + cute @@ -131,6 +140,9 @@ exports[`Tabs.Basic Skip invalidate children 1`] = ` role="tab" tabindex="0" > + light From 8bff0a8eaa3f0e44a410ffe0d119b40cd68d84fe Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Mon, 27 Nov 2023 10:08:11 +0800 Subject: [PATCH 4/5] Update src/TabNavList/TabNode.tsx Co-authored-by: MadCcc <1075746765@qq.com> --- src/TabNavList/TabNode.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TabNavList/TabNode.tsx b/src/TabNavList/TabNode.tsx index f2298749..0914ac29 100644 --- a/src/TabNavList/TabNode.tsx +++ b/src/TabNavList/TabNode.tsx @@ -87,7 +87,7 @@ function TabNode({ }} onFocus={onFocus} > - {icon} + {icon && {icon}} {label} From a851f15cd0256b3c1cb77abefeb8ce8a39f900bc Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Mon, 27 Nov 2023 10:14:54 +0800 Subject: [PATCH 5/5] test: update snap --- tests/__snapshots__/index.test.tsx.snap | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/__snapshots__/index.test.tsx.snap b/tests/__snapshots__/index.test.tsx.snap index ae2295e1..7fb34117 100644 --- a/tests/__snapshots__/index.test.tsx.snap +++ b/tests/__snapshots__/index.test.tsx.snap @@ -27,9 +27,6 @@ exports[`Tabs.Basic Normal 1`] = ` role="tab" tabindex="0" > - light @@ -45,9 +42,6 @@ exports[`Tabs.Basic Normal 1`] = ` role="tab" tabindex="0" > - bamboo @@ -63,9 +57,6 @@ exports[`Tabs.Basic Normal 1`] = ` role="tab" tabindex="0" > - cute @@ -140,9 +131,6 @@ exports[`Tabs.Basic Skip invalidate children 1`] = ` role="tab" tabindex="0" > - light