windi.config.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // windi.config.js
  2. import { defineConfig } from 'windicss/helpers'
  3. import lineClamp from 'windicss/plugin/line-clamp'
  4. import colors from 'windicss/colors'
  5. import proSettings from './config/defaultSettings'
  6. export default defineConfig({
  7. extract: {
  8. exclude: ['node_modules', '.git', 'dist', 'mock', '.umi']
  9. },
  10. darkMode: 'class',
  11. plugins: [lineClamp, createEnterPlugin()],
  12. theme: {
  13. extend: {
  14. colors: {
  15. ...colors,
  16. primary: proSettings.primaryColor
  17. },
  18. screens: {
  19. sm: '576px',
  20. md: '768px',
  21. lg: '992px',
  22. xl: '1200px',
  23. '2xl': '1600px'
  24. },
  25. boxShadow: {
  26. card: '0 0 13px 0 rgba(74, 53, 107, 0.08)'
  27. },
  28. zIndex: {
  29. max: 999,
  30. 1060: 1060,
  31. 1050: 1050,
  32. 1040: 1040
  33. }
  34. }
  35. }
  36. })
  37. /**
  38. * Used for animation when the element is displayed
  39. * @param maxOutput The larger the maxOutput output, the larger the generated css volume
  40. */
  41. function createEnterPlugin(maxOutput = 10) {
  42. const createCss = (index: number, d = 'x') => {
  43. const upd = d.toUpperCase()
  44. return {
  45. [`*> .enter-${d}:nth-child(${index})`]: {
  46. transform: `translate${upd}(50px)`
  47. },
  48. [`*> .-enter-${d}:nth-child(${index})`]: {
  49. transform: `translate${upd}(-50px)`
  50. },
  51. [`* > .enter-${d}:nth-child(${index}),* > .-enter-${d}:nth-child(${index})`]: {
  52. 'z-index': `${10 - index}`,
  53. opacity: '0',
  54. animation: `enter-${d}-animation 0.4s ease-in-out 0.3s`,
  55. 'animation-fill-mode': 'forwards',
  56. 'animation-delay': `${(index * 1) / 10}s`
  57. }
  58. }
  59. }
  60. const handler = ({ addBase }) => {
  61. const addRawCss = {}
  62. for (let index = 1; index < maxOutput; index++) {
  63. Object.assign(addRawCss, {
  64. ...createCss(index, 'x'),
  65. ...createCss(index, 'y')
  66. })
  67. }
  68. addBase({
  69. ...addRawCss,
  70. [`@keyframes enter-x-animation`]: {
  71. to: {
  72. opacity: '1',
  73. transform: 'translateX(0)'
  74. }
  75. },
  76. [`@keyframes enter-y-animation`]: {
  77. to: {
  78. opacity: '1',
  79. transform: 'translateY(0)'
  80. }
  81. }
  82. })
  83. }
  84. return { handler }
  85. }