feat: preserve breakpoint tokens value (#45981)

This commit is contained in:
MadCcc 2023-11-21 15:26:41 +08:00 committed by GitHub
parent 1f61c28bb1
commit 682904a9ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 8 deletions

View File

@ -106,7 +106,7 @@ const genBorderedStyle = (token: ListToken): CSSObject => {
const genResponsiveStyle = (token: ListToken): CSSObject => { const genResponsiveStyle = (token: ListToken): CSSObject => {
const { componentCls, screenSM, screenMD, marginLG, marginSM, margin } = token; const { componentCls, screenSM, screenMD, marginLG, marginSM, margin } = token;
return { return {
[`@media screen and (max-width:${screenMD})`]: { [`@media screen and (max-width:${screenMD}px)`]: {
[`${componentCls}`]: { [`${componentCls}`]: {
[`${componentCls}-item`]: { [`${componentCls}-item`]: {
[`${componentCls}-item-action`]: { [`${componentCls}-item-action`]: {
@ -124,7 +124,7 @@ const genResponsiveStyle = (token: ListToken): CSSObject => {
}, },
}, },
[`@media screen and (max-width: ${screenSM})`]: { [`@media screen and (max-width: ${screenSM}px)`]: {
[`${componentCls}`]: { [`${componentCls}`]: {
[`${componentCls}-item`]: { [`${componentCls}-item`]: {
flexWrap: 'wrap', flexWrap: 'wrap',
@ -299,10 +299,7 @@ const genBaseStyle: GenerateStyle<ListToken> = (token) => {
insetBlockStart: '50%', insetBlockStart: '50%',
insetInlineEnd: 0, insetInlineEnd: 0,
width: lineWidth, width: lineWidth,
height: token height: token.calc(token.fontHeight).sub(token.calc(token.marginXXS).mul(2)).equal(),
.calc(token.fontHeight)
.sub(token.calc(token.marginXXS).mul(2))
.equal(),
transform: 'translateY(-50%)', transform: 'translateY(-50%)',
backgroundColor: token.colorSplit, backgroundColor: token.colorSplit,
}, },

View File

@ -174,7 +174,7 @@ const genModalStyle: GenerateStyle<ModalToken> = (token) => {
}, },
}, },
[`@media (max-width: ${token.screenSMMax})`]: { [`@media (max-width: ${token.screenSMMax}px)`]: {
[componentCls]: { [componentCls]: {
maxWidth: 'calc(100vw - 16px)', maxWidth: 'calc(100vw - 16px)',
margin: `${unit(token.marginXS)} auto`, margin: `${unit(token.marginXS)} auto`,

View File

@ -44,6 +44,28 @@ export const ignore: {
motionUnit: true, motionUnit: true,
}; };
const preserve: {
[key in keyof AliasToken]?: boolean;
} = {
screenXS: true,
screenXSMin: true,
screenXSMax: true,
screenSM: true,
screenSMMin: true,
screenSMMax: true,
screenMD: true,
screenMDMin: true,
screenMDMax: true,
screenLG: true,
screenLGMin: true,
screenLGMax: true,
screenXL: true,
screenXLMin: true,
screenXLMax: true,
screenXXL: true,
screenXXLMin: true,
};
export const getComputedToken = ( export const getComputedToken = (
originToken: SeedToken, originToken: SeedToken,
overrideToken: DesignTokenProviderProps['components'] & { overrideToken: DesignTokenProviderProps['components'] & {
@ -122,6 +144,7 @@ export default function useToken(): [
key: cssVar.key, key: cssVar.key,
unitless, unitless,
ignore, ignore,
preserve,
}, },
}, },
); );

View File

@ -113,7 +113,7 @@
], ],
"dependencies": { "dependencies": {
"@ant-design/colors": "^7.0.0", "@ant-design/colors": "^7.0.0",
"@ant-design/cssinjs": "^1.18.0-alpha.1", "@ant-design/cssinjs": "^1.18.0-alpha.2",
"@ant-design/icons": "^5.2.6", "@ant-design/icons": "^5.2.6",
"@ant-design/react-slick": "~1.0.2", "@ant-design/react-slick": "~1.0.2",
"@babel/runtime": "^7.18.3", "@babel/runtime": "^7.18.3",