mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 19:19:57 +08:00
101865cf7e
* fix: statistic token
* fix: all components token
* test: fix lint
* chore: code clean
* Revert "chore: code clean"
This reverts commit 2c0e7d6ba3
.
136 lines
3.0 KiB
TypeScript
136 lines
3.0 KiB
TypeScript
// deps-lint-skip-all
|
|
import { CSSObject } from '@ant-design/cssinjs';
|
|
import {
|
|
resetComponent,
|
|
GenerateStyle,
|
|
FullToken,
|
|
genComponentStyleHook,
|
|
mergeToken,
|
|
} from '../../_util/theme';
|
|
|
|
interface RateToken extends FullToken<'Rate'> {
|
|
rateStarColor: string;
|
|
rateStarSize: number;
|
|
rateStarHoverScale: CSSObject['transform'];
|
|
}
|
|
|
|
const genRateStarStyle: GenerateStyle<RateToken, CSSObject> = token => {
|
|
const { componentCls } = token;
|
|
|
|
return {
|
|
[`${componentCls}-star`]: {
|
|
position: 'relative',
|
|
display: 'inline-block',
|
|
color: 'inherit',
|
|
cursor: 'pointer',
|
|
|
|
'&:not(:last-child)': {
|
|
marginInlineEnd: token.marginXS,
|
|
},
|
|
|
|
'> div': {
|
|
transition: `all ${token.motionDurationSlow}, outline 0s`,
|
|
|
|
'&:hover': {
|
|
transform: token.rateStarHoverScale,
|
|
},
|
|
|
|
'&:focus': {
|
|
outline: 0,
|
|
},
|
|
|
|
'&:focus-visible': {
|
|
outline: `1px dashed ${token.colorSplit}`,
|
|
transform: token.rateStarHoverScale,
|
|
},
|
|
},
|
|
|
|
'&-first, &-second': {
|
|
color: token.colorSplit,
|
|
transition: `all ${token.motionDurationSlow}`,
|
|
userSelect: 'none',
|
|
|
|
[token.iconCls]: {
|
|
verticalAlign: 'middle',
|
|
},
|
|
},
|
|
|
|
'&-first': {
|
|
position: 'absolute',
|
|
top: 0,
|
|
insetInlineStart: 0,
|
|
width: '50%',
|
|
height: '100%',
|
|
overflow: 'hidden',
|
|
opacity: 0,
|
|
},
|
|
|
|
[`&-half ${componentCls}-star-first, &-half ${componentCls}-star-second`]: {
|
|
opacity: 1,
|
|
},
|
|
|
|
[`&-half ${componentCls}-star-first, &-full ${componentCls}-star-second`]: {
|
|
color: 'inherit',
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
const genRateRtlStyle = (token: RateToken): CSSObject => ({
|
|
[`&-rtl${token.componentCls}`]: {
|
|
direction: 'rtl',
|
|
},
|
|
});
|
|
|
|
const genRateStyle: GenerateStyle<RateToken> = token => {
|
|
const { componentCls } = token;
|
|
|
|
return {
|
|
[componentCls]: {
|
|
...resetComponent(token),
|
|
|
|
display: 'inline-block',
|
|
margin: 0,
|
|
padding: 0,
|
|
color: token.rateStarColor,
|
|
fontSize: token.rateStarSize,
|
|
lineHeight: 'unset',
|
|
listStyle: 'none',
|
|
outline: 'none',
|
|
|
|
// disable styles
|
|
[`&-disabled${componentCls} ${componentCls}-star`]: {
|
|
cursor: 'default',
|
|
|
|
'&:hover': {
|
|
transform: 'scale(1)',
|
|
},
|
|
},
|
|
|
|
// star styles
|
|
...genRateStarStyle(token),
|
|
|
|
// text styles
|
|
[`+ ${componentCls}-text`]: {
|
|
display: 'inline-block',
|
|
marginInlineStart: token.marginXS,
|
|
fontSize: token.fontSize,
|
|
},
|
|
|
|
// rtl styles
|
|
...genRateRtlStyle(token),
|
|
},
|
|
};
|
|
};
|
|
|
|
// ============================== Export ==============================
|
|
export default genComponentStyleHook('Rate', token => {
|
|
const rateToken = mergeToken<RateToken>(token, {
|
|
// FIXME: missing token
|
|
rateStarColor: '#fadb14', // @yellow-6
|
|
rateStarSize: 20, // fixed-value
|
|
rateStarHoverScale: 'scale(1.1)', // fixed-value
|
|
});
|
|
return [genRateStyle(rateToken)];
|
|
});
|