index.js 7.6 KB

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