Files
comp126/tailwind.config.js
2024-11-11 23:03:20 -05:00

46 lines
1.5 KiB
JavaScript

import { spacing } from 'tailwindcss/defaultTheme';
/** @type {import('tailwindcss').Config} */
export default {
content: [],
theme: {
extend: {},
spacing: {
...spacing,
0.5: undefined,
1.5: undefined,
2.5: undefined,
3.5: undefined,
},
},
plugins: [
function ({ addUtilities, theme }) {
function extractVars(obj, group = '', prefix) {
return Object.keys(obj).reduce((vars, key) => {
const value = obj[key];
if (!value || typeof value === 'boolean') return vars;
const cssVariable = key === 'DEFAULT' ? `--${prefix}${group}` : `--${prefix}${group}-${key}`;
const newVars = typeof value === 'string' ? { [cssVariable]: value } : extractVars(value, `-${key}`, prefix);
return { ...vars, ...newVars };
}, {});
}
addUtilities({
':root': {
...extractVars(theme('colors'), '', 'color'),
...extractVars(theme('boxShadow'), '', 'shadow'),
...extractVars(theme('ringWidth'), '', 'ring'),
...extractVars(theme('ringColor'), '', 'ring'),
...extractVars(theme('ringOffsetWidth'), '', 'ring'),
...extractVars(theme('ringOffsetColor'), '', 'ring'),
...extractVars(theme('spacing'), '', 'space'),
...extractVars(theme('screens'), '', 'screen'),
...extractVars(theme('maxWidth'), '', 'w'),
...extractVars(theme('borderRadius'), '', 'rounded'),
},
});
},
],
};