File size: 3,636 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
import { unit } from '@ant-design/cssinjs';
import type { CSSObject } from '@ant-design/cssinjs';
import { DEPRECATED_TOKENS, prepareComponentToken } from '.';
import type { LayoutToken } from '.';
import type { GenerateStyle } from '../../theme/interface';
import { genStyleHooks } from '../../theme/internal';
const genSiderStyle: GenerateStyle<LayoutToken, CSSObject> = (token) => {
const {
componentCls,
siderBg,
motionDurationMid,
motionDurationSlow,
antCls,
triggerHeight,
triggerColor,
triggerBg,
headerHeight,
zeroTriggerWidth,
zeroTriggerHeight,
borderRadiusLG,
lightSiderBg,
lightTriggerColor,
lightTriggerBg,
bodyBg,
} = token;
return {
[componentCls]: {
position: 'relative',
// fix firefox can't set width smaller than content on flex item
minWidth: 0,
background: siderBg,
transition: `all ${motionDurationMid}, background 0s`,
'&-has-trigger': {
paddingBottom: triggerHeight,
},
'&-right': {
order: 1,
},
[`${componentCls}-children`]: {
height: '100%',
// Hack for fixing margin collapse bug
// https://github.com/ant-design/ant-design/issues/7967
// solution from https://stackoverflow.com/a/33132624/3040605
marginTop: -0.1,
paddingTop: 0.1,
[`${antCls}-menu${antCls}-menu-inline-collapsed`]: {
width: 'auto',
},
},
[`&-zero-width ${componentCls}-children`]: {
overflow: 'hidden',
},
[`${componentCls}-trigger`]: {
position: 'fixed',
bottom: 0,
zIndex: 1,
height: triggerHeight,
color: triggerColor,
lineHeight: unit(triggerHeight),
textAlign: 'center',
background: triggerBg,
cursor: 'pointer',
transition: `all ${motionDurationMid}`,
},
[`${componentCls}-zero-width-trigger`]: {
position: 'absolute',
top: headerHeight,
insetInlineEnd: token.calc(zeroTriggerWidth).mul(-1).equal(),
zIndex: 1,
width: zeroTriggerWidth,
height: zeroTriggerHeight,
color: triggerColor,
fontSize: token.fontSizeXL,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
background: siderBg,
borderRadius: `0 ${unit(borderRadiusLG)} ${unit(borderRadiusLG)} 0`,
cursor: 'pointer',
transition: `background ${motionDurationSlow} ease`,
'&::after': {
position: 'absolute',
inset: 0,
background: 'transparent',
transition: `all ${motionDurationSlow}`,
content: '""',
},
'&:hover::after': {
background: `rgba(255, 255, 255, 0.2)`,
},
'&-right': {
insetInlineStart: token.calc(zeroTriggerWidth).mul(-1).equal(),
borderRadius: `${unit(borderRadiusLG)} 0 0 ${unit(borderRadiusLG)}`,
},
},
// Light
'&-light': {
background: lightSiderBg,
[`${componentCls}-trigger`]: {
color: lightTriggerColor,
background: lightTriggerBg,
},
[`${componentCls}-zero-width-trigger`]: {
color: lightTriggerColor,
background: lightTriggerBg,
border: `1px solid ${bodyBg}`, // Safe to modify to any other color
borderInlineStart: 0,
},
},
},
};
};
export default genStyleHooks(
['Layout', 'Sider'],
(token) => [genSiderStyle(token)],
prepareComponentToken,
{
deprecatedTokens: DEPRECATED_TOKENS,
},
);
|