Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Tab Item support icon prop #680

Merged
merged 5 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}
>
<span className={`${tabPrefix}-btn-icon`}>{icon}</span>
li-jia-nan marked this conversation as resolved.
Show resolved Hide resolved
{label}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

icon 和 label 之间要有一个默认间距。

Copy link
Member Author

@li-jia-nan li-jia-nan Nov 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那我加个 span 标签,在 antd 里面加间距

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个间距直接用 css 就能覆盖吧

</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
12 changes: 12 additions & 0 deletions tests/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ exports[`Tabs.Basic Normal 1`] = `
role="tab"
tabindex="0"
>
<span
class="rc-tabs-tab-btn-icon"
/>
light
</div>
</div>
Expand All @@ -42,6 +45,9 @@ exports[`Tabs.Basic Normal 1`] = `
role="tab"
tabindex="0"
>
<span
class="rc-tabs-tab-btn-icon"
/>
bamboo
</div>
</div>
Expand All @@ -57,6 +63,9 @@ exports[`Tabs.Basic Normal 1`] = `
role="tab"
tabindex="0"
>
<span
class="rc-tabs-tab-btn-icon"
/>
cute
</div>
</div>
Expand Down Expand Up @@ -131,6 +140,9 @@ exports[`Tabs.Basic Skip invalidate children 1`] = `
role="tab"
tabindex="0"
>
<span
class="rc-tabs-tab-btn-icon"
/>
light
</div>
</div>
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"
]
}
Loading