index.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { genStyleHooks, mergeToken } from '../../theme/internal';
  2. // ============================== Shared ==============================
  3. const genSharedEmptyStyle = token => {
  4. const {
  5. componentCls,
  6. margin,
  7. marginXS,
  8. marginXL,
  9. fontSize,
  10. lineHeight
  11. } = token;
  12. return {
  13. [componentCls]: {
  14. marginInline: marginXS,
  15. fontSize,
  16. lineHeight,
  17. textAlign: 'center',
  18. // 原来 &-image 没有父子结构,现在为了外层承担我们的 hashId,改成父子结构
  19. [`${componentCls}-image`]: {
  20. height: token.emptyImgHeight,
  21. marginBottom: marginXS,
  22. opacity: token.opacityImage,
  23. img: {
  24. height: '100%'
  25. },
  26. svg: {
  27. maxWidth: '100%',
  28. height: '100%',
  29. margin: 'auto'
  30. }
  31. },
  32. [`${componentCls}-description`]: {
  33. color: token.colorTextDescription
  34. },
  35. // 原来 &-footer 没有父子结构,现在为了外层承担我们的 hashId,改成父子结构
  36. [`${componentCls}-footer`]: {
  37. marginTop: margin
  38. },
  39. '&-normal': {
  40. marginBlock: marginXL,
  41. color: token.colorTextDescription,
  42. [`${componentCls}-description`]: {
  43. color: token.colorTextDescription
  44. },
  45. [`${componentCls}-image`]: {
  46. height: token.emptyImgHeightMD
  47. }
  48. },
  49. '&-small': {
  50. marginBlock: marginXS,
  51. color: token.colorTextDescription,
  52. [`${componentCls}-image`]: {
  53. height: token.emptyImgHeightSM
  54. }
  55. }
  56. }
  57. };
  58. };
  59. // ============================== Export ==============================
  60. export default genStyleHooks('Empty', token => {
  61. const {
  62. componentCls,
  63. controlHeightLG,
  64. calc
  65. } = token;
  66. const emptyToken = mergeToken(token, {
  67. emptyImgCls: `${componentCls}-img`,
  68. emptyImgHeight: calc(controlHeightLG).mul(2.5).equal(),
  69. emptyImgHeightMD: controlHeightLG,
  70. emptyImgHeightSM: calc(controlHeightLG).mul(0.875).equal()
  71. });
  72. return genSharedEmptyStyle(emptyToken);
  73. });