mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-10 13:29:11 +08:00
8e328d0ae2
* feat: focus outline * feat: add tree focus
124 lines
3.4 KiB
TypeScript
124 lines
3.4 KiB
TypeScript
import type { CSSObject } from '@ant-design/cssinjs';
|
|
import type { FullToken, GenerateStyle } from '../../theme';
|
|
import { genComponentStyleHook, mergeToken } from '../../theme';
|
|
import { genFocusStyle, resetComponent } from '../../style';
|
|
|
|
interface BreadcrumbToken extends FullToken<'Breadcrumb'> {
|
|
breadcrumbBaseColor: string;
|
|
breadcrumbFontSize: number;
|
|
breadcrumbIconFontSize: number;
|
|
breadcrumbLinkColor: string;
|
|
breadcrumbLinkColorHover: string;
|
|
breadcrumbLastItemColor: string;
|
|
breadcrumbSeparatorMargin: number;
|
|
breadcrumbSeparatorColor: string;
|
|
}
|
|
|
|
const genBreadcrumbStyle: GenerateStyle<BreadcrumbToken, CSSObject> = token => {
|
|
const { componentCls, iconCls } = token;
|
|
|
|
return {
|
|
[componentCls]: {
|
|
...resetComponent(token),
|
|
color: token.breadcrumbBaseColor,
|
|
fontSize: token.breadcrumbFontSize,
|
|
|
|
[iconCls]: {
|
|
fontSize: token.breadcrumbIconFontSize,
|
|
},
|
|
|
|
ol: {
|
|
display: 'flex',
|
|
flexWrap: 'wrap',
|
|
margin: 0,
|
|
padding: 0,
|
|
listStyle: 'none',
|
|
},
|
|
|
|
a: {
|
|
color: token.breadcrumbLinkColor,
|
|
transition: `color ${token.motionDurationFast}`,
|
|
padding: `0 ${token.paddingXXS}px`,
|
|
borderRadius: token.radiusSM,
|
|
height: token.lineHeight * token.fontSize,
|
|
display: 'inline-block',
|
|
marginInline: -token.marginXXS,
|
|
|
|
'&:hover': {
|
|
color: token.breadcrumbLinkColorHover,
|
|
backgroundColor: token.colorBgTextHover,
|
|
},
|
|
|
|
...genFocusStyle(token),
|
|
},
|
|
|
|
[`li:last-child > ${componentCls}-separator`]: {
|
|
display: 'none',
|
|
},
|
|
|
|
[`${componentCls}-separator`]: {
|
|
marginInline: token.breadcrumbSeparatorMargin,
|
|
color: token.breadcrumbSeparatorColor,
|
|
},
|
|
|
|
[`${componentCls}-link`]: {
|
|
[`
|
|
> ${iconCls} + span,
|
|
> ${iconCls} + a
|
|
`]: {
|
|
marginInlineStart: token.marginXXS,
|
|
},
|
|
},
|
|
|
|
[`${componentCls}-overlay-link`]: {
|
|
borderRadius: token.radiusSM,
|
|
height: token.lineHeight * token.fontSize,
|
|
display: 'inline-block',
|
|
padding: `0 ${token.paddingXXS}px`,
|
|
marginInline: -token.marginXXS,
|
|
|
|
[`> ${iconCls}`]: {
|
|
marginInlineStart: token.marginXXS,
|
|
fontSize: token.fontSizeIcon,
|
|
},
|
|
|
|
'&:hover': {
|
|
color: token.breadcrumbLinkColorHover,
|
|
backgroundColor: token.colorBgTextHover,
|
|
|
|
a: {
|
|
color: token.breadcrumbLinkColorHover,
|
|
},
|
|
},
|
|
|
|
a: {
|
|
'&:hover': {
|
|
backgroundColor: 'transparent',
|
|
},
|
|
},
|
|
},
|
|
|
|
// rtl style
|
|
[`&${token.componentCls}-rtl`]: {
|
|
direction: 'rtl',
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
// ============================== Export ==============================
|
|
export default genComponentStyleHook('Breadcrumb', token => {
|
|
const BreadcrumbToken = mergeToken<BreadcrumbToken>(token, {
|
|
breadcrumbBaseColor: token.colorTextDescription,
|
|
breadcrumbFontSize: token.fontSizeBase,
|
|
breadcrumbIconFontSize: token.fontSizeBase,
|
|
breadcrumbLinkColor: token.colorTextDescription,
|
|
breadcrumbLinkColorHover: token.colorText,
|
|
breadcrumbLastItemColor: token.colorText,
|
|
breadcrumbSeparatorMargin: token.marginXS,
|
|
breadcrumbSeparatorColor: token.colorTextDescription,
|
|
});
|
|
|
|
return [genBreadcrumbStyle(BreadcrumbToken)];
|
|
});
|