index.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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 _tinycolor = require("@ctrl/tinycolor");
  9. var _internal = require("../../theme/internal");
  10. var _style = require("../../style");
  11. var _placementArrow = _interopRequireWildcard(require("../../style/placementArrow"));
  12. function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
  13. function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
  14. // =============================== Base ===============================
  15. const genBaseStyle = token => {
  16. const {
  17. componentCls,
  18. lineHeight,
  19. padding,
  20. paddingXS,
  21. borderRadius,
  22. borderRadiusXS,
  23. colorPrimary,
  24. colorText,
  25. colorFill,
  26. indicatorHeight,
  27. indicatorWidth,
  28. boxShadowTertiary,
  29. tourZIndexPopup,
  30. fontSize,
  31. colorBgContainer,
  32. fontWeightStrong,
  33. marginXS,
  34. colorTextLightSolid,
  35. tourBorderRadius,
  36. colorWhite,
  37. colorBgTextHover,
  38. tourCloseSize,
  39. motionDurationSlow,
  40. antCls
  41. } = token;
  42. return [{
  43. [componentCls]: (0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetComponent)(token)), {
  44. color: colorText,
  45. position: 'absolute',
  46. zIndex: tourZIndexPopup,
  47. display: 'block',
  48. visibility: 'visible',
  49. fontSize,
  50. lineHeight,
  51. width: 520,
  52. '--antd-arrow-background-color': colorBgContainer,
  53. '&-pure': {
  54. maxWidth: '100%',
  55. position: 'relative'
  56. },
  57. [`&${componentCls}-hidden`]: {
  58. display: 'none'
  59. },
  60. // ============================= panel content ============================
  61. [`${componentCls}-content`]: {
  62. position: 'relative'
  63. },
  64. [`${componentCls}-inner`]: {
  65. textAlign: 'start',
  66. textDecoration: 'none',
  67. borderRadius: tourBorderRadius,
  68. boxShadow: boxShadowTertiary,
  69. position: 'relative',
  70. backgroundColor: colorBgContainer,
  71. border: 'none',
  72. backgroundClip: 'padding-box',
  73. [`${componentCls}-close`]: {
  74. position: 'absolute',
  75. top: padding,
  76. insetInlineEnd: padding,
  77. color: token.colorIcon,
  78. outline: 'none',
  79. width: tourCloseSize,
  80. height: tourCloseSize,
  81. borderRadius: token.borderRadiusSM,
  82. transition: `background-color ${token.motionDurationMid}, color ${token.motionDurationMid}`,
  83. display: 'flex',
  84. alignItems: 'center',
  85. justifyContent: 'center',
  86. '&:hover': {
  87. color: token.colorIconHover,
  88. backgroundColor: token.wireframe ? 'transparent' : token.colorFillContent
  89. }
  90. },
  91. [`${componentCls}-cover`]: {
  92. textAlign: 'center',
  93. padding: `${padding + tourCloseSize + paddingXS}px ${padding}px 0`,
  94. img: {
  95. width: '100%'
  96. }
  97. },
  98. [`${componentCls}-header`]: {
  99. padding: `${padding}px ${padding}px ${paddingXS}px`,
  100. [`${componentCls}-title`]: {
  101. lineHeight,
  102. fontSize,
  103. fontWeight: fontWeightStrong
  104. }
  105. },
  106. [`${componentCls}-description`]: {
  107. padding: `0 ${padding}px`,
  108. lineHeight,
  109. wordWrap: 'break-word'
  110. },
  111. [`${componentCls}-footer`]: {
  112. padding: `${paddingXS}px ${padding}px ${padding}px`,
  113. textAlign: 'end',
  114. borderRadius: `0 0 ${borderRadiusXS}px ${borderRadiusXS}px`,
  115. display: 'flex',
  116. [`${componentCls}-indicators`]: {
  117. display: 'inline-block',
  118. [`${componentCls}-indicator`]: {
  119. width: indicatorWidth,
  120. height: indicatorHeight,
  121. display: 'inline-block',
  122. borderRadius: '50%',
  123. background: colorFill,
  124. '&:not(:last-child)': {
  125. marginInlineEnd: indicatorHeight
  126. },
  127. '&-active': {
  128. background: colorPrimary
  129. }
  130. }
  131. },
  132. [`${componentCls}-buttons`]: {
  133. marginInlineStart: 'auto',
  134. [`${antCls}-btn`]: {
  135. marginInlineStart: marginXS
  136. }
  137. }
  138. }
  139. },
  140. // ============================= primary type ===========================
  141. // `$` for panel, `&$` for pure panel
  142. [`${componentCls}-primary, &${componentCls}-primary`]: {
  143. '--antd-arrow-background-color': colorPrimary,
  144. [`${componentCls}-inner`]: {
  145. color: colorTextLightSolid,
  146. textAlign: 'start',
  147. textDecoration: 'none',
  148. backgroundColor: colorPrimary,
  149. borderRadius,
  150. boxShadow: boxShadowTertiary,
  151. [`${componentCls}-close`]: {
  152. color: colorTextLightSolid
  153. },
  154. [`${componentCls}-indicators`]: {
  155. [`${componentCls}-indicator`]: {
  156. background: new _tinycolor.TinyColor(colorTextLightSolid).setAlpha(0.15).toRgbString(),
  157. '&-active': {
  158. background: colorTextLightSolid
  159. }
  160. }
  161. },
  162. [`${componentCls}-prev-btn`]: {
  163. color: colorTextLightSolid,
  164. borderColor: new _tinycolor.TinyColor(colorTextLightSolid).setAlpha(0.15).toRgbString(),
  165. backgroundColor: colorPrimary,
  166. '&:hover': {
  167. backgroundColor: new _tinycolor.TinyColor(colorTextLightSolid).setAlpha(0.15).toRgbString(),
  168. borderColor: 'transparent'
  169. }
  170. },
  171. [`${componentCls}-next-btn`]: {
  172. color: colorPrimary,
  173. borderColor: 'transparent',
  174. background: colorWhite,
  175. '&:hover': {
  176. background: new _tinycolor.TinyColor(colorBgTextHover).onBackground(colorWhite).toRgbString()
  177. }
  178. }
  179. }
  180. }
  181. }),
  182. // ============================= mask ===========================
  183. [`${componentCls}-mask`]: {
  184. [`${componentCls}-placeholder-animated`]: {
  185. transition: `all ${motionDurationSlow}`
  186. }
  187. },
  188. // =========== Limit left and right placement radius ==============
  189. [['&-placement-left', '&-placement-leftTop', '&-placement-leftBottom', '&-placement-right', '&-placement-rightTop', '&-placement-rightBottom'].join(',')]: {
  190. [`${componentCls}-inner`]: {
  191. borderRadius: Math.min(tourBorderRadius, _placementArrow.MAX_VERTICAL_CONTENT_RADIUS)
  192. }
  193. }
  194. },
  195. // ============================= Arrow ===========================
  196. (0, _placementArrow.default)(token, {
  197. colorBg: 'var(--antd-arrow-background-color)',
  198. contentRadius: tourBorderRadius,
  199. limitVerticalRadius: true
  200. })];
  201. };
  202. // ============================== Export ==============================
  203. var _default = exports.default = (0, _internal.genComponentStyleHook)('Tour', token => {
  204. const {
  205. borderRadiusLG,
  206. fontSize,
  207. lineHeight
  208. } = token;
  209. const TourToken = (0, _internal.mergeToken)(token, {
  210. tourZIndexPopup: token.zIndexPopupBase + 70,
  211. indicatorWidth: 6,
  212. indicatorHeight: 6,
  213. tourBorderRadius: borderRadiusLG,
  214. tourCloseSize: fontSize * lineHeight
  215. });
  216. return [genBaseStyle(TourToken)];
  217. });