mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-12 04:13:13 +08:00

Some checks failed
Publish Any Commit / build (push) Has been cancelled
🔀 Sync mirror to Gitee / mirror (push) Has been cancelled
✅ test / lint (push) Has been cancelled
✅ test / test-react-legacy (16, 1/2) (push) Has been cancelled
✅ test / test-react-legacy (16, 2/2) (push) Has been cancelled
✅ test / test-react-legacy (17, 1/2) (push) Has been cancelled
✅ test / test-react-legacy (17, 2/2) (push) Has been cancelled
✅ test / test-node (push) Has been cancelled
✅ test / test-react-latest (dom, 1/2) (push) Has been cancelled
✅ test / test-react-latest (dom, 2/2) (push) Has been cancelled
✅ test / build (push) Has been cancelled
✅ test / test lib/es module (es, 1/2) (push) Has been cancelled
✅ test / test lib/es module (es, 2/2) (push) Has been cancelled
✅ test / test lib/es module (lib, 1/2) (push) Has been cancelled
✅ test / test lib/es module (lib, 2/2) (push) Has been cancelled
👁️ Visual Regression Persist Start / test image (push) Has been cancelled
✅ test / test-react-latest-dist (dist, 1/2) (push) Has been cancelled
✅ test / test-react-latest-dist (dist, 2/2) (push) Has been cancelled
✅ test / test-react-latest-dist (dist-min, 1/2) (push) Has been cancelled
✅ test / test-react-latest-dist (dist-min, 2/2) (push) Has been cancelled
✅ test / test-coverage (push) Has been cancelled
* Revert "fix(layout): enhance Sider zero-width-trigger selector specificity (#51936)"
This reverts commit a5dc4069b1
.
* fix: resolve the style not taking effect error
150 lines
3.8 KiB
TypeScript
150 lines
3.8 KiB
TypeScript
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,
|
|
borderRadius,
|
|
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',
|
|
},
|
|
},
|
|
|
|
[`${componentCls}-trigger`]: {
|
|
position: 'fixed',
|
|
bottom: 0,
|
|
zIndex: 1,
|
|
height: triggerHeight,
|
|
color: triggerColor,
|
|
lineHeight: unit(triggerHeight),
|
|
textAlign: 'center',
|
|
background: triggerBg,
|
|
cursor: 'pointer',
|
|
transition: `all ${motionDurationMid}`,
|
|
},
|
|
|
|
'&-zero-width': {
|
|
'> *': {
|
|
overflow: 'hidden',
|
|
},
|
|
|
|
'&-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,
|
|
borderStartStartRadius: 0,
|
|
borderStartEndRadius: borderRadius,
|
|
borderEndEndRadius: borderRadius,
|
|
borderEndStartRadius: 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(),
|
|
borderStartStartRadius: borderRadius,
|
|
borderStartEndRadius: 0,
|
|
borderEndEndRadius: 0,
|
|
borderEndStartRadius: borderRadius,
|
|
},
|
|
},
|
|
},
|
|
|
|
// 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) => ({
|
|
[`${token.antCls}-layout`]: genSiderStyle(token),
|
|
}),
|
|
prepareComponentToken,
|
|
{
|
|
deprecatedTokens: DEPRECATED_TOKENS,
|
|
},
|
|
);
|