mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-04 00:49:39 +08:00
3bfb7ac2a0
* feat: less to component token for Typography * feat: add titleFontWeight token * feat: add debug demo * chore: rename token * chore: rename demo name * chore: rename titleFontWeight --------- Co-authored-by: zhangjianxiong <zhangjx@tsintergy.com> Co-authored-by: MadCcc <1075746765@qq.com> Co-authored-by: lijianan <574980606@qq.com>
135 lines
2.8 KiB
TypeScript
135 lines
2.8 KiB
TypeScript
import { operationUnit } from '../../style';
|
|
import type { FullToken, GenerateStyle } from '../../theme/internal';
|
|
import { genComponentStyleHook } from '../../theme/internal';
|
|
import {
|
|
getCopyableStyles,
|
|
getEditableStyles,
|
|
getEllipsisStyles,
|
|
getLinkStyles,
|
|
getResetStyles,
|
|
getTitleStyles,
|
|
} from './mixins';
|
|
|
|
/** Component only token. Which will handle additional calculation of alias token */
|
|
export interface ComponentToken {
|
|
titleMarginTop: number | string;
|
|
titleMarginBottom: number | string;
|
|
fontWeightStrong: number;
|
|
}
|
|
|
|
export type TypographyToken = FullToken<'Typography'>;
|
|
|
|
const genTypographyStyle: GenerateStyle<TypographyToken> = (token) => {
|
|
const { componentCls, titleMarginTop } = token;
|
|
|
|
return {
|
|
[componentCls]: {
|
|
color: token.colorText,
|
|
wordBreak: 'break-word',
|
|
lineHeight: token.lineHeight,
|
|
[`&${componentCls}-secondary`]: {
|
|
color: token.colorTextDescription,
|
|
},
|
|
|
|
[`&${componentCls}-success`]: {
|
|
color: token.colorSuccess,
|
|
},
|
|
|
|
[`&${componentCls}-warning`]: {
|
|
color: token.colorWarning,
|
|
},
|
|
|
|
[`&${componentCls}-danger`]: {
|
|
color: token.colorError,
|
|
'a&:active, a&:focus': {
|
|
color: token.colorErrorActive,
|
|
},
|
|
'a&:hover': {
|
|
color: token.colorErrorHover,
|
|
},
|
|
},
|
|
|
|
[`&${componentCls}-disabled`]: {
|
|
color: token.colorTextDisabled,
|
|
cursor: 'not-allowed',
|
|
userSelect: 'none',
|
|
},
|
|
|
|
[`
|
|
div&,
|
|
p
|
|
`]: {
|
|
marginBottom: '1em',
|
|
},
|
|
|
|
...getTitleStyles(token),
|
|
|
|
[`
|
|
& + h1${componentCls},
|
|
& + h2${componentCls},
|
|
& + h3${componentCls},
|
|
& + h4${componentCls},
|
|
& + h5${componentCls}
|
|
`]: {
|
|
marginTop: titleMarginTop,
|
|
},
|
|
|
|
[`
|
|
div,
|
|
ul,
|
|
li,
|
|
p,
|
|
h1,
|
|
h2,
|
|
h3,
|
|
h4,
|
|
h5`]: {
|
|
[`
|
|
+ h1,
|
|
+ h2,
|
|
+ h3,
|
|
+ h4,
|
|
+ h5
|
|
`]: {
|
|
marginTop: titleMarginTop,
|
|
},
|
|
},
|
|
|
|
...getResetStyles(token),
|
|
|
|
...getLinkStyles(token),
|
|
|
|
// Operation
|
|
[`
|
|
${componentCls}-expand,
|
|
${componentCls}-edit,
|
|
${componentCls}-copy
|
|
`]: {
|
|
...operationUnit(token),
|
|
marginInlineStart: token.marginXXS,
|
|
},
|
|
|
|
...getEditableStyles(token),
|
|
|
|
...getCopyableStyles(token),
|
|
|
|
...getEllipsisStyles(),
|
|
|
|
'&-rtl': {
|
|
direction: 'rtl',
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
// ============================== Export ==============================
|
|
export default genComponentStyleHook(
|
|
'Typography',
|
|
(token) => [genTypographyStyle(token)],
|
|
(token) => ({
|
|
titleMarginTop: '1.2em',
|
|
titleMarginBottom: '0.5em',
|
|
fontWeightStrong: token.fontWeightStrong,
|
|
}),
|
|
);
|