2023-05-19 09:46:15 +08:00
|
|
|
import { operationUnit } from '../../style';
|
2022-11-23 20:22:38 +08:00
|
|
|
import type { FullToken, GenerateStyle } from '../../theme/internal';
|
|
|
|
import { genComponentStyleHook } from '../../theme/internal';
|
2022-03-16 19:10:36 +08:00
|
|
|
import {
|
2023-02-23 21:56:43 +08:00
|
|
|
getCopyableStyles,
|
2022-06-22 15:18:03 +08:00
|
|
|
getEditableStyles,
|
2022-03-16 19:10:36 +08:00
|
|
|
getEllipsisStyles,
|
2022-06-22 15:18:03 +08:00
|
|
|
getLinkStyles,
|
|
|
|
getResetStyles,
|
|
|
|
getTitleStyles,
|
2022-03-16 19:10:36 +08:00
|
|
|
} from './mixins';
|
2022-03-25 17:54:57 +08:00
|
|
|
|
|
|
|
/** Component only token. Which will handle additional calculation of alias token */
|
|
|
|
export interface ComponentToken {
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 标题上间距
|
|
|
|
* @descEN Margin top of title
|
|
|
|
*/
|
2023-05-19 09:46:15 +08:00
|
|
|
titleMarginTop: number | string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 标题下间距
|
|
|
|
* @descEN Margin bottom of title
|
|
|
|
*/
|
2023-05-19 09:46:15 +08:00
|
|
|
titleMarginBottom: number | string;
|
2022-03-25 17:54:57 +08:00
|
|
|
}
|
|
|
|
|
2022-04-06 21:49:30 +08:00
|
|
|
export type TypographyToken = FullToken<'Typography'>;
|
2019-02-19 11:42:05 +08:00
|
|
|
|
2022-11-13 14:33:07 +08:00
|
|
|
const genTypographyStyle: GenerateStyle<TypographyToken> = (token) => {
|
2023-05-19 09:46:15 +08:00
|
|
|
const { componentCls, titleMarginTop } = token;
|
2022-03-25 17:54:57 +08:00
|
|
|
|
2022-03-16 19:10:36 +08:00
|
|
|
return {
|
2022-04-06 21:49:30 +08:00
|
|
|
[componentCls]: {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: token.colorText,
|
2022-11-13 14:33:07 +08:00
|
|
|
wordBreak: 'break-word',
|
2022-09-09 10:53:03 +08:00
|
|
|
lineHeight: token.lineHeight,
|
2023-01-20 10:31:27 +08:00
|
|
|
[`&${componentCls}-secondary`]: {
|
2022-08-04 16:16:50 +08:00
|
|
|
color: token.colorTextDescription,
|
2022-03-16 19:10:36 +08:00
|
|
|
},
|
|
|
|
|
2023-01-20 10:31:27 +08:00
|
|
|
[`&${componentCls}-success`]: {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: token.colorSuccess,
|
2022-03-16 19:10:36 +08:00
|
|
|
},
|
|
|
|
|
2023-01-20 10:31:27 +08:00
|
|
|
[`&${componentCls}-warning`]: {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: token.colorWarning,
|
2022-03-16 19:10:36 +08:00
|
|
|
},
|
|
|
|
|
2023-01-20 10:31:27 +08:00
|
|
|
[`&${componentCls}-danger`]: {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: token.colorError,
|
2022-04-20 12:20:20 +08:00
|
|
|
'a&:active, a&:focus': {
|
|
|
|
color: token.colorErrorActive,
|
|
|
|
},
|
|
|
|
'a&:hover': {
|
2022-03-24 14:30:48 +08:00
|
|
|
color: token.colorErrorHover,
|
2022-03-16 19:10:36 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2023-01-20 10:31:27 +08:00
|
|
|
[`&${componentCls}-disabled`]: {
|
2022-03-22 20:02:04 +08:00
|
|
|
color: token.colorTextDisabled,
|
2022-03-16 19:10:36 +08:00
|
|
|
cursor: 'not-allowed',
|
|
|
|
userSelect: 'none',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`
|
|
|
|
div&,
|
|
|
|
p
|
|
|
|
`]: {
|
|
|
|
marginBottom: '1em',
|
|
|
|
},
|
|
|
|
|
|
|
|
...getTitleStyles(token),
|
|
|
|
|
|
|
|
[`
|
2023-01-20 10:31:27 +08:00
|
|
|
& + h1${componentCls},
|
|
|
|
& + h2${componentCls},
|
|
|
|
& + h3${componentCls},
|
|
|
|
& + h4${componentCls},
|
|
|
|
& + h5${componentCls}
|
2022-03-16 19:10:36 +08:00
|
|
|
`]: {
|
2023-05-19 09:46:15 +08:00
|
|
|
marginTop: titleMarginTop,
|
2022-03-16 19:10:36 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`
|
|
|
|
div,
|
|
|
|
ul,
|
|
|
|
li,
|
|
|
|
p,
|
|
|
|
h1,
|
|
|
|
h2,
|
|
|
|
h3,
|
|
|
|
h4,
|
|
|
|
h5`]: {
|
|
|
|
[`
|
|
|
|
+ h1,
|
|
|
|
+ h2,
|
|
|
|
+ h3,
|
|
|
|
+ h4,
|
|
|
|
+ h5
|
|
|
|
`]: {
|
2023-05-19 09:46:15 +08:00
|
|
|
marginTop: titleMarginTop,
|
2022-03-16 19:10:36 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-12-27 16:43:45 +08:00
|
|
|
...getResetStyles(token),
|
2022-03-16 19:10:36 +08:00
|
|
|
|
|
|
|
...getLinkStyles(token),
|
|
|
|
|
|
|
|
// Operation
|
|
|
|
[`
|
2022-04-06 21:49:30 +08:00
|
|
|
${componentCls}-expand,
|
|
|
|
${componentCls}-edit,
|
|
|
|
${componentCls}-copy
|
2022-03-16 19:10:36 +08:00
|
|
|
`]: {
|
|
|
|
...operationUnit(token),
|
|
|
|
marginInlineStart: token.marginXXS,
|
|
|
|
},
|
|
|
|
|
|
|
|
...getEditableStyles(token),
|
|
|
|
|
2023-02-23 21:56:43 +08:00
|
|
|
...getCopyableStyles(token),
|
2022-03-16 19:10:36 +08:00
|
|
|
|
|
|
|
...getEllipsisStyles(),
|
|
|
|
|
|
|
|
'&-rtl': {
|
|
|
|
direction: 'rtl',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2023-05-19 09:46:15 +08:00
|
|
|
export default genComponentStyleHook(
|
|
|
|
'Typography',
|
|
|
|
(token) => [genTypographyStyle(token)],
|
2023-07-05 17:49:59 +08:00
|
|
|
() => ({
|
2023-05-19 09:46:15 +08:00
|
|
|
titleMarginTop: '1.2em',
|
|
|
|
titleMarginBottom: '0.5em',
|
|
|
|
}),
|
|
|
|
);
|