2022-03-16 19:10:36 +08:00
|
|
|
// deps-lint-skip-all
|
2022-04-06 21:49:30 +08:00
|
|
|
import { FullToken, genComponentStyleHook } from '../../_util/theme';
|
|
|
|
import type { GenerateStyle } from '../../_util/theme';
|
2022-03-16 19:10:36 +08:00
|
|
|
import { operationUnit } from '../../_util/theme/util/operationUnit';
|
|
|
|
import {
|
|
|
|
getTitleStyles,
|
|
|
|
getResetStyles,
|
|
|
|
getLinkStyles,
|
|
|
|
getEditableStyles,
|
|
|
|
getCopiableStyles,
|
|
|
|
getEllipsisStyles,
|
|
|
|
} from './mixins';
|
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-03-16 19:10:36 +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-03-16 19:10:36 +08:00
|
|
|
overflowWrap: 'break-word',
|
|
|
|
'&&-secondary': {
|
2022-03-22 13:26:29 +08:00
|
|
|
color: token.colorTextSecondary,
|
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-03-16 19:10:36 +08:00
|
|
|
'a&:active, a&:focus, 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-04-06 21:49:30 +08:00
|
|
|
export default genComponentStyleHook('Typography', token => [genTypographyStyle(token)], {
|
|
|
|
sizeMarginHeadingVerticalStart: '1.2em',
|
|
|
|
sizeMarginHeadingVerticalEnd: '0.5em',
|
|
|
|
});
|