tailwind.config.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. module.exports = {
  2. mode: 'jit',
  3. // darkMode: 'class',
  4. plugins: [createEnterPlugin()],
  5. purge: {
  6. enable: process.env.NODE_ENV === 'production',
  7. content: ['./index.html', './src/**/*.{vue,ts,tsx}'],
  8. },
  9. theme: {
  10. extend: {
  11. zIndex: {
  12. '-1': '-1',
  13. },
  14. colors: {
  15. primary: {
  16. DEFAULT: '#0960bd',
  17. // dark: primaryColorDark,
  18. },
  19. },
  20. screens: {
  21. sm: '576px',
  22. md: '768px',
  23. lg: '992px',
  24. xl: '1200px',
  25. '2xl': '1600px',
  26. },
  27. },
  28. },
  29. };
  30. /**
  31. * Used for animation when the element is displayed
  32. * @param maxOutput The larger the maxOutput output, the larger the generated css volume
  33. */
  34. function createEnterPlugin(maxOutput = 6) {
  35. const createCss = (index, d = 'x') => {
  36. const upd = d.toUpperCase();
  37. return {
  38. [`*> .enter-${d}:nth-child(${index})`]: {
  39. transform: `translate${upd}(50px)`,
  40. },
  41. [`*> .-enter-${d}:nth-child(${index})`]: {
  42. transform: `translate${upd}(-50px)`,
  43. },
  44. [`* > .enter-${d}:nth-child(${index}),* > .-enter-${d}:nth-child(${index})`]: {
  45. 'z-index': `${10 - index}`,
  46. opacity: '0',
  47. animation: `enter-${d}-animation 0.4s ease-in-out 0.3s`,
  48. 'animation-fill-mode': 'forwards',
  49. 'animation-delay': `${(index * 1) / 10}s`,
  50. },
  51. };
  52. };
  53. const handler = ({ addBase }) => {
  54. const addRawCss = {};
  55. for (let index = 1; index < maxOutput; index++) {
  56. Object.assign(addRawCss, {
  57. ...createCss(index, 'x'),
  58. ...createCss(index, 'y'),
  59. });
  60. }
  61. addBase({
  62. ...addRawCss,
  63. [`@keyframes enter-x-animation`]: {
  64. to: {
  65. opacity: '1',
  66. transform: 'translateX(0)',
  67. },
  68. },
  69. [`@keyframes enter-y-animation`]: {
  70. to: {
  71. opacity: '1',
  72. transform: 'translateY(0)',
  73. },
  74. },
  75. });
  76. };
  77. return { handler };
  78. }