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

Display the close icon when hovering over the title in the tabs component mouse #48162

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions components/tabs/demo/component-token.tsx
Expand Up @@ -14,6 +14,7 @@ const App: React.FC = () => (
titleFontSize: 20,
titleFontSizeLG: 20,
titleFontSizeSM: 20,
titleHoverCloseIcon: 'block',
inkBarColor: '#52C41A',
horizontalMargin: `0 0 12px 0`,
horizontalItemGutter: 12, // Fixed Value
Expand Down
11 changes: 11 additions & 0 deletions components/tabs/style/index.ts
Expand Up @@ -7,6 +7,11 @@ import { genStyleHooks, mergeToken } from '../../theme/internal';
import genMotionStyle from './motion';

export interface ComponentToken {
/**
* @desc 可编辑卡片标签标题鼠标悬浮显示关闭图标
* @descEN Editable card label title, hovering mouse display, off icon
*/
titleHoverCloseIcon: string;
/**
* @desc 下拉菜单 z-index
* @descEN z-index of dropdown menu
Expand Down Expand Up @@ -698,6 +703,7 @@ const genTabStyle: GenerateStyle<TabsToken, CSSObject> = (token: TabsToken) => {
},
'&-remove': {
flex: 'none',
display: token.titleHoverCloseIcon,
marginRight: {
_skip_check_: true,
value: token.calc(token.marginXXS).mul(-1).equal(),
Expand All @@ -721,6 +727,10 @@ const genTabStyle: GenerateStyle<TabsToken, CSSObject> = (token: TabsToken) => {
color: itemHoverColor,
},

[`&:hover ${tabCls}-remove`]: {
display: 'block'
},

[`&${tabCls}-active ${tabCls}-btn`]: {
color: itemSelectedColor,
textShadow: token.tabsActiveTextShadow,
Expand Down Expand Up @@ -1028,6 +1038,7 @@ export const prepareComponentToken: GetDefaultToken<'Tabs'> = (token) => {
titleFontSize: token.fontSize,
titleFontSizeLG: token.fontSizeLG,
titleFontSizeSM: token.fontSize,
titleHoverCloseIcon: token.hoverDisplay,
inkBarColor: token.colorPrimary,
horizontalMargin: `0 0 ${token.margin}px 0`,
horizontalItemGutter: 32, // Fixed Value
Expand Down
10 changes: 10 additions & 0 deletions components/theme/interface/maps/style.ts
Expand Up @@ -40,4 +40,14 @@ export interface StyleMapToken {
* @descEN Outer border radius
*/
borderRadiusOuter: number;

// hover
/**
* @nameZH 布局(悬浮)
* @nameEN display (hover)
* @desc 布局(悬浮),用于组件鼠标悬浮后样式变换
* @descEN display (hover), Used for style transformation after hovering the mouse over components
* @default 'block''
*/
hoverDisplay: string;
}
2 changes: 2 additions & 0 deletions components/theme/util/alias.ts
Expand Up @@ -165,6 +165,8 @@ export default function formatToken(derivativeToken: RawMergedToken): AliasToken
screenXXL,
screenXXLMin: screenXXL,

hoverDisplay: 'block',

boxShadowPopoverArrow: '2px 2px 5px rgba(0, 0, 0, 0.05)',
boxShadowCard: `
0 1px 2px -2px ${new TinyColor('rgba(0, 0, 0, 0.16)').toRgbString()},
Expand Down
1 change: 1 addition & 0 deletions docs/react/migrate-less-variables.en-US.md
Expand Up @@ -827,6 +827,7 @@ export default App;
| `@tabs-title-font-size` | `titleFontSize` | - |
| `@tabs-title-font-size-lg` | `titleFontSizeLG` | - |
| `@tabs-title-font-size-sm` | `titleFontSizeSM` | - |
| `@tabs-title-hover-close-icon` | `titleHoverCloseIcon` | - |
| `@tabs-ink-bar-color` | `inkBarColor` | - |
| `@tabs-bar-margin` | `horizontalMargin` | - |
| `@tabs-horizontal-gutter` | `horizontalItemGutter` | - |
Expand Down
1 change: 1 addition & 0 deletions docs/react/migrate-less-variables.zh-CN.md
Expand Up @@ -827,6 +827,7 @@ Mentions 提及
| `@tabs-title-font-size` | `titleFontSize` | - |
| `@tabs-title-font-size-lg` | `titleFontSizeLG` | - |
| `@tabs-title-font-size-sm` | `titleFontSizeSM` | - |
| `@tabs-title-hover-close-icon` | `titleHoverCloseIcon` | - |
| `@tabs-ink-bar-color` | `inkBarColor` | - |
| `@tabs-bar-margin` | `horizontalMargin` | - |
| `@tabs-horizontal-gutter` | `horizontalItemGutter` | - |
Expand Down