Compare commits

...

2 Commits

Author SHA1 Message Date
d624ac6ab2
feat(page): update layout styling
The structure of the main component in page.tsx has been adjusted to better accommodate its content. The div styling has been updated from full width with padding to half-width, full height, and content justified to the end.
2024-06-07 14:34:31 +02:00
409926a97b
feat(tailwind.config): add global CSS variables for colors
A new function, `addVariablesForColors`, has been added into the Tailwind configuration file to map each Tailwind color into a global CSS variable. This allows usage such as `var(--gray-200)` throughout the application for all Tailwind colors.
2024-06-07 14:26:48 +02:00
2 changed files with 17 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import Image from "next/image";
export default function Home() { export default function Home() {
return ( return (
<main className="flex flex-col items-center justify-between p-24"> <main className="flex flex-col items-center justify-end h-full w-2/4">
<h1>Hello world !</h1> <h1>Hello world !</h1>
</main> </main>
); );

View File

@ -1,5 +1,8 @@
import type { Config } from "tailwindcss" import type { Config } from "tailwindcss"
// @ts-ignore
import {default as flattenColorPalette} from "tailwindcss/lib/util/flattenColorPalette";
const config = { const config = {
darkMode: ["class"], darkMode: ["class"],
content: [ content: [
@ -74,7 +77,19 @@ const config = {
}, },
}, },
}, },
plugins: [require("tailwindcss-animate")], plugins: [require("tailwindcss-animate"), addVariablesForColors],
} satisfies Config } satisfies Config
// This plugin adds each Tailwind color as a global CSS variable, e.g. var(--gray-200).
function addVariablesForColors({ addBase, theme }: any) {
let allColors = flattenColorPalette(theme("colors"));
let newVars = Object.fromEntries(
Object.entries(allColors).map(([key, val]) => [`--${key}`, val])
);
addBase({
":root": newVars,
});
}
export default config export default config