Files
Folo/configs/tailwind.base.config.ts
T
Innei 634436ee83 refactor: update background colors and styling across components
- Replaced 'bg-theme-modal-background-opaque' with 'bg-theme-background' in various error fallback components for consistency.
- Updated hover background classes from 'bg-theme-button-hover' to 'bg-material-ultra-thick' in multiple UI elements.
- Removed the 'modalOpaque' setting from UI settings for cleaner configuration.

Signed-off-by: Innei <tukon479@gmail.com>
2025-04-23 23:54:50 +08:00

204 lines
5.4 KiB
TypeScript

/* @moduleResolution bundler */
import "./tw-css-plugin"
import path, { resolve } from "node:path"
import { getIconCollections, iconsPlugin } from "@egoist/tailwindcss-icons"
import { cleanupSVG, importDirectorySync, isEmptyColor, parseColors, runSVGO } from "@iconify/tools"
import { compareColors, stringToColor } from "@iconify/utils/lib/colors"
import { theme } from "tailwindcss/defaultConfig"
import type { Config } from "tailwindcss/types/config"
import { withUIKit } from "tailwindcss-uikit-colors/src/macos/tailwind"
const twConfig = {
darkMode: ["class", '[data-theme="dark"]'],
content: [],
prefix: "",
theme: {
container: {
center: true,
padding: "2rem",
screens: {
"2xl": "1400px",
},
},
fontSize: {
...theme?.fontSize,
largeTitle: ["26px", "32px"],
title1: ["22px", "26px"],
title2: ["17px", "22px"],
title3: ["15px", "20px"],
headline: ["13px", "16px"],
body: ["13px", "16px"],
callout: ["12px", "15px"],
subheadline: ["11px", "14px"],
footnote: ["10px", "13px"],
caption: ["10px", "13px"],
},
extend: {
fontFamily: {
theme: "var(--fo-font-family)",
default: "SN pro, sans-serif, system-ui",
},
colors: {
border: "hsl(var(--border) / <alpha-value>)",
background: "hsl(var(--background) / <alpha-value>)",
accent: "hsl(var(--fo-a) / <alpha-value>)",
theme: {
// https://uicolors.app/create
accent: {
DEFAULT: "hsl(var(--fo-a) / <alpha-value>)",
"50": "#fff8ed",
"100": "#ffeed4",
"200": "#ffdaa8",
"300": "#ffbe70",
"400": "#ff9737",
"500": "#ff760a",
"600": "#f05d06",
"700": "#c74507",
"800": "#9e360e",
"900": "#7f2f0f",
"950": "#451505",
},
boxShadow: {
"context-menu":
"0px 0px 1px rgba(0, 0, 0, 0.4), 0px 0px 1.5px rgba(0, 0, 0, 0.3), 0px 7px 22px rgba(0, 0, 0, 0.25)",
},
item: {
active: "var(--fo-item-active)",
hover: "var(--fo-item-hover)",
},
selection: {
active: "var(--fo-selection-active)",
hover: "var(--fo-selection-hover)",
foreground: "var(--fo-selection-foreground)",
},
inactive: "hsl(var(--fo-inactive) / <alpha-value>)",
disabled: "hsl(var(--fo-disabled) / <alpha-value>)",
background: "var(--fo-background)",
},
},
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
},
backdropBlur: {
background: "80px",
},
typography: (theme: any) => ({
zinc: {
css: {
"--tw-prose-body": theme("colors.zinc.500"),
"--tw-prose-quotes": theme("colors.zinc.500"),
},
},
}),
},
},
plugins: [
iconsPlugin({
collections: {
...getIconCollections(["mingcute", "simple-icons", "logos"]),
mgc: getCollections(path.resolve(__dirname, "../icons/mgc")),
},
}),
require("tailwindcss-animate"),
require("@tailwindcss/container-queries"),
require("@tailwindcss/typography"),
require("tailwindcss-motion"),
require("tailwindcss-safe-area"),
require(resolve(__dirname, "./tailwind-extend.css")),
],
} satisfies Config
export const baseTwConfig = withUIKit(twConfig) as typeof twConfig
function getCollections(dir: string) {
// Import icons
const iconSet = importDirectorySync(dir, {
includeSubDirs: false,
})
// Validate, clean up, fix palette and optimism
iconSet.forEachSync((name, type) => {
if (type !== "icon") {
return
}
const svg = iconSet.toSVG(name)
if (!svg) {
// Invalid icon
iconSet.remove(name)
return
}
// Clean up and optimize icons
try {
// Clean up icon code
cleanupSVG(svg)
// Change color to `currentColor`
// Skip this step if icon has hardcoded palette
const blackColor = stringToColor("black")!
const whiteColor = stringToColor("white")!
parseColors(svg, {
defaultColor: "currentColor",
callback: (attr, colorStr, color) => {
if (!color) {
// Color cannot be parsed!
throw new Error(`Invalid color: "${colorStr}" in attribute ${attr}`)
}
if (isEmptyColor(color)) {
// Color is empty: 'none' or 'transparent'. Return as is
return color
}
// Change black to 'currentColor'
if (compareColors(color, blackColor)) {
return "currentColor"
}
// Remove shapes with white color
if (compareColors(color, whiteColor)) {
return "remove"
}
// NOTE: MGC icons has default color of #10161F
if (compareColors(color, stringToColor("#10161F")!)) {
return "currentColor"
}
// Icon is not monotone
return color
},
})
runSVGO(svg)
} catch (err) {
// Invalid icon
console.error(`Error parsing ${name}:`, err)
iconSet.remove(name)
return
}
// Update icon
iconSet.fromSVG(name, svg)
})
// Export
return iconSet.export()
}