mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-19 20:08:43 +08:00
832cffcdf9
* refactor: support type update * chore: update clear style * chore: bump color picker * chore: use slider * chore: bump color picker * chore: range slider * chore: layout * chore: useModeColor * chore: simplify * chore: bump color picker * refactor: event * chore: tmp lock check * chore: of it * chore: update ts def * chore: update ts def * chore: remove useless ts * chore: linear * chore: adjust style * chore: rm useless code * chore: fill color * chore: basic linear * chore: support toStr * chore: limit minCount * chore: use cache * chore: drag support: * chore: yes * chore: update demo * chore: useLayoutEffect instead * chore: fix click to add point * chore: add smmoth * chore: support of locale * chore: add locale * chore: fix lint * chore: adjust style * chore: fix lint * chore: fix style * test: fix test case * chore: fix popover * test: fix test case * chore: fix test * test: clean up * chore: fix lint * chore: fix lint * chore: fix lint * test: coverage * test: coverage * test: coverage * test: coverage * test: coverage * test: coverage * chore: fix docs * docs: update demo desc * chore: enhance hover range * fix: delete not working * chore: fix lint * test: coverage * test: coverage * chore: clean up * chore: adjust * chore: highlight * chore: adjust style * chore: fix lint * chore: update demo * chore: memo perf * refactor: up to down colors * test: update snapshot
149 lines
3.6 KiB
TypeScript
149 lines
3.6 KiB
TypeScript
/* eslint-disable import/prefer-default-export */
|
|
import { unit } from '@ant-design/cssinjs';
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
|
|
|
import type { AliasToken } from '../theme/internal';
|
|
|
|
export { operationUnit } from './operationUnit';
|
|
|
|
export const textEllipsis: CSSObject = {
|
|
overflow: 'hidden',
|
|
whiteSpace: 'nowrap',
|
|
textOverflow: 'ellipsis',
|
|
};
|
|
|
|
export const resetComponent = (token: AliasToken, needInheritFontFamily = false): CSSObject => ({
|
|
boxSizing: 'border-box',
|
|
margin: 0,
|
|
padding: 0,
|
|
color: token.colorText,
|
|
fontSize: token.fontSize,
|
|
// font-variant: @font-variant-base;
|
|
lineHeight: token.lineHeight,
|
|
listStyle: 'none',
|
|
// font-feature-settings: @font-feature-settings-base;
|
|
fontFamily: needInheritFontFamily ? 'inherit' : token.fontFamily,
|
|
});
|
|
|
|
export const resetIcon = (): CSSObject => ({
|
|
display: 'inline-flex',
|
|
alignItems: 'center',
|
|
color: 'inherit',
|
|
fontStyle: 'normal',
|
|
lineHeight: 0,
|
|
textAlign: 'center',
|
|
textTransform: 'none',
|
|
// for SVG icon, see https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4
|
|
verticalAlign: '-0.125em',
|
|
textRendering: 'optimizeLegibility',
|
|
'-webkit-font-smoothing': 'antialiased',
|
|
'-moz-osx-font-smoothing': 'grayscale',
|
|
|
|
'> *': {
|
|
lineHeight: 1,
|
|
},
|
|
|
|
svg: {
|
|
display: 'inline-block',
|
|
},
|
|
});
|
|
|
|
export const clearFix = (): CSSObject => ({
|
|
// https://github.com/ant-design/ant-design/issues/21301#issuecomment-583955229
|
|
'&::before': {
|
|
display: 'table',
|
|
content: '""',
|
|
},
|
|
|
|
'&::after': {
|
|
// https://github.com/ant-design/ant-design/issues/21864
|
|
display: 'table',
|
|
clear: 'both',
|
|
content: '""',
|
|
},
|
|
});
|
|
|
|
export const genLinkStyle = (token: AliasToken): CSSObject => ({
|
|
a: {
|
|
color: token.colorLink,
|
|
textDecoration: token.linkDecoration,
|
|
backgroundColor: 'transparent', // remove the gray background on active links in IE 10.
|
|
outline: 'none',
|
|
cursor: 'pointer',
|
|
transition: `color ${token.motionDurationSlow}`,
|
|
'-webkit-text-decoration-skip': 'objects', // remove gaps in links underline in iOS 8+ and Safari 8+.
|
|
|
|
'&:hover': {
|
|
color: token.colorLinkHover,
|
|
},
|
|
|
|
'&:active': {
|
|
color: token.colorLinkActive,
|
|
},
|
|
|
|
'&:active, &:hover': {
|
|
textDecoration: token.linkHoverDecoration,
|
|
outline: 0,
|
|
},
|
|
|
|
// https://github.com/ant-design/ant-design/issues/22503
|
|
'&:focus': {
|
|
textDecoration: token.linkFocusDecoration,
|
|
outline: 0,
|
|
},
|
|
|
|
'&[disabled]': {
|
|
color: token.colorTextDisabled,
|
|
cursor: 'not-allowed',
|
|
},
|
|
},
|
|
});
|
|
|
|
export const genCommonStyle = (
|
|
token: AliasToken,
|
|
componentPrefixCls: string,
|
|
rootCls?: string,
|
|
resetFont?: boolean,
|
|
): CSSObject => {
|
|
const prefixSelector = `[class^="${componentPrefixCls}"], [class*=" ${componentPrefixCls}"]`;
|
|
const rootPrefixSelector = rootCls ? `.${rootCls}` : prefixSelector;
|
|
|
|
const resetStyle: CSSObject = {
|
|
boxSizing: 'border-box',
|
|
|
|
'&::before, &::after': {
|
|
boxSizing: 'border-box',
|
|
},
|
|
};
|
|
|
|
let resetFontStyle: CSSObject = {};
|
|
|
|
if (resetFont !== false) {
|
|
resetFontStyle = {
|
|
fontFamily: token.fontFamily,
|
|
fontSize: token.fontSize,
|
|
};
|
|
}
|
|
|
|
return {
|
|
[rootPrefixSelector]: {
|
|
...resetFontStyle,
|
|
...resetStyle,
|
|
|
|
[prefixSelector]: resetStyle,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const genFocusOutline = (token: AliasToken): CSSObject => ({
|
|
outline: `${unit(token.lineWidthFocus)} solid ${token.colorPrimaryBorder}`,
|
|
outlineOffset: 1,
|
|
transition: 'outline-offset 0s, outline 0s',
|
|
});
|
|
|
|
export const genFocusStyle = (token: AliasToken): CSSObject => ({
|
|
'&:focus-visible': {
|
|
...genFocusOutline(token),
|
|
},
|
|
});
|