index.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.prepareComponentToken = exports.default = void 0;
  6. var _cssinjs = require("@ant-design/cssinjs");
  7. var _style = require("../../style");
  8. var _internal = require("../../theme/internal");
  9. // ============================== Size ================================
  10. const genSizeDividerStyle = token => {
  11. const {
  12. componentCls
  13. } = token;
  14. return {
  15. [componentCls]: {
  16. '&-horizontal': {
  17. [`&${componentCls}`]: {
  18. '&-sm': {
  19. marginBlock: token.marginXS
  20. },
  21. '&-md': {
  22. marginBlock: token.margin
  23. }
  24. }
  25. }
  26. }
  27. };
  28. };
  29. // ============================== Shared ==============================
  30. const genSharedDividerStyle = token => {
  31. const {
  32. componentCls,
  33. sizePaddingEdgeHorizontal,
  34. colorSplit,
  35. lineWidth,
  36. textPaddingInline,
  37. orientationMargin,
  38. verticalMarginInline
  39. } = token;
  40. return {
  41. [componentCls]: Object.assign(Object.assign({}, (0, _style.resetComponent)(token)), {
  42. borderBlockStart: `${(0, _cssinjs.unit)(lineWidth)} solid ${colorSplit}`,
  43. // vertical
  44. '&-vertical': {
  45. position: 'relative',
  46. top: '-0.06em',
  47. display: 'inline-block',
  48. height: '0.9em',
  49. marginInline: verticalMarginInline,
  50. marginBlock: 0,
  51. verticalAlign: 'middle',
  52. borderTop: 0,
  53. borderInlineStart: `${(0, _cssinjs.unit)(lineWidth)} solid ${colorSplit}`
  54. },
  55. '&-horizontal': {
  56. display: 'flex',
  57. clear: 'both',
  58. width: '100%',
  59. minWidth: '100%',
  60. // Fix https://github.com/ant-design/ant-design/issues/10914
  61. margin: `${(0, _cssinjs.unit)(token.marginLG)} 0`
  62. },
  63. [`&-horizontal${componentCls}-with-text`]: {
  64. display: 'flex',
  65. alignItems: 'center',
  66. margin: `${(0, _cssinjs.unit)(token.dividerHorizontalWithTextGutterMargin)} 0`,
  67. color: token.colorTextHeading,
  68. fontWeight: 500,
  69. fontSize: token.fontSizeLG,
  70. whiteSpace: 'nowrap',
  71. textAlign: 'center',
  72. borderBlockStart: `0 ${colorSplit}`,
  73. '&::before, &::after': {
  74. position: 'relative',
  75. width: '50%',
  76. borderBlockStart: `${(0, _cssinjs.unit)(lineWidth)} solid transparent`,
  77. // Chrome not accept `inherit` in `border-top`
  78. borderBlockStartColor: 'inherit',
  79. borderBlockEnd: 0,
  80. transform: 'translateY(50%)',
  81. content: "''"
  82. }
  83. },
  84. [`&-horizontal${componentCls}-with-text-start`]: {
  85. '&::before': {
  86. width: `calc(${orientationMargin} * 100%)`
  87. },
  88. '&::after': {
  89. width: `calc(100% - ${orientationMargin} * 100%)`
  90. }
  91. },
  92. [`&-horizontal${componentCls}-with-text-end`]: {
  93. '&::before': {
  94. width: `calc(100% - ${orientationMargin} * 100%)`
  95. },
  96. '&::after': {
  97. width: `calc(${orientationMargin} * 100%)`
  98. }
  99. },
  100. [`${componentCls}-inner-text`]: {
  101. display: 'inline-block',
  102. paddingBlock: 0,
  103. paddingInline: textPaddingInline
  104. },
  105. '&-dashed': {
  106. background: 'none',
  107. borderColor: colorSplit,
  108. borderStyle: 'dashed',
  109. borderWidth: `${(0, _cssinjs.unit)(lineWidth)} 0 0`
  110. },
  111. [`&-horizontal${componentCls}-with-text${componentCls}-dashed`]: {
  112. '&::before, &::after': {
  113. borderStyle: 'dashed none none'
  114. }
  115. },
  116. [`&-vertical${componentCls}-dashed`]: {
  117. borderInlineStartWidth: lineWidth,
  118. borderInlineEnd: 0,
  119. borderBlockStart: 0,
  120. borderBlockEnd: 0
  121. },
  122. '&-dotted': {
  123. background: 'none',
  124. borderColor: colorSplit,
  125. borderStyle: 'dotted',
  126. borderWidth: `${(0, _cssinjs.unit)(lineWidth)} 0 0`
  127. },
  128. [`&-horizontal${componentCls}-with-text${componentCls}-dotted`]: {
  129. '&::before, &::after': {
  130. borderStyle: 'dotted none none'
  131. }
  132. },
  133. [`&-vertical${componentCls}-dotted`]: {
  134. borderInlineStartWidth: lineWidth,
  135. borderInlineEnd: 0,
  136. borderBlockStart: 0,
  137. borderBlockEnd: 0
  138. },
  139. [`&-plain${componentCls}-with-text`]: {
  140. color: token.colorText,
  141. fontWeight: 'normal',
  142. fontSize: token.fontSize
  143. },
  144. [`&-horizontal${componentCls}-with-text-start${componentCls}-no-default-orientation-margin-start`]: {
  145. '&::before': {
  146. width: 0
  147. },
  148. '&::after': {
  149. width: '100%'
  150. },
  151. [`${componentCls}-inner-text`]: {
  152. paddingInlineStart: sizePaddingEdgeHorizontal
  153. }
  154. },
  155. [`&-horizontal${componentCls}-with-text-end${componentCls}-no-default-orientation-margin-end`]: {
  156. '&::before': {
  157. width: '100%'
  158. },
  159. '&::after': {
  160. width: 0
  161. },
  162. [`${componentCls}-inner-text`]: {
  163. paddingInlineEnd: sizePaddingEdgeHorizontal
  164. }
  165. }
  166. })
  167. };
  168. };
  169. const prepareComponentToken = token => ({
  170. textPaddingInline: '1em',
  171. orientationMargin: 0.05,
  172. verticalMarginInline: token.marginXS
  173. });
  174. // ============================== Export ==============================
  175. exports.prepareComponentToken = prepareComponentToken;
  176. var _default = exports.default = (0, _internal.genStyleHooks)('Divider', token => {
  177. const dividerToken = (0, _internal.mergeToken)(token, {
  178. dividerHorizontalWithTextGutterMargin: token.margin,
  179. sizePaddingEdgeHorizontal: 0
  180. });
  181. return [genSharedDividerStyle(dividerToken), genSizeDividerStyle(dividerToken)];
  182. }, prepareComponentToken, {
  183. unitless: {
  184. orientationMargin: true
  185. }
  186. });