You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
231 lines
5.5 KiB
231 lines
5.5 KiB
2 years ago
|
import type { FullToken, GenerateStyle } from '../../theme/internal';
|
||
|
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
|
||
2 years ago
|
import genMotionStyle from './motion';
|
||
|
|
||
|
export interface ComponentToken {
|
||
|
zIndexPopup: number;
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
export interface DrawerToken extends FullToken<'Drawer'> {
|
||
3 years ago
|
drawerFooterPaddingVertical: number;
|
||
|
drawerFooterPaddingHorizontal: number;
|
||
3 years ago
|
}
|
||
|
|
||
|
// =============================== Base ===============================
|
||
2 years ago
|
const genDrawerStyle: GenerateStyle<DrawerToken> = (token: DrawerToken) => {
|
||
3 years ago
|
const {
|
||
3 years ago
|
componentCls,
|
||
2 years ago
|
zIndexPopup,
|
||
|
colorBgMask,
|
||
|
colorBgElevated,
|
||
3 years ago
|
motionDurationSlow,
|
||
2 years ago
|
motionDurationMid,
|
||
2 years ago
|
padding,
|
||
3 years ago
|
paddingLG,
|
||
2 years ago
|
fontSizeLG,
|
||
|
lineHeightLG,
|
||
3 years ago
|
lineWidth,
|
||
3 years ago
|
lineType,
|
||
|
colorSplit,
|
||
2 years ago
|
marginSM,
|
||
|
colorIcon,
|
||
|
colorIconHover,
|
||
|
colorText,
|
||
|
fontWeightStrong,
|
||
|
drawerFooterPaddingVertical,
|
||
|
drawerFooterPaddingHorizontal,
|
||
3 years ago
|
} = token;
|
||
|
|
||
2 years ago
|
const wrapperCls = `${componentCls}-content-wrapper`;
|
||
|
|
||
3 years ago
|
return {
|
||
2 years ago
|
[componentCls]: {
|
||
3 years ago
|
position: 'fixed',
|
||
2 years ago
|
inset: 0,
|
||
|
zIndex: zIndexPopup,
|
||
|
pointerEvents: 'none',
|
||
|
|
||
2 years ago
|
'&-pure': {
|
||
|
position: 'relative',
|
||
2 years ago
|
background: colorBgElevated,
|
||
|
|
||
|
[`&${componentCls}-left`]: {
|
||
|
boxShadow: token.boxShadowDrawerLeft,
|
||
|
},
|
||
|
[`&${componentCls}-right`]: {
|
||
|
boxShadow: token.boxShadowDrawerRight,
|
||
|
},
|
||
|
[`&${componentCls}-top`]: {
|
||
|
boxShadow: token.boxShadowDrawerUp,
|
||
|
},
|
||
|
[`&${componentCls}-bottom`]: {
|
||
|
boxShadow: token.boxShadowDrawerDown,
|
||
|
},
|
||
2 years ago
|
},
|
||
|
|
||
2 years ago
|
'&-inline': {
|
||
3 years ago
|
position: 'absolute',
|
||
|
},
|
||
2 years ago
|
|
||
|
// ====================== Mask ======================
|
||
3 years ago
|
[`${componentCls}-mask`]: {
|
||
3 years ago
|
position: 'absolute',
|
||
2 years ago
|
inset: 0,
|
||
|
zIndex: zIndexPopup,
|
||
|
background: colorBgMask,
|
||
|
pointerEvents: 'auto',
|
||
3 years ago
|
},
|
||
|
|
||
2 years ago
|
// ==================== Content =====================
|
||
|
[wrapperCls]: {
|
||
|
position: 'absolute',
|
||
|
zIndex: zIndexPopup,
|
||
|
transition: `all ${motionDurationSlow}`,
|
||
3 years ago
|
|
||
2 years ago
|
'&-hidden': {
|
||
|
display: 'none',
|
||
|
},
|
||
3 years ago
|
},
|
||
2 years ago
|
|
||
|
// Placement
|
||
2 years ago
|
[`&-left > ${wrapperCls}`]: {
|
||
2 years ago
|
top: 0,
|
||
|
bottom: 0,
|
||
|
left: {
|
||
|
_skip_check_: true,
|
||
|
value: 0,
|
||
|
},
|
||
2 years ago
|
boxShadow: token.boxShadowDrawerLeft,
|
||
3 years ago
|
},
|
||
2 years ago
|
[`&-right > ${wrapperCls}`]: {
|
||
2 years ago
|
top: 0,
|
||
|
right: {
|
||
|
_skip_check_: true,
|
||
|
value: 0,
|
||
|
},
|
||
|
bottom: 0,
|
||
2 years ago
|
boxShadow: token.boxShadowDrawerRight,
|
||
3 years ago
|
},
|
||
2 years ago
|
[`&-top > ${wrapperCls}`]: {
|
||
2 years ago
|
top: 0,
|
||
|
insetInline: 0,
|
||
2 years ago
|
boxShadow: token.boxShadowDrawerUp,
|
||
2 years ago
|
},
|
||
2 years ago
|
[`&-bottom > ${wrapperCls}`]: {
|
||
2 years ago
|
bottom: 0,
|
||
|
insetInline: 0,
|
||
2 years ago
|
boxShadow: token.boxShadowDrawerDown,
|
||
2 years ago
|
},
|
||
3 years ago
|
|
||
2 years ago
|
[`${componentCls}-content`]: {
|
||
3 years ago
|
width: '100%',
|
||
2 years ago
|
height: '100%',
|
||
|
overflow: 'auto',
|
||
|
background: colorBgElevated,
|
||
|
pointerEvents: 'auto',
|
||
3 years ago
|
},
|
||
|
|
||
2 years ago
|
// ===================== Panel ======================
|
||
|
[`${componentCls}-wrapper-body`]: {
|
||
|
display: 'flex',
|
||
|
flexDirection: 'column',
|
||
|
width: '100%',
|
||
|
height: '100%',
|
||
|
},
|
||
3 years ago
|
|
||
2 years ago
|
// Header
|
||
|
[`${componentCls}-header`]: {
|
||
|
display: 'flex',
|
||
|
flex: 0,
|
||
|
alignItems: 'center',
|
||
|
padding: `${padding}px ${paddingLG}px`,
|
||
|
fontSize: fontSizeLG,
|
||
|
lineHeight: lineHeightLG,
|
||
|
borderBottom: `${lineWidth}px ${lineType} ${colorSplit}`,
|
||
|
|
||
|
'&-title': {
|
||
|
display: 'flex',
|
||
|
flex: 1,
|
||
|
alignItems: 'center',
|
||
|
minWidth: 0,
|
||
|
minHeight: 0,
|
||
|
},
|
||
|
},
|
||
3 years ago
|
|
||
2 years ago
|
[`${componentCls}-extra`]: {
|
||
2 years ago
|
flex: 'none',
|
||
3 years ago
|
},
|
||
|
|
||
2 years ago
|
[`${componentCls}-close`]: {
|
||
|
display: 'inline-block',
|
||
|
marginInlineEnd: marginSM,
|
||
|
color: colorIcon,
|
||
|
fontWeight: fontWeightStrong,
|
||
|
fontSize: fontSizeLG,
|
||
|
fontStyle: 'normal',
|
||
|
lineHeight: 1,
|
||
|
textAlign: 'center',
|
||
|
textTransform: 'none',
|
||
|
textDecoration: 'none',
|
||
|
background: 'transparent',
|
||
|
border: 0,
|
||
|
outline: 0,
|
||
|
cursor: 'pointer',
|
||
2 years ago
|
transition: `color ${motionDurationMid}`,
|
||
2 years ago
|
textRendering: 'auto',
|
||
|
|
||
|
'&:focus, &:hover': {
|
||
|
color: colorIconHover,
|
||
|
textDecoration: 'none',
|
||
|
},
|
||
3 years ago
|
},
|
||
|
|
||
2 years ago
|
[`${componentCls}-title`]: {
|
||
|
flex: 1,
|
||
|
margin: 0,
|
||
|
color: colorText,
|
||
|
fontWeight: token.fontWeightStrong,
|
||
|
fontSize: fontSizeLG,
|
||
|
lineHeight: lineHeightLG,
|
||
|
},
|
||
|
|
||
|
// Body
|
||
|
[`${componentCls}-body`]: {
|
||
|
flex: 1,
|
||
|
minWidth: 0,
|
||
|
minHeight: 0,
|
||
|
padding: paddingLG,
|
||
|
overflow: 'auto',
|
||
|
},
|
||
|
|
||
|
// Footer
|
||
|
[`${componentCls}-footer`]: {
|
||
|
flexShrink: 0,
|
||
|
padding: `${drawerFooterPaddingVertical}px ${drawerFooterPaddingHorizontal}px`,
|
||
|
borderTop: `${lineWidth}px ${lineType} ${colorSplit}`,
|
||
3 years ago
|
},
|
||
|
|
||
2 years ago
|
// ====================== RTL =======================
|
||
|
'&-rtl': {
|
||
|
direction: 'rtl',
|
||
|
},
|
||
3 years ago
|
},
|
||
|
};
|
||
|
};
|
||
|
|
||
|
// ============================== Export ==============================
|
||
2 years ago
|
export default genComponentStyleHook(
|
||
|
'Drawer',
|
||
2 years ago
|
(token) => {
|
||
2 years ago
|
const drawerToken = mergeToken<DrawerToken>(token, {
|
||
|
drawerFooterPaddingVertical: token.paddingXS,
|
||
|
drawerFooterPaddingHorizontal: token.padding,
|
||
|
});
|
||
|
|
||
|
return [genDrawerStyle(drawerToken), genMotionStyle(drawerToken)];
|
||
|
},
|
||
2 years ago
|
(token) => ({
|
||
2 years ago
|
zIndexPopup: token.zIndexPopupBase,
|
||
|
}),
|
||
|
);
|