windi.config.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. }
  29. }
  30. })
  31. /**
  32. * Used for animation when the element is displayed
  33. * @param maxOutput The larger the maxOutput output, the larger the generated css volume
  34. */
  35. function createEnterPlugin(maxOutput = 10) {
  36. const createCss = (index: number, d = 'x') => {
  37. const upd = d.toUpperCase()
  38. return {
  39. [`*> .enter-${d}:nth-child(${index})`]: {
  40. transform: `translate${upd}(50px)`
  41. },
  42. [`*> .-enter-${d}:nth-child(${index})`]: {
  43. transform: `translate${upd}(-50px)`
  44. },
  45. [`* > .enter-${d}:nth-child(${index}),* > .-enter-${d}:nth-child(${index})`]: {
  46. 'z-index': `${10 - index}`,
  47. opacity: '0',
  48. animation: `enter-${d}-animation 0.4s ease-in-out 0.3s`,
  49. 'animation-fill-mode': 'forwards',
  50. 'animation-delay': `${(index * 1) / 10}s`
  51. }
  52. }
  53. }
  54. const handler = ({ addBase }) => {
  55. const addRawCss = {}
  56. for (let index = 1; index < maxOutput; index++) {
  57. Object.assign(addRawCss, {
  58. ...createCss(index, 'x'),
  59. ...createCss(index, 'y')
  60. })
  61. }
  62. addBase({
  63. ...addRawCss,
  64. [`@keyframes enter-x-animation`]: {
  65. to: {
  66. opacity: '1',
  67. transform: 'translateX(0)'
  68. }
  69. },
  70. [`@keyframes enter-y-animation`]: {
  71. to: {
  72. opacity: '1',
  73. transform: 'translateY(0)'
  74. }
  75. }
  76. })
  77. }
  78. return { handler }
  79. }