mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-21 04:48:02 +08:00
47bd5ecccc
* feat: typograohy support collapse * feat: snap * feat: test * feat: 单测不符合预期 * feat: test * feat: 恢复 * feat: test * feat: test * feat: 修改命名 * feat: 代码优化 * feat: 添加控制台提示 * feat: snap * feat: symbol support function * feat: snap * fix: text * feat: snap * feat: api 修改 * feat: key 修改 * feat: 去掉参数 * feat: lint * feat: snap * feat: test * feat: use 2 * feat: review * feat: test * chore: part of it * chore: fix auto collapse logic * feat: 修改 doc 单测 * feat: doc * test: update testcase * docs: add more --------- Co-authored-by: 二货机器人 <smith3816@gmail.com>
144 lines
3.0 KiB
TypeScript
144 lines
3.0 KiB
TypeScript
import { operationUnit } from '../../style';
|
|
import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';
|
|
import { genStyleHooks } 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 {
|
|
/**
|
|
* @desc 标题上间距
|
|
* @descEN Margin top of title
|
|
*/
|
|
titleMarginTop: number | string;
|
|
/**
|
|
* @desc 标题下间距
|
|
* @descEN Margin bottom of title
|
|
*/
|
|
titleMarginBottom: number | string;
|
|
}
|
|
|
|
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}-collapse,
|
|
${componentCls}-edit,
|
|
${componentCls}-copy
|
|
`]: {
|
|
...operationUnit(token),
|
|
marginInlineStart: token.marginXXS,
|
|
},
|
|
|
|
...getEditableStyles(token),
|
|
|
|
...getCopyableStyles(token),
|
|
|
|
...getEllipsisStyles(),
|
|
|
|
'&-rtl': {
|
|
direction: 'rtl',
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
export const prepareComponentToken: GetDefaultToken<'Typography'> = () => ({
|
|
titleMarginTop: '1.2em',
|
|
titleMarginBottom: '0.5em',
|
|
});
|
|
|
|
// ============================== Export ==============================
|
|
export default genStyleHooks(
|
|
'Typography',
|
|
(token) => [genTypographyStyle(token)],
|
|
prepareComponentToken,
|
|
);
|