mirror of
https://github.com/decompme/decomp.me.git
synced 2026-02-19 21:08:51 -06:00
- Use Next.js 13 app directory for all routes except projects - Add Tailwind (resolves #619) and use it for most components - New footer - Adjust navbar (logotype, buttons moved to right) - Improve the styling of the search box - New /settings/account page - /credits grabs contributors list for this repo from GitHub's API - Resolve #634 - New welcome page header with scrolling platform icons
86 lines
2.3 KiB
JavaScript
86 lines
2.3 KiB
JavaScript
const plugin = require("tailwindcss/plugin")
|
|
const radixColors = require("@radix-ui/colors")
|
|
|
|
// Colors to use from Radix UI
|
|
const COLOR_NAME_MAP = {
|
|
gray: "mauve", // It's "grey", but whatever
|
|
purple: "purple",
|
|
red: "red",
|
|
blue: "blue",
|
|
}
|
|
|
|
// Convert color from `hsl(h, s, l)` to `h s l` for Tailwind
|
|
function extractHslComponents(color) {
|
|
if (!color.startsWith("hsl(")) {
|
|
console.warn(`color ${color} is not in hsl format`)
|
|
}
|
|
|
|
return color
|
|
.replace(/,/g, "")
|
|
.replace("hsl(", "")
|
|
.replace(")", "")
|
|
}
|
|
|
|
function makeTailwindColor(colorName) {
|
|
const obj = {}
|
|
|
|
for (let i = 1; i <= 12; i++) {
|
|
const key = `${colorName}${i}`
|
|
obj[i] = `hsl(var(--color-${key}) / <alpha-value>)`
|
|
}
|
|
|
|
return obj
|
|
}
|
|
|
|
function makeCssVariables(suffix = "") {
|
|
return Object.keys(COLOR_NAME_MAP).reduce((acc, unmappedColorName) => {
|
|
const colorName = COLOR_NAME_MAP[unmappedColorName]
|
|
const colors = radixColors[colorName + suffix]
|
|
const obj = {}
|
|
|
|
for (let i = 1; i <= 12; i++) {
|
|
const key = `${colorName}${i}`
|
|
const color = extractHslComponents(colors[key])
|
|
obj[`--color-${key}`] = color
|
|
}
|
|
|
|
return { ...acc, ...obj }
|
|
}, {})
|
|
}
|
|
|
|
/** @type {import('tailwindcss').Config} */
|
|
module.exports = {
|
|
darkMode: "class",
|
|
content: [
|
|
"./src/**/*.{js,ts,jsx,tsx}",
|
|
],
|
|
theme: {
|
|
extend: {
|
|
fontFamily: {
|
|
mono: ["var(--monospace)", "ui-monospace", "monospace"],
|
|
},
|
|
},
|
|
colors: {
|
|
// Subset of Tailwind default colors
|
|
transparent: "transparent",
|
|
current: "currentColor",
|
|
|
|
// Make colors from Radix UI available
|
|
...Object.keys(COLOR_NAME_MAP).reduce((acc, unmappedColorName) => {
|
|
const radixColor = COLOR_NAME_MAP[unmappedColorName]
|
|
acc[unmappedColorName] = makeTailwindColor(radixColor)
|
|
return acc
|
|
}, {}),
|
|
},
|
|
},
|
|
plugins: [
|
|
// Set --color-* variables
|
|
plugin(({ addBase }) => {
|
|
addBase({
|
|
":root": makeCssVariables(),
|
|
".dark": makeCssVariables("Dark"),
|
|
})
|
|
}),
|
|
],
|
|
}
|