Files
zenblog/apps/web/tailwind.config.ts

231 lines
6.2 KiB
TypeScript

const {
default: flattenColorPalette,
} = require("tailwindcss/lib/util/flattenColorPalette");
const svgToDataUri = require("mini-svg-data-uri");
const colors = require("tailwindcss/colors");
const defaultTheme = require("tailwindcss/defaultTheme");
/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: ["class"],
content: [
"./pages/**/*.{ts,tsx}",
"./components/**/*.{ts,tsx}",
"./src/**/*.{ts,tsx}",
],
theme: {
border: {
"1": "1px",
"2": "2px",
DEFAULT: "1px solid var(--border-color)",
},
container: {
center: true,
padding: "2rem",
screens: {
"2xl": "1400px",
},
},
extend: {
fontFamily: {
default: [
"var(--font-sans)",
"ui-sans-serif",
"system-ui",
"sans-serif",
"Apple Color Emoji",
"Segoe UI Emoji",
"Segoe UI Symbol",
"Noto Color Emoji",
],
},
textShadow: {
sm: "0 1px 2px var(--tw-shadow-color)",
DEFAULT: "0 2px 4px var(--tw-shadow-color)",
lg: "0 8px 16px var(--tw-shadow-color)",
},
highlight: {
DEFAULT: "shadow",
},
borderColor: {
DEFAULT: "#e4e4e7",
},
colors: {
slate: {
"50": "#f9fafb",
"150": "#f4f5f7",
},
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
popover: {
DEFAULT: "hsl(var(--popover))",
foreground: "hsl(var(--popover-foreground))",
},
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
secondary: {
DEFAULT: "hsl(var(--secondary))",
foreground: "hsl(var(--secondary-foreground))",
},
muted: {
DEFAULT: "hsl(var(--muted))",
foreground: "hsl(var(--muted-foreground))",
},
accent: {
DEFAULT: "hsl(var(--accent))",
foreground: "hsl(var(--accent-foreground))",
},
destructive: {
DEFAULT: "hsl(var(--destructive))",
foreground: "hsl(var(--destructive-foreground))",
},
border: "hsl(var(--border))",
input: "hsl(var(--input))",
ring: "hsl(var(--ring))",
chart: {
"1": "hsl(var(--chart-1))",
"2": "hsl(var(--chart-2))",
"3": "hsl(var(--chart-3))",
"4": "hsl(var(--chart-4))",
"5": "hsl(var(--chart-5))",
},
},
keyframes: {
"infinite-scroll": {
from: {
transform: "translateX(0)",
},
to: {
transform: "translateX(-100%)",
},
},
"accordion-down": {
from: {
height: 0,
},
to: {
height: "var(--radix-accordion-content-height)",
},
},
"accordion-up": {
from: {
height: "var(--radix-accordion-content-height)",
},
to: {
height: 0,
},
},
marquee: {
from: {
transform: "translateX(0)",
},
to: {
transform: "translateX(calc(-100% - var(--gap)))",
},
},
"marquee-vertical": {
from: {
transform: "translateY(0)",
},
to: {
transform: "translateY(calc(-100% - var(--gap)))",
},
},
},
animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
"infinite-scroll": "infinite-scroll 25s linear infinite",
marquee: "marquee var(--duration) infinite linear",
"marquee-vertical": "marquee-vertical var(--duration) linear infinite",
},
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
},
},
},
plugins: [
require("tailwindcss-animate"),
require("@tailwindcss/typography"),
function ({ matchUtilities, theme }: any) {
matchUtilities(
{
"bg-grid": (value: any) => ({
backgroundImage: `url("${svgToDataUri(
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="${value}"><path d="M0 .5H31.5V32"/></svg>`
)}")`,
}),
},
{ values: flattenColorPalette(theme("backgroundColor")), type: "color" }
);
matchUtilities(
{
"text-shadow": (value: any) => ({
textShadow: value,
}),
},
{ values: flattenColorPalette(theme("backgroundColor")), type: "color" }
);
matchUtilities(
{
"inner-glow": (value: any) => ({
boxShadow: `inset 0 0 5px 2px ${value}`,
}),
},
{ values: flattenColorPalette(theme("backgroundColor")), type: "color" }
);
matchUtilities(
{
highlight: (value: any) => ({
boxShadow: `inset 0 1px 0 0 ${value}`,
}),
},
{ values: flattenColorPalette(theme("backgroundColor")), type: "color" }
);
},
function ({ addUtilities }: any) {
const flexUtilities = {
".flex-col": {
display: "flex",
"flex-direction": "column",
},
".flex-x-center": {
display: "flex",
"justify-content": "center",
},
".flex-y-center": {
display: "flex",
"align-items": "center",
},
".flex-center": {
display: "flex",
"align-items": "center",
"justify-content": "center",
},
// Additional utility to fix x and y inversion in flex-col
".flex-col.flex-x-center": {
"align-items": "center",
"justify-content": "start",
},
".flex-col.flex-y-center": {
"justify-content": "center",
"align-items": "start",
},
};
addUtilities(flexUtilities, ["responsive", "hover"]);
},
],
};