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 {
|
|
|
|
getCopiableStyles,
|
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-07-11 15:35:58 +08:00
|
|
|
import { operationUnit } from '../../style';
|
2022-03-25 17:54:57 +08:00
|
|
|
|
|
|
|
/** Component only token. Which will handle additional calculation of alias token */
|
|
|
|
export interface ComponentToken {
|
|
|
|
sizeMarginHeadingVerticalStart: number | string;
|
|
|
|
sizeMarginHeadingVerticalEnd: number | string;
|
|
|
|
}
|
|
|
|
|
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) => {
|
2022-04-06 21:49:30 +08:00
|
|
|
const { componentCls, sizeMarginHeadingVerticalStart } = 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,
|
2022-03-16 19:10:36 +08:00
|
|
|
'&&-secondary': {
|
2022-08-04 16:16:50 +08:00
|
|
|
color: token.colorTextDescription,
|
2022-03-16 19:10:36 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&&-success': {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: token.colorSuccess,
|
2022-03-16 19:10:36 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&&-warning': {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: token.colorWarning,
|
2022-03-16 19:10:36 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&&-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
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&&-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),
|
|
|
|
|
|
|
|
[`
|
|
|
|
& + h1&,
|
|
|
|
& + h2&,
|
|
|
|
& + h3&,
|
|
|
|
& + h4&,
|
|
|
|
& + h5&
|
|
|
|
`]: {
|
2022-03-25 17:54:57 +08:00
|
|
|
marginTop: sizeMarginHeadingVerticalStart,
|
2022-03-16 19:10:36 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`
|
|
|
|
div,
|
|
|
|
ul,
|
|
|
|
li,
|
|
|
|
p,
|
|
|
|
h1,
|
|
|
|
h2,
|
|
|
|
h3,
|
|
|
|
h4,
|
|
|
|
h5`]: {
|
|
|
|
[`
|
|
|
|
+ h1,
|
|
|
|
+ h2,
|
|
|
|
+ h3,
|
|
|
|
+ h4,
|
|
|
|
+ h5
|
|
|
|
`]: {
|
2022-03-25 17:54:57 +08:00
|
|
|
marginTop: sizeMarginHeadingVerticalStart,
|
2022-03-16 19:10:36 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
...getResetStyles(),
|
|
|
|
|
|
|
|
...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),
|
|
|
|
|
|
|
|
...getCopiableStyles(token),
|
|
|
|
|
|
|
|
...getEllipsisStyles(),
|
|
|
|
|
|
|
|
'&-rtl': {
|
|
|
|
direction: 'rtl',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2022-11-13 14:33:07 +08:00
|
|
|
export default genComponentStyleHook('Typography', (token) => [genTypographyStyle(token)], {
|
2022-04-06 21:49:30 +08:00
|
|
|
sizeMarginHeadingVerticalStart: '1.2em',
|
|
|
|
sizeMarginHeadingVerticalEnd: '0.5em',
|
|
|
|
});
|