index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 _style = require("../../style");
  10. // ============================== Shared ==============================
  11. const genSharedAnchorStyle = token => {
  12. const {
  13. componentCls,
  14. holderOffsetBlock,
  15. motionDurationSlow,
  16. lineWidthBold,
  17. colorPrimary,
  18. lineType,
  19. colorSplit
  20. } = token;
  21. return {
  22. [`${componentCls}-wrapper`]: {
  23. marginBlockStart: -holderOffsetBlock,
  24. paddingBlockStart: holderOffsetBlock,
  25. // delete overflow: auto
  26. // overflow: 'auto',
  27. backgroundColor: 'transparent',
  28. [componentCls]: (0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetComponent)(token)), {
  29. position: 'relative',
  30. paddingInlineStart: lineWidthBold,
  31. [`${componentCls}-link`]: {
  32. paddingBlock: token.anchorPaddingBlock,
  33. paddingInline: `${token.anchorPaddingInline}px 0`,
  34. '&-title': (0, _extends2.default)((0, _extends2.default)({}, _style.textEllipsis), {
  35. position: 'relative',
  36. display: 'block',
  37. marginBlockEnd: token.anchorTitleBlock,
  38. color: token.colorText,
  39. transition: `all ${token.motionDurationSlow}`,
  40. '&:only-child': {
  41. marginBlockEnd: 0
  42. }
  43. }),
  44. [`&-active > ${componentCls}-link-title`]: {
  45. color: token.colorPrimary
  46. },
  47. // link link
  48. [`${componentCls}-link`]: {
  49. paddingBlock: token.anchorPaddingBlockSecondary
  50. }
  51. }
  52. }),
  53. [`&:not(${componentCls}-wrapper-horizontal)`]: {
  54. [componentCls]: {
  55. '&::before': {
  56. position: 'absolute',
  57. left: {
  58. _skip_check_: true,
  59. value: 0
  60. },
  61. top: 0,
  62. height: '100%',
  63. borderInlineStart: `${lineWidthBold}px ${lineType} ${colorSplit}`,
  64. content: '" "'
  65. },
  66. [`${componentCls}-ink`]: {
  67. position: 'absolute',
  68. left: {
  69. _skip_check_: true,
  70. value: 0
  71. },
  72. display: 'none',
  73. transform: 'translateY(-50%)',
  74. transition: `top ${motionDurationSlow} ease-in-out`,
  75. width: lineWidthBold,
  76. backgroundColor: colorPrimary,
  77. [`&${componentCls}-ink-visible`]: {
  78. display: 'inline-block'
  79. }
  80. }
  81. }
  82. },
  83. [`${componentCls}-fixed ${componentCls}-ink ${componentCls}-ink`]: {
  84. display: 'none'
  85. }
  86. }
  87. };
  88. };
  89. const genSharedAnchorHorizontalStyle = token => {
  90. const {
  91. componentCls,
  92. motionDurationSlow,
  93. lineWidthBold,
  94. colorPrimary
  95. } = token;
  96. return {
  97. [`${componentCls}-wrapper-horizontal`]: {
  98. position: 'relative',
  99. '&::before': {
  100. position: 'absolute',
  101. left: {
  102. _skip_check_: true,
  103. value: 0
  104. },
  105. right: {
  106. _skip_check_: true,
  107. value: 0
  108. },
  109. bottom: 0,
  110. borderBottom: `1px ${token.lineType} ${token.colorSplit}`,
  111. content: '" "'
  112. },
  113. [componentCls]: {
  114. overflowX: 'scroll',
  115. position: 'relative',
  116. display: 'flex',
  117. scrollbarWidth: 'none' /* Firefox */,
  118. '&::-webkit-scrollbar': {
  119. display: 'none' /* Safari and Chrome */
  120. },
  121. [`${componentCls}-link:first-of-type`]: {
  122. paddingInline: 0
  123. },
  124. [`${componentCls}-ink`]: {
  125. position: 'absolute',
  126. bottom: 0,
  127. transition: `left ${motionDurationSlow} ease-in-out, width ${motionDurationSlow} ease-in-out`,
  128. height: lineWidthBold,
  129. backgroundColor: colorPrimary
  130. }
  131. }
  132. }
  133. };
  134. };
  135. // ============================== Export ==============================
  136. var _default = exports.default = (0, _internal.genComponentStyleHook)('Anchor', token => {
  137. const {
  138. fontSize,
  139. fontSizeLG,
  140. padding,
  141. paddingXXS
  142. } = token;
  143. const anchorToken = (0, _internal.mergeToken)(token, {
  144. holderOffsetBlock: paddingXXS,
  145. anchorPaddingBlock: paddingXXS,
  146. anchorPaddingBlockSecondary: paddingXXS / 2,
  147. anchorPaddingInline: padding,
  148. anchorTitleBlock: fontSize / 14 * 3,
  149. anchorBallSize: fontSizeLG / 2
  150. });
  151. return [genSharedAnchorStyle(anchorToken), genSharedAnchorHorizontalStyle(anchorToken)];
  152. });