| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- import _extends from "@babel/runtime/helpers/esm/extends";
- import { genComponentStyleHook, mergeToken } from '../../theme/internal';
- import genLayoutLightStyle from './light';
- const genLayoutStyle = token => {
- const {
- antCls,
- // .ant
- componentCls,
- // .ant-layout
- colorText,
- colorTextLightSolid,
- colorBgHeader,
- colorBgBody,
- colorBgTrigger,
- layoutHeaderHeight,
- layoutHeaderPaddingInline,
- layoutHeaderColor,
- layoutFooterPadding,
- layoutTriggerHeight,
- layoutZeroTriggerSize,
- motionDurationMid,
- motionDurationSlow,
- fontSize,
- borderRadius
- } = token;
- return {
- [componentCls]: _extends(_extends({
- display: 'flex',
- flex: 'auto',
- flexDirection: 'column',
- color: colorText,
- /* fix firefox can't set height smaller than content on flex item */
- minHeight: 0,
- background: colorBgBody,
- '&, *': {
- boxSizing: 'border-box'
- },
- [`&${componentCls}-has-sider`]: {
- flexDirection: 'row',
- [`> ${componentCls}, > ${componentCls}-content`]: {
- // https://segmentfault.com/a/1190000019498300
- width: 0
- }
- },
- [`${componentCls}-header, &${componentCls}-footer`]: {
- flex: '0 0 auto'
- },
- [`${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'
- }
- },
- [`${componentCls}-footer`]: {
- padding: layoutFooterPadding,
- color: colorText,
- fontSize,
- background: colorBgBody
- },
- [`${componentCls}-content`]: {
- flex: 'auto',
- // fix firefox can't set height smaller than content on flex item
- minHeight: 0
- },
- [`${componentCls}-sider`]: {
- position: 'relative',
- // fix firefox can't set width smaller than content on flex item
- minWidth: 0,
- background: colorBgHeader,
- transition: `all ${motionDurationMid}, background 0s`,
- '&-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'
- }
- },
- '&-has-trigger': {
- paddingBottom: layoutTriggerHeight
- },
- '&-right': {
- order: 1
- },
- '&-trigger': {
- position: 'fixed',
- bottom: 0,
- zIndex: 1,
- height: layoutTriggerHeight,
- color: colorTextLightSolid,
- lineHeight: `${layoutTriggerHeight}px`,
- textAlign: 'center',
- background: colorBgTrigger,
- cursor: 'pointer',
- transition: `all ${motionDurationMid}`
- },
- '&-zero-width': {
- '> *': {
- overflow: 'hidden'
- },
- '&-trigger': {
- position: 'absolute',
- top: layoutHeaderHeight,
- insetInlineEnd: -layoutZeroTriggerSize,
- zIndex: 1,
- width: layoutZeroTriggerSize,
- height: layoutZeroTriggerSize,
- color: colorTextLightSolid,
- fontSize: token.fontSizeXL,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- background: colorBgHeader,
- 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': {
- // FIXME: Hardcode, but seems no need to create a token for this
- background: `rgba(255, 255, 255, 0.2)`
- },
- '&-right': {
- insetInlineStart: -layoutZeroTriggerSize,
- borderStartStartRadius: borderRadius,
- borderStartEndRadius: 0,
- borderEndEndRadius: 0,
- borderEndStartRadius: borderRadius
- }
- }
- }
- }
- }, genLayoutLightStyle(token)), {
- // RTL
- '&-rtl': {
- direction: 'rtl'
- }
- })
- };
- };
- // ============================== Export ==============================
- export default genComponentStyleHook('Layout', token => {
- const {
- colorText,
- controlHeightSM,
- controlHeight,
- controlHeightLG,
- marginXXS
- } = token;
- const layoutHeaderPaddingInline = controlHeightLG * 1.25;
- const layoutToken = mergeToken(token, {
- // Layout
- layoutHeaderHeight: controlHeight * 2,
- layoutHeaderPaddingInline,
- layoutHeaderColor: colorText,
- layoutFooterPadding: `${controlHeightSM}px ${layoutHeaderPaddingInline}px`,
- layoutTriggerHeight: controlHeightLG + marginXXS * 2,
- layoutZeroTriggerSize: controlHeightLG
- });
- return [genLayoutStyle(layoutToken)];
- }, token => {
- const {
- colorBgLayout
- } = token;
- return {
- colorBgHeader: '#001529',
- colorBgBody: colorBgLayout,
- colorBgTrigger: '#002140'
- };
- });
|