ant-design/components/upload/style/index.ts
kiner-tang(文辉) 49ffbe2c82
feat: Upload support cssVar (#45820)
* feat: Upload support cssVar

* feat: optimize code

* Apply suggestions from code review

Signed-off-by: MadCcc <1075746765@qq.com>

* feat: update size limit

* feat: optimize code

* feat: optimize code

---------

Signed-off-by: MadCcc <1075746765@qq.com>
Signed-off-by: MadCcc <madccc@foxmail.com>
Co-authored-by: MadCcc <madccc@foxmail.com>
2023-11-13 19:44:27 +08:00

80 lines
2.2 KiB
TypeScript

import { resetComponent } from '../../style';
import { genCollapseMotion } from '../../style/motion';
import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
import genDraggerStyle from './dragger';
import genListStyle from './list';
import genMotionStyle from './motion';
import { genPictureCardStyle, genPictureStyle } from './picture';
import genRtlStyle from './rtl';
export interface ComponentToken {
/**
* @desc 操作按扭颜色
* @descEN Action button color
*/
actionsColor: string;
}
export interface UploadToken extends FullToken<'Upload'> {
uploadThumbnailSize: number | string;
uploadProgressOffset: number | string;
uploadPicCardSize: number | string;
}
const genBaseStyle: GenerateStyle<UploadToken> = (token) => {
const { componentCls, colorTextDisabled } = token;
return {
[`${componentCls}-wrapper`]: {
...resetComponent(token),
[componentCls]: {
outline: 0,
"input[type='file']": {
cursor: 'pointer',
},
},
[`${componentCls}-select`]: {
display: 'inline-block',
},
[`${componentCls}-disabled`]: {
color: colorTextDisabled,
cursor: 'not-allowed',
},
},
};
};
export const prepareComponentToken: GetDefaultToken<'Upload'> = (token) => ({
actionsColor: token.colorTextDescription,
});
// ============================== Export ==============================
export default genComponentStyleHook(
'Upload',
(token) => {
const { fontSizeHeading3, fontHeight, lineWidth, controlHeightLG, calc } = token;
const uploadToken = mergeToken<UploadToken>(token, {
uploadThumbnailSize: calc(fontSizeHeading3).mul(2).equal(),
uploadProgressOffset: calc(calc(fontHeight).div(2)).add(lineWidth).equal(),
uploadPicCardSize: calc(controlHeightLG).mul(2.55).equal(),
});
return [
genBaseStyle(uploadToken),
genDraggerStyle(uploadToken),
genPictureStyle(uploadToken),
genPictureCardStyle(uploadToken),
genListStyle(uploadToken),
genMotionStyle(uploadToken),
genRtlStyle(uploadToken),
genCollapseMotion(uploadToken),
];
},
prepareComponentToken,
);