windi.config.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. darkMode: 'class',
  8. plugins: [lineClamp, createEnterPlugin()],
  9. theme: {
  10. extend: {
  11. colors: {
  12. ...colors,
  13. primary: proSettings.primaryColor
  14. },
  15. screens: {
  16. sm: '576px',
  17. md: '768px',
  18. lg: '992px',
  19. xl: '1200px',
  20. '2xl': '1600px'
  21. }
  22. }
  23. }
  24. })
  25. /**
  26. * Used for animation when the element is displayed
  27. * @param maxOutput The larger the maxOutput output, the larger the generated css volume
  28. */
  29. function createEnterPlugin(maxOutput = 10) {
  30. const createCss = (index: number, d = 'x') => {
  31. const upd = d.toUpperCase()
  32. return {
  33. [`*> .enter-${d}:nth-child(${index})`]: {
  34. transform: `translate${upd}(50px)`
  35. },
  36. [`*> .-enter-${d}:nth-child(${index})`]: {
  37. transform: `translate${upd}(-50px)`
  38. },
  39. [`* > .enter-${d}:nth-child(${index}),* > .-enter-${d}:nth-child(${index})`]: {
  40. 'z-index': `${10 - index}`,
  41. opacity: '0',
  42. animation: `enter-${d}-animation 0.4s ease-in-out 0.3s`,
  43. 'animation-fill-mode': 'forwards',
  44. 'animation-delay': `${(index * 1) / 10}s`
  45. }
  46. }
  47. }
  48. const handler = ({ addBase }) => {
  49. const addRawCss = {}
  50. for (let index = 1; index < maxOutput; index++) {
  51. Object.assign(addRawCss, {
  52. ...createCss(index, 'x'),
  53. ...createCss(index, 'y')
  54. })
  55. }
  56. addBase({
  57. ...addRawCss,
  58. [`@keyframes enter-x-animation`]: {
  59. to: {
  60. opacity: '1',
  61. transform: 'translateX(0)'
  62. }
  63. },
  64. [`@keyframes enter-y-animation`]: {
  65. to: {
  66. opacity: '1',
  67. transform: 'translateY(0)'
  68. }
  69. }
  70. })
  71. }
  72. return { handler }
  73. }