2022-03-24 23:33:51 +08:00
|
|
|
// deps-lint-skip-all
|
2022-05-09 22:20:07 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
|
|
|
import { Keyframes } from '@ant-design/cssinjs';
|
|
|
|
import type { FullToken, GenerateStyle } from '../../_util/theme';
|
|
|
|
import { genComponentStyleHook, mergeToken } from '../../_util/theme';
|
2022-03-24 23:33:51 +08:00
|
|
|
|
2022-04-08 15:43:28 +08:00
|
|
|
export interface DrawerToken extends FullToken<'Drawer'> {
|
2022-05-17 20:22:26 +08:00
|
|
|
drawerFooterPaddingVertical: number;
|
|
|
|
drawerFooterPaddingHorizontal: number;
|
2022-03-24 23:33:51 +08:00
|
|
|
}
|
|
|
|
|
2022-04-20 10:24:24 +08:00
|
|
|
const antdDrawerFadeIn = new Keyframes('antDrawerFadeIn', {
|
2022-03-24 23:33:51 +08:00
|
|
|
'0%': { opacity: 0 },
|
|
|
|
'100%': { opacity: 1 },
|
|
|
|
});
|
|
|
|
|
|
|
|
// =============================== Base ===============================
|
2022-04-21 02:06:22 +08:00
|
|
|
const genBaseStyle: GenerateStyle<DrawerToken> = (token: DrawerToken): CSSObject => {
|
2022-03-24 23:33:51 +08:00
|
|
|
const {
|
2022-04-08 15:43:28 +08:00
|
|
|
componentCls,
|
2022-03-24 23:33:51 +08:00
|
|
|
motionEaseOut,
|
|
|
|
motionDurationSlow,
|
|
|
|
fontSizeLG,
|
|
|
|
paddingLG,
|
|
|
|
lineWidth,
|
|
|
|
radiusBase,
|
|
|
|
fontSize,
|
|
|
|
lineHeight,
|
2022-05-17 20:22:26 +08:00
|
|
|
drawerFooterPaddingVertical,
|
|
|
|
drawerFooterPaddingHorizontal,
|
2022-05-10 17:30:01 +08:00
|
|
|
zIndexPopupBase,
|
2022-03-24 23:33:51 +08:00
|
|
|
colorText,
|
2022-05-17 20:22:26 +08:00
|
|
|
padding,
|
|
|
|
lineType,
|
|
|
|
colorSplit,
|
2022-03-24 23:33:51 +08:00
|
|
|
} = token;
|
|
|
|
|
|
|
|
return {
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
position: 'fixed',
|
2022-05-10 17:30:01 +08:00
|
|
|
zIndex: zIndexPopupBase,
|
2022-03-24 23:33:51 +08:00
|
|
|
width: 0,
|
|
|
|
height: '100%',
|
|
|
|
transition: `width 0s ease ${motionDurationSlow}, height 0s ease ${motionDurationSlow}`,
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-content-wrapper`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
position: 'absolute',
|
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
|
|
|
transition: `transform ${motionDurationSlow} ${motionEaseOut},box-shadow ${motionDurationSlow} ${motionEaseOut}`,
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-content`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
|
|
|
position: 'relative',
|
|
|
|
zIndex: 1,
|
|
|
|
overflow: 'auto',
|
2022-06-17 18:47:47 +08:00
|
|
|
backgroundColor: token.colorBgElevated,
|
2022-03-24 23:33:51 +08:00
|
|
|
backgroundClip: `padding-box`,
|
|
|
|
border: 0,
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-wrapper-body`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
display: 'flex',
|
|
|
|
flexFlow: 'column nowrap',
|
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-header`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
position: 'relative',
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'space-between',
|
2022-05-17 20:22:26 +08:00
|
|
|
padding: `${padding}px ${paddingLG}px`,
|
2022-03-24 23:33:51 +08:00
|
|
|
color: colorText,
|
2022-06-17 18:47:47 +08:00
|
|
|
background: token.colorBgElevated,
|
2022-05-17 20:22:26 +08:00
|
|
|
borderBottom: `${lineWidth}px ${lineType} ${colorSplit}`,
|
|
|
|
borderRadius: `${radiusBase}px ${radiusBase}px 0 0`,
|
2022-03-24 23:33:51 +08:00
|
|
|
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-header-title`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
display: 'flex',
|
|
|
|
flex: 1,
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'space-between',
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-title`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
flex: 1,
|
|
|
|
margin: 0,
|
|
|
|
color: colorText,
|
2022-05-17 20:22:26 +08:00
|
|
|
fontWeight: token.fontWeightStrong,
|
2022-03-24 23:33:51 +08:00
|
|
|
fontSize: fontSizeLG,
|
2022-05-17 20:22:26 +08:00
|
|
|
lineHeight: token.lineHeightLG,
|
2022-03-24 23:33:51 +08:00
|
|
|
},
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-close`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
display: 'inline-block',
|
2022-05-17 20:22:26 +08:00
|
|
|
marginInlineEnd: token.marginSM,
|
|
|
|
color: token.colorAction,
|
|
|
|
fontWeight: token.fontWeightStrong,
|
2022-03-24 23:33:51 +08:00
|
|
|
fontSize: fontSizeLG,
|
|
|
|
fontStyle: 'normal',
|
|
|
|
lineHeight: 1,
|
|
|
|
textAlign: 'center',
|
|
|
|
textTransform: 'none',
|
|
|
|
textDecoration: 'none',
|
|
|
|
background: 'transparent',
|
|
|
|
border: 0,
|
|
|
|
outline: 0,
|
|
|
|
cursor: 'pointer',
|
|
|
|
transition: `color ${motionDurationSlow}`,
|
|
|
|
textRendering: 'auto',
|
|
|
|
|
2022-05-17 20:22:26 +08:00
|
|
|
[`&:focus, &:hover`]: {
|
|
|
|
color: token.colorActionHover,
|
2022-03-24 23:33:51 +08:00
|
|
|
textDecoration: 'none',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-header-close-only`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
paddingBottom: 0,
|
|
|
|
border: 'none',
|
|
|
|
},
|
|
|
|
},
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-body`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
flexGrow: 1,
|
|
|
|
padding: paddingLG,
|
|
|
|
overflow: 'auto',
|
|
|
|
fontSize,
|
|
|
|
lineHeight,
|
|
|
|
wordWrap: 'break-word',
|
|
|
|
},
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-footer`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
flexShrink: 0,
|
2022-05-17 20:22:26 +08:00
|
|
|
padding: `${drawerFooterPaddingVertical}px ${drawerFooterPaddingHorizontal}px`,
|
|
|
|
borderTop: `${lineWidth}px ${lineType} ${colorSplit}`,
|
2022-03-24 23:33:51 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-mask`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
position: 'absolute',
|
|
|
|
insetBlockStart: 0,
|
|
|
|
insetInlineStart: 0,
|
|
|
|
width: '100%',
|
|
|
|
height: 0,
|
2022-06-17 18:47:47 +08:00
|
|
|
backgroundColor: token.controlMaskBg,
|
2022-03-24 23:33:51 +08:00
|
|
|
opacity: 0,
|
|
|
|
transition: `opacity ${motionDurationSlow} linear, height 0s ease ${motionDurationSlow}`,
|
|
|
|
pointerEvents: 'none',
|
|
|
|
},
|
|
|
|
},
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}${componentCls}-open ${componentCls}-mask`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
height: '100%',
|
|
|
|
opacity: 1,
|
|
|
|
transition: 'none',
|
2022-04-21 02:06:22 +08:00
|
|
|
animationName: antdDrawerFadeIn,
|
|
|
|
animationDuration: token.motionDurationSlow,
|
|
|
|
animationTimingFunction: motionEaseOut,
|
2022-03-24 23:33:51 +08:00
|
|
|
pointerEvents: 'auto',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genDrawerStyle: GenerateStyle<DrawerToken> = (token: DrawerToken) => {
|
2022-06-24 10:45:29 +08:00
|
|
|
const { componentCls, motionDurationSlow, lineWidth, motionEaseOut } = token;
|
2022-03-24 23:33:51 +08:00
|
|
|
|
|
|
|
return {
|
|
|
|
// =================== left,right ===================
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-left`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
insetInlineStart: 0,
|
|
|
|
insetBlockStart: 0,
|
|
|
|
width: 0,
|
|
|
|
height: '100%',
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-content-wrapper`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
height: '100%',
|
|
|
|
insetInlineStart: 0,
|
|
|
|
},
|
|
|
|
},
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-left${componentCls}-open`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
width: '100%',
|
|
|
|
transition: `transform ${motionDurationSlow} ${motionEaseOut}`,
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-content-wrapper`]: {
|
2022-06-24 10:45:29 +08:00
|
|
|
boxShadow: token.boxShadowDrawerRight,
|
2022-03-24 23:33:51 +08:00
|
|
|
},
|
|
|
|
},
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-right`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
insetInlineEnd: 0,
|
|
|
|
insetBlockStart: 0,
|
|
|
|
width: 0,
|
|
|
|
height: '100%',
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-content-wrapper`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
height: '100%',
|
|
|
|
insetInlineEnd: 0,
|
|
|
|
},
|
|
|
|
},
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-right${componentCls}-open`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
width: '100%',
|
|
|
|
transition: `transform ${motionDurationSlow} ${motionEaseOut}`,
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-content-wrapper`]: {
|
2022-06-24 10:45:29 +08:00
|
|
|
boxShadow: token.boxShadowDrawerLeft,
|
2022-03-24 23:33:51 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
// https://github.com/ant-design/ant-design/issues/18607, Avoid edge alignment bug.
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-right${componentCls}-open.no-mask`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
insetInlineEnd: lineWidth,
|
|
|
|
transform: `translateX(${lineWidth})`,
|
|
|
|
},
|
|
|
|
|
|
|
|
// =================== top,bottom ===================
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-top,${componentCls}-bottom`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
insetInlineStart: 0,
|
|
|
|
width: '100%',
|
|
|
|
height: 0,
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-content-wrapper`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
width: '100%',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-top${componentCls}-open,${componentCls}-bottom${componentCls}-open`]: {
|
|
|
|
height: '100%',
|
|
|
|
transition: `transform ${motionDurationSlow} ${motionEaseOut}`,
|
|
|
|
},
|
2022-03-24 23:33:51 +08:00
|
|
|
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-top`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
insetBlockStart: 0,
|
|
|
|
},
|
|
|
|
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-top${componentCls}-open`]: {
|
|
|
|
[`${componentCls}-content-wrapper`]: {
|
2022-06-24 10:45:29 +08:00
|
|
|
boxShadow: token.boxShadowDrawerDown,
|
2022-03-24 23:33:51 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-bottom`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
bottom: 0,
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-content-wrapper`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
bottom: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-bottom${componentCls}-bottom-open`]: {
|
|
|
|
[`${componentCls}-content-wrapper`]: {
|
2022-06-24 10:45:29 +08:00
|
|
|
boxShadow: token.boxShadowDrawerUp,
|
2022-03-24 23:33:51 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 15:43:28 +08:00
|
|
|
[`${componentCls}-bottom${componentCls}-bottom-open.no-mask`]: {
|
2022-03-24 23:33:51 +08:00
|
|
|
insetBlockEnd: lineWidth,
|
|
|
|
transform: `translateY(${lineWidth})`,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2022-04-21 02:06:22 +08:00
|
|
|
export default genComponentStyleHook('Drawer', token => {
|
2022-04-11 16:04:00 +08:00
|
|
|
const drawerToken = mergeToken<DrawerToken>(token, {
|
2022-05-17 20:22:26 +08:00
|
|
|
drawerFooterPaddingVertical: token.paddingXS,
|
|
|
|
drawerFooterPaddingHorizontal: token.padding,
|
2022-04-11 16:04:00 +08:00
|
|
|
});
|
2022-03-24 23:33:51 +08:00
|
|
|
|
2022-04-26 01:00:39 +08:00
|
|
|
return [genBaseStyle(drawerToken), genDrawerStyle(drawerToken)];
|
2022-04-08 15:43:28 +08:00
|
|
|
});
|