tailwind.config.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. const colors = require('tailwindcss/colors');
  2. module.exports = {
  3. mode: 'jit',
  4. // darkMode: 'class',
  5. plugins: [createEnterPlugin()],
  6. purge: {
  7. enabled: false,
  8. content: ['./index.html', './src/**/*.{vue,ts,tsx}'],
  9. },
  10. theme: {
  11. extend: {
  12. zIndex: {
  13. '-1': '-1',
  14. },
  15. },
  16. colors: {
  17. ...colors,
  18. primary: {
  19. DEFAULT: '#0960bd',
  20. // dark: primaryColorDark,
  21. },
  22. },
  23. screens: {
  24. sm: '576px',
  25. md: '768px',
  26. lg: '992px',
  27. xl: '1200px',
  28. '2xl': '1600px',
  29. },
  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 = 6) {
  37. const createCss = (index, 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. }