index.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { operationUnit } from '../../style';
  2. import { genStyleHooks } from '../../theme/internal';
  3. import { getCopyableStyles, getEditableStyles, getEllipsisStyles, getLinkStyles, getResetStyles, getTitleStyles } from './mixins';
  4. const genTypographyStyle = token => {
  5. const {
  6. componentCls,
  7. titleMarginTop
  8. } = token;
  9. return {
  10. [componentCls]: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
  11. color: token.colorText,
  12. wordBreak: 'break-word',
  13. lineHeight: token.lineHeight,
  14. [`&${componentCls}-secondary`]: {
  15. color: token.colorTextDescription
  16. },
  17. [`&${componentCls}-success`]: {
  18. color: token.colorSuccessText
  19. },
  20. [`&${componentCls}-warning`]: {
  21. color: token.colorWarningText
  22. },
  23. [`&${componentCls}-danger`]: {
  24. color: token.colorErrorText,
  25. 'a&:active, a&:focus': {
  26. color: token.colorErrorTextActive
  27. },
  28. 'a&:hover': {
  29. color: token.colorErrorTextHover
  30. }
  31. },
  32. [`&${componentCls}-disabled`]: {
  33. color: token.colorTextDisabled,
  34. cursor: 'not-allowed',
  35. userSelect: 'none'
  36. },
  37. [`
  38. div&,
  39. p
  40. `]: {
  41. marginBottom: '1em'
  42. }
  43. }, getTitleStyles(token)), {
  44. [`
  45. & + h1${componentCls},
  46. & + h2${componentCls},
  47. & + h3${componentCls},
  48. & + h4${componentCls},
  49. & + h5${componentCls}
  50. `]: {
  51. marginTop: titleMarginTop
  52. },
  53. [`
  54. div,
  55. ul,
  56. li,
  57. p,
  58. h1,
  59. h2,
  60. h3,
  61. h4,
  62. h5`]: {
  63. [`
  64. + h1,
  65. + h2,
  66. + h3,
  67. + h4,
  68. + h5
  69. `]: {
  70. marginTop: titleMarginTop
  71. }
  72. }
  73. }), getResetStyles(token)), getLinkStyles(token)), {
  74. // Operation
  75. [`
  76. ${componentCls}-expand,
  77. ${componentCls}-collapse,
  78. ${componentCls}-edit,
  79. ${componentCls}-copy
  80. `]: Object.assign(Object.assign({}, operationUnit(token)), {
  81. marginInlineStart: token.marginXXS
  82. })
  83. }), getEditableStyles(token)), getCopyableStyles(token)), getEllipsisStyles()), {
  84. '&-rtl': {
  85. direction: 'rtl'
  86. }
  87. })
  88. };
  89. };
  90. export const prepareComponentToken = () => ({
  91. titleMarginTop: '1.2em',
  92. titleMarginBottom: '0.5em'
  93. });
  94. // ============================== Export ==============================
  95. export default genStyleHooks('Typography', genTypographyStyle, prepareComponentToken);