2022-04-22 15:00:18 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2022-11-23 20:22:38 +08:00
|
|
|
import type { FullToken, GenerateStyle } from '../../theme/internal';
|
|
|
|
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
|
2022-04-22 15:00:18 +08:00
|
|
|
import genLayoutLightStyle from './light';
|
|
|
|
|
2022-05-19 16:23:12 +08:00
|
|
|
export interface ComponentToken {
|
|
|
|
colorBgHeader: string;
|
|
|
|
colorBgBody: string;
|
|
|
|
colorBgTrigger: string;
|
|
|
|
}
|
|
|
|
|
2022-04-22 15:00:18 +08:00
|
|
|
export interface LayoutToken extends FullToken<'Layout'> {
|
|
|
|
// Layout
|
|
|
|
layoutHeaderHeight: number;
|
2022-05-19 16:23:12 +08:00
|
|
|
layoutHeaderPaddingInline: number;
|
2022-04-22 15:00:18 +08:00
|
|
|
layoutHeaderColor: string;
|
|
|
|
layoutFooterPadding: string;
|
|
|
|
layoutTriggerHeight: number;
|
2022-05-19 16:23:12 +08:00
|
|
|
layoutZeroTriggerSize: number;
|
2022-04-22 15:00:18 +08:00
|
|
|
}
|
|
|
|
|
2022-11-19 13:47:33 +08:00
|
|
|
const genLayoutStyle: GenerateStyle<LayoutToken, CSSObject> = (token) => {
|
2022-04-22 15:00:18 +08:00
|
|
|
const {
|
|
|
|
antCls, // .ant
|
|
|
|
componentCls, // .ant-layout
|
|
|
|
colorText,
|
2022-05-19 16:23:12 +08:00
|
|
|
colorTextLightSolid,
|
|
|
|
colorBgHeader,
|
|
|
|
colorBgBody,
|
|
|
|
colorBgTrigger,
|
2022-04-22 15:00:18 +08:00
|
|
|
layoutHeaderHeight,
|
2022-05-19 16:23:12 +08:00
|
|
|
layoutHeaderPaddingInline,
|
2022-04-22 15:00:18 +08:00
|
|
|
layoutHeaderColor,
|
|
|
|
layoutFooterPadding,
|
|
|
|
layoutTriggerHeight,
|
2022-05-19 16:23:12 +08:00
|
|
|
layoutZeroTriggerSize,
|
2022-04-22 15:00:18 +08:00
|
|
|
motionDurationMid,
|
|
|
|
motionDurationSlow,
|
2022-11-01 15:06:38 +08:00
|
|
|
fontSize,
|
|
|
|
borderRadius,
|
2022-04-22 15:00:18 +08:00
|
|
|
} = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
[componentCls]: {
|
|
|
|
display: 'flex',
|
|
|
|
flex: 'auto',
|
|
|
|
flexDirection: 'column',
|
|
|
|
|
|
|
|
/* fix firefox can't set height smaller than content on flex item */
|
2022-05-19 16:23:12 +08:00
|
|
|
minHeight: 0,
|
|
|
|
background: colorBgBody,
|
2022-04-22 15:00:18 +08:00
|
|
|
|
|
|
|
'&, *': {
|
|
|
|
boxSizing: 'border-box',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${componentCls}-has-sider`]: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
[`> ${componentCls}, > ${componentCls}-content`]: {
|
2022-05-19 16:23:12 +08:00
|
|
|
// https://segmentfault.com/a/1190000019498300
|
|
|
|
width: 0,
|
2022-04-22 15:00:18 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-header, &${componentCls}-footer`]: {
|
2022-05-19 16:23:12 +08:00
|
|
|
flex: '0 0 auto',
|
2022-04-22 15:00:18 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-sider`]: {
|
|
|
|
position: 'relative',
|
|
|
|
|
|
|
|
// fix firefox can't set width smaller than content on flex item
|
2022-05-19 16:23:12 +08:00
|
|
|
minWidth: 0,
|
|
|
|
background: colorBgHeader,
|
2023-04-25 22:53:14 +08:00
|
|
|
transition: `all ${motionDurationMid}, background 0s`,
|
2022-04-22 15:00:18 +08:00
|
|
|
|
|
|
|
'&-children': {
|
2022-05-19 16:23:12 +08:00
|
|
|
height: '100%',
|
|
|
|
// Hack for fixing margin collapse bug
|
2022-04-22 15:00:18 +08:00
|
|
|
// https://github.com/ant-design/ant-design/issues/7967
|
|
|
|
// solution from https://stackoverflow.com/a/33132624/3040605
|
2022-05-19 16:23:12 +08:00
|
|
|
marginTop: -0.1,
|
|
|
|
paddingTop: 0.1,
|
2022-04-22 15:00:18 +08:00
|
|
|
|
2022-11-21 16:40:59 +08:00
|
|
|
[`${antCls}-menu${antCls}-menu-inline-collapsed`]: {
|
2022-04-22 15:00:18 +08:00
|
|
|
width: 'auto',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-has-trigger': {
|
|
|
|
paddingBottom: layoutTriggerHeight,
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-right': {
|
2022-05-19 16:23:12 +08:00
|
|
|
order: 1,
|
2022-04-22 15:00:18 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&-trigger': {
|
|
|
|
position: 'fixed',
|
2022-05-19 16:23:12 +08:00
|
|
|
bottom: 0,
|
|
|
|
zIndex: 1,
|
2022-04-22 15:00:18 +08:00
|
|
|
height: layoutTriggerHeight,
|
2022-05-19 16:23:12 +08:00
|
|
|
color: colorTextLightSolid,
|
2022-04-22 15:00:18 +08:00
|
|
|
lineHeight: `${layoutTriggerHeight}px`,
|
|
|
|
textAlign: 'center',
|
2022-05-19 16:23:12 +08:00
|
|
|
background: colorBgTrigger,
|
2022-04-22 15:00:18 +08:00
|
|
|
cursor: 'pointer',
|
|
|
|
transition: `all ${motionDurationMid}`,
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-zero-width': {
|
|
|
|
'> *': {
|
|
|
|
overflow: 'hidden',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-trigger': {
|
|
|
|
position: 'absolute',
|
|
|
|
top: layoutHeaderHeight,
|
2022-05-19 16:23:12 +08:00
|
|
|
insetInlineEnd: -layoutZeroTriggerSize,
|
|
|
|
zIndex: 1,
|
|
|
|
width: layoutZeroTriggerSize,
|
|
|
|
height: layoutZeroTriggerSize,
|
|
|
|
color: colorTextLightSolid,
|
|
|
|
fontSize: token.fontSizeXL,
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
background: colorBgHeader,
|
|
|
|
borderStartStartRadius: 0,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderStartEndRadius: borderRadius,
|
|
|
|
borderEndEndRadius: borderRadius,
|
2022-05-19 16:23:12 +08:00
|
|
|
borderEndStartRadius: 0,
|
2022-04-22 15:00:18 +08:00
|
|
|
|
|
|
|
cursor: 'pointer',
|
|
|
|
transition: `background ${motionDurationSlow} ease`,
|
|
|
|
|
|
|
|
'&::after': {
|
|
|
|
position: 'absolute',
|
2022-05-19 16:23:12 +08:00
|
|
|
inset: 0,
|
2022-04-22 15:00:18 +08:00
|
|
|
background: 'transparent',
|
|
|
|
transition: `all ${motionDurationSlow}`,
|
|
|
|
content: '""',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:hover::after': {
|
2022-05-19 16:23:12 +08:00
|
|
|
// FIXME: Hardcode, but seems no need to create a token for this
|
|
|
|
background: `rgba(255, 255, 255, 0.2)`,
|
2022-04-22 15:00:18 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&-right': {
|
2022-05-19 16:23:12 +08:00
|
|
|
insetInlineStart: -layoutZeroTriggerSize,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderStartStartRadius: borderRadius,
|
2022-05-19 16:23:12 +08:00
|
|
|
borderStartEndRadius: 0,
|
|
|
|
borderEndEndRadius: 0,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderEndStartRadius: borderRadius,
|
2022-04-22 15:00:18 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Light
|
|
|
|
...genLayoutLightStyle(token),
|
|
|
|
// RTL
|
|
|
|
'&-rtl': {
|
|
|
|
direction: 'rtl',
|
|
|
|
},
|
|
|
|
},
|
2023-02-27 15:35:22 +08:00
|
|
|
|
|
|
|
// ==================== Header ====================
|
|
|
|
[`${componentCls}-header`]: {
|
|
|
|
height: layoutHeaderHeight,
|
|
|
|
paddingInline: layoutHeaderPaddingInline,
|
|
|
|
color: layoutHeaderColor,
|
|
|
|
lineHeight: `${layoutHeaderHeight}px`,
|
|
|
|
background: colorBgHeader,
|
|
|
|
|
|
|
|
// Other components/menu/style/index.less line:686
|
|
|
|
// Integration with header element so menu items have the same height
|
|
|
|
[`${antCls}-menu`]: {
|
|
|
|
lineHeight: 'inherit',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// ==================== Footer ====================
|
|
|
|
[`${componentCls}-footer`]: {
|
|
|
|
padding: layoutFooterPadding,
|
|
|
|
color: colorText,
|
|
|
|
fontSize,
|
|
|
|
background: colorBgBody,
|
|
|
|
},
|
|
|
|
|
|
|
|
// =================== Content ====================
|
|
|
|
[`${componentCls}-content`]: {
|
|
|
|
flex: 'auto',
|
|
|
|
|
|
|
|
// fix firefox can't set height smaller than content on flex item
|
|
|
|
minHeight: 0,
|
|
|
|
},
|
2022-04-22 15:00:18 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2022-05-19 16:23:12 +08:00
|
|
|
export default genComponentStyleHook(
|
|
|
|
'Layout',
|
2022-11-19 13:47:33 +08:00
|
|
|
(token) => {
|
2022-05-19 16:23:12 +08:00
|
|
|
const { colorText, controlHeightSM, controlHeight, controlHeightLG, marginXXS } = token;
|
|
|
|
const layoutHeaderPaddingInline = controlHeightLG * 1.25;
|
|
|
|
|
|
|
|
const layoutToken = mergeToken<LayoutToken>(token, {
|
|
|
|
// Layout
|
|
|
|
layoutHeaderHeight: controlHeight * 2,
|
|
|
|
layoutHeaderPaddingInline,
|
|
|
|
layoutHeaderColor: colorText,
|
|
|
|
layoutFooterPadding: `${controlHeightSM}px ${layoutHeaderPaddingInline}px`,
|
|
|
|
layoutTriggerHeight: controlHeightLG + marginXXS * 2, // = item height + margin
|
|
|
|
layoutZeroTriggerSize: controlHeightLG,
|
|
|
|
});
|
|
|
|
|
|
|
|
return [genLayoutStyle(layoutToken)];
|
|
|
|
},
|
2022-11-19 13:47:33 +08:00
|
|
|
(token) => {
|
2022-10-16 00:10:35 +08:00
|
|
|
const { colorBgLayout } = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
colorBgHeader: '#001529',
|
|
|
|
colorBgBody: colorBgLayout,
|
|
|
|
colorBgTrigger: '#002140',
|
|
|
|
};
|
2022-05-19 16:23:12 +08:00
|
|
|
},
|
|
|
|
);
|