sider.js 3.5 KB

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