windi.config.ts 2.2 KB

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