tailwind.config.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. const { sky: color_sky, ...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. sky: color_sky,
  19. primary: {
  20. DEFAULT: '#0960bd',
  21. // dark: primaryColorDark,
  22. },
  23. },
  24. screens: {
  25. sm: '576px',
  26. md: '768px',
  27. lg: '992px',
  28. xl: '1200px',
  29. '2xl': '1600px',
  30. },
  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 = 6) {
  38. const createCss = (index, 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. }