windi.config.ts 2.1 KB

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