index.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = void 0;
  7. var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
  8. var _internal = require("../../theme/internal");
  9. var _light = _interopRequireDefault(require("./light"));
  10. const genLayoutStyle = token => {
  11. const {
  12. antCls,
  13. // .ant
  14. componentCls,
  15. // .ant-layout
  16. colorText,
  17. colorTextLightSolid,
  18. colorBgHeader,
  19. colorBgBody,
  20. colorBgTrigger,
  21. layoutHeaderHeight,
  22. layoutHeaderPaddingInline,
  23. layoutHeaderColor,
  24. layoutFooterPadding,
  25. layoutTriggerHeight,
  26. layoutZeroTriggerSize,
  27. motionDurationMid,
  28. motionDurationSlow,
  29. fontSize,
  30. borderRadius
  31. } = token;
  32. return {
  33. [componentCls]: (0, _extends2.default)((0, _extends2.default)({
  34. display: 'flex',
  35. flex: 'auto',
  36. flexDirection: 'column',
  37. color: colorText,
  38. /* fix firefox can't set height smaller than content on flex item */
  39. minHeight: 0,
  40. background: colorBgBody,
  41. '&, *': {
  42. boxSizing: 'border-box'
  43. },
  44. [`&${componentCls}-has-sider`]: {
  45. flexDirection: 'row',
  46. [`> ${componentCls}, > ${componentCls}-content`]: {
  47. // https://segmentfault.com/a/1190000019498300
  48. width: 0
  49. }
  50. },
  51. [`${componentCls}-header, &${componentCls}-footer`]: {
  52. flex: '0 0 auto'
  53. },
  54. [`${componentCls}-header`]: {
  55. height: layoutHeaderHeight,
  56. paddingInline: layoutHeaderPaddingInline,
  57. color: layoutHeaderColor,
  58. lineHeight: `${layoutHeaderHeight}px`,
  59. background: colorBgHeader,
  60. // Other components/menu/style/index.less line:686
  61. // Integration with header element so menu items have the same height
  62. [`${antCls}-menu`]: {
  63. lineHeight: 'inherit'
  64. }
  65. },
  66. [`${componentCls}-footer`]: {
  67. padding: layoutFooterPadding,
  68. color: colorText,
  69. fontSize,
  70. background: colorBgBody
  71. },
  72. [`${componentCls}-content`]: {
  73. flex: 'auto',
  74. // fix firefox can't set height smaller than content on flex item
  75. minHeight: 0
  76. },
  77. [`${componentCls}-sider`]: {
  78. position: 'relative',
  79. // fix firefox can't set width smaller than content on flex item
  80. minWidth: 0,
  81. background: colorBgHeader,
  82. transition: `all ${motionDurationMid}, background 0s`,
  83. '&-children': {
  84. height: '100%',
  85. // Hack for fixing margin collapse bug
  86. // https://github.com/ant-design/ant-design/issues/7967
  87. // solution from https://stackoverflow.com/a/33132624/3040605
  88. marginTop: -0.1,
  89. paddingTop: 0.1,
  90. [`${antCls}-menu${antCls}-menu-inline-collapsed`]: {
  91. width: 'auto'
  92. }
  93. },
  94. '&-has-trigger': {
  95. paddingBottom: layoutTriggerHeight
  96. },
  97. '&-right': {
  98. order: 1
  99. },
  100. '&-trigger': {
  101. position: 'fixed',
  102. bottom: 0,
  103. zIndex: 1,
  104. height: layoutTriggerHeight,
  105. color: colorTextLightSolid,
  106. lineHeight: `${layoutTriggerHeight}px`,
  107. textAlign: 'center',
  108. background: colorBgTrigger,
  109. cursor: 'pointer',
  110. transition: `all ${motionDurationMid}`
  111. },
  112. '&-zero-width': {
  113. '> *': {
  114. overflow: 'hidden'
  115. },
  116. '&-trigger': {
  117. position: 'absolute',
  118. top: layoutHeaderHeight,
  119. insetInlineEnd: -layoutZeroTriggerSize,
  120. zIndex: 1,
  121. width: layoutZeroTriggerSize,
  122. height: layoutZeroTriggerSize,
  123. color: colorTextLightSolid,
  124. fontSize: token.fontSizeXL,
  125. display: 'flex',
  126. alignItems: 'center',
  127. justifyContent: 'center',
  128. background: colorBgHeader,
  129. borderStartStartRadius: 0,
  130. borderStartEndRadius: borderRadius,
  131. borderEndEndRadius: borderRadius,
  132. borderEndStartRadius: 0,
  133. cursor: 'pointer',
  134. transition: `background ${motionDurationSlow} ease`,
  135. '&::after': {
  136. position: 'absolute',
  137. inset: 0,
  138. background: 'transparent',
  139. transition: `all ${motionDurationSlow}`,
  140. content: '""'
  141. },
  142. '&:hover::after': {
  143. // FIXME: Hardcode, but seems no need to create a token for this
  144. background: `rgba(255, 255, 255, 0.2)`
  145. },
  146. '&-right': {
  147. insetInlineStart: -layoutZeroTriggerSize,
  148. borderStartStartRadius: borderRadius,
  149. borderStartEndRadius: 0,
  150. borderEndEndRadius: 0,
  151. borderEndStartRadius: borderRadius
  152. }
  153. }
  154. }
  155. }
  156. }, (0, _light.default)(token)), {
  157. // RTL
  158. '&-rtl': {
  159. direction: 'rtl'
  160. }
  161. })
  162. };
  163. };
  164. // ============================== Export ==============================
  165. var _default = exports.default = (0, _internal.genComponentStyleHook)('Layout', token => {
  166. const {
  167. colorText,
  168. controlHeightSM,
  169. controlHeight,
  170. controlHeightLG,
  171. marginXXS
  172. } = token;
  173. const layoutHeaderPaddingInline = controlHeightLG * 1.25;
  174. const layoutToken = (0, _internal.mergeToken)(token, {
  175. // Layout
  176. layoutHeaderHeight: controlHeight * 2,
  177. layoutHeaderPaddingInline,
  178. layoutHeaderColor: colorText,
  179. layoutFooterPadding: `${controlHeightSM}px ${layoutHeaderPaddingInline}px`,
  180. layoutTriggerHeight: controlHeightLG + marginXXS * 2,
  181. layoutZeroTriggerSize: controlHeightLG
  182. });
  183. return [genLayoutStyle(layoutToken)];
  184. }, token => {
  185. const {
  186. colorBgLayout
  187. } = token;
  188. return {
  189. colorBgHeader: '#001529',
  190. colorBgBody: colorBgLayout,
  191. colorBgTrigger: '#002140'
  192. };
  193. });