tailwind.config.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* eslint-disable */
  2. const defaultTheme = require('tailwindcss/defaultTheme');
  3. const colors = require('tailwindcss/colors');
  4. function withOpacityValue(variable) {
  5. return ({ opacityValue }) => {
  6. if (opacityValue === undefined) {
  7. return `rgb(var(${variable}))`;
  8. }
  9. return `rgb(var(${variable}) / ${opacityValue})`;
  10. };
  11. }
  12. function rem2px(input, fontSize = 16) {
  13. if (input == null) {
  14. return input;
  15. }
  16. switch (typeof input) {
  17. case 'object':
  18. if (Array.isArray(input)) {
  19. return input.map((val) => rem2px(val, fontSize));
  20. }
  21. const ret = {};
  22. for (const key in input) {
  23. ret[key] = rem2px(input[key]);
  24. }
  25. return ret;
  26. case 'string':
  27. return input.replace(
  28. /(\d*\.?\d+)rem$/,
  29. (_, val) => `${parseFloat(val) * fontSize}px`
  30. );
  31. default:
  32. return input;
  33. }
  34. }
  35. module.exports = {
  36. content: ['./src/**/*.{js,jsx,ts,tsx,vue}', './business/**/*.{js,jsx,ts,tsx,vue}'],
  37. darkMode: 'class', // or 'media' or 'class'
  38. theme: {
  39. borderRadius: rem2px(defaultTheme.borderRadius),
  40. columns: rem2px(defaultTheme.columns),
  41. fontSize: rem2px(defaultTheme.fontSize),
  42. lineHeight: rem2px(defaultTheme.lineHeight),
  43. maxWidth: ({ theme, breakpoints }) => ({
  44. ...rem2px(defaultTheme.maxWidth({ theme, breakpoints })),
  45. }),
  46. spacing: rem2px(defaultTheme.spacing),
  47. extend: {
  48. colors: {
  49. primary: withOpacityValue('--color-primary'),
  50. secondary: withOpacityValue('--color-secondary'),
  51. accent: withOpacityValue('--color-accent'),
  52. gray: colors.zinc,
  53. orange: colors.orange,
  54. },
  55. fontFamily: {
  56. sans: ['Poppins', 'sans-serif'],
  57. mono: ['Source Code Pro', 'monospace'],
  58. },
  59. container: {
  60. center: true,
  61. padding: {
  62. DEFAULT: '1rem',
  63. sm: '2rem',
  64. },
  65. },
  66. },
  67. },
  68. variants: {
  69. extend: {},
  70. },
  71. plugins: [require('@tailwindcss/typography')],
  72. };