Skip to content

Commit f888a0a

Browse files
committed
fix: implement proper color system with CSS variables
- Convert color variables from hex to RGB format for better opacity support - Update Tailwind config to use RGB color values with alpha channel support - Add test color squares to verify color system functionality - Apply explicit color classes to UI components - Fix theme class application in layout component - Ensure proper CSS variable inheritance for light/dark themes
1 parent cf9157c commit f888a0a

6 files changed

Lines changed: 56 additions & 114 deletions

File tree

postcss.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
}

postcss.config.mjs

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/app/globals.css

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,33 @@
55
@tailwind components;
66
@tailwind utilities;
77

8-
@layer base {
9-
:root {
10-
--background-light: #ffffff;
11-
--background-dark: #0d1117;
12-
--text-light: #24292f;
13-
--text-dark: #f0f6fc;
14-
--accent-light: #0969da;
15-
--accent-dark: #58a6ff;
16-
--muted-light: #656d76;
17-
--muted-dark: #8b949e;
18-
--surface-light: #f6f8fa;
19-
--surface-dark: #21262d;
20-
}
8+
:root {
9+
--background-light: 255 255 255;
10+
--background-dark: 13 17 23;
11+
--text-light: 36 41 47;
12+
--text-dark: 240 246 252;
13+
--accent-light: 9 105 218;
14+
--accent-dark: 88 166 255;
15+
--muted-light: 101 109 118;
16+
--muted-dark: 139 148 158;
17+
--surface-light: 246 248 250;
18+
--surface-dark: 33 38 45;
19+
}
2120

22-
.light {
23-
--background: var(--background-light);
24-
--text: var(--text-light);
25-
--accent: var(--accent-light);
26-
--muted: var(--muted-light);
27-
--surface: var(--surface-light);
28-
}
21+
.light {
22+
--background: var(--background-light);
23+
--text: var(--text-light);
24+
--accent: var(--accent-light);
25+
--muted: var(--muted-light);
26+
--surface: var(--surface-light);
27+
}
2928

30-
.dark {
31-
--background: var(--background-dark);
32-
--text: var(--text-dark);
33-
--accent: var(--accent-dark);
34-
--muted: var(--muted-dark);
35-
--surface: var(--surface-dark);
36-
}
29+
.dark {
30+
--background: var(--background-dark);
31+
--text: var(--text-dark);
32+
--accent: var(--accent-dark);
33+
--muted: var(--muted-dark);
34+
--surface: var(--surface-dark);
3735
}
3836

3937
@layer base {

src/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function RootLayout({
2323
children: React.ReactNode;
2424
}>) {
2525
return (
26-
<html lang="en">
26+
<html lang="en" className="light">
2727
<body
2828
className={`${jetbrainsMono.variable} ${inter.variable} antialiased`}
2929
>

src/app/page.tsx

Lines changed: 19 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -16,66 +16,27 @@ import {
1616
export default function Home() {
1717
return (
1818
<div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
19-
<main className="flex flex-col gap-8 row-start-2 items-center sm:items-start">
20-
<Image
21-
className="dark:invert"
22-
src="/next.svg"
23-
alt="Next.js logo"
24-
width={180}
25-
height={38}
26-
priority={true}
27-
/>
28-
<ol className="list-inside list-decimal text-sm text-center sm:text-left font-[family-name:var(--font-geist-mono)]">
29-
<li className="mb-2">
30-
Get started by editing{" "}
31-
<code className="bg-black/[.05] dark:bg-white/[.06] px-1 py-0.5 rounded font-semibold">
32-
src/app/page.tsx
33-
</code>
34-
.
35-
</li>
36-
<li>Save and see your changes instantly.</li>
37-
</ol>
38-
39-
<div className="flex gap-4 items-center flex-col sm:flex-row">
40-
<a
41-
className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground text-background gap-2 hover:bg-[#383838] dark:hover:bg-[#ccc] text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5"
42-
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
43-
target="_blank"
44-
rel="noopener noreferrer"
45-
>
46-
<Image
47-
className="dark:invert"
48-
src="/vercel.svg"
49-
alt="Vercel logomark"
50-
width={20}
51-
height={20}
52-
/>
53-
Deploy now
54-
</a>
55-
<a
56-
className="rounded-full border border-solid border-black/[.08] dark:border-white/[.145] transition-colors flex items-center justify-center hover:bg-[#f2f2f2] dark:hover:bg-[#1a1a1a] hover:border-transparent text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 sm:min-w-44"
57-
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
58-
target="_blank"
59-
rel="noopener noreferrer"
60-
>
61-
Read our docs
62-
</a>
63-
</div>
64-
</main>
65-
19+
{/* Test colors */}
20+
<div className="fixed top-4 left-4 flex flex-col gap-2">
21+
<div className="w-20 h-20 bg-background border border-text"></div>
22+
<div className="w-20 h-20 bg-accent"></div>
23+
<div className="w-20 h-20 bg-muted"></div>
24+
<div className="w-20 h-20 bg-surface"></div>
25+
</div>
26+
6627
<Section spacing="lg" maxWidth="4xl" align="center" className="row-start-2 w-full flex flex-col gap-12 items-center mt-8">
67-
<Heading as="h2" size="h2" className="mb-2">UI Component Showcase</Heading>
28+
<Heading as="h2" size="h2" className="mb-2 text-accent">UI Component Showcase</Heading>
6829
<div className="flex flex-wrap gap-8 justify-center w-full">
6930
<div className="flex flex-col gap-2 items-center">
70-
<Text weight="bold">Badges</Text>
31+
<Text weight="bold" className="text-accent">Badges</Text>
7132
<div className="flex gap-2">
7233
<Badge>Default</Badge>
7334
<Badge variant="secondary">Secondary</Badge>
7435
<Badge variant="outline">Outline</Badge>
7536
</div>
7637
</div>
7738
<div className="flex flex-col gap-2 items-center">
78-
<Text weight="bold">Buttons</Text>
39+
<Text weight="bold" className="text-accent">Buttons</Text>
7940
<div className="flex gap-2 flex-wrap">
8041
<Button>Default</Button>
8142
<Button variant="secondary">Secondary</Button>
@@ -89,8 +50,8 @@ export default function Home() {
8950
</div>
9051
<div className="flex flex-wrap gap-8 justify-center w-full">
9152
<div className="flex flex-col gap-2 items-center">
92-
<Text weight="bold">Card</Text>
93-
<Card className="w-80">
53+
<Text weight="bold" className="text-accent">Card</Text>
54+
<Card className="w-80 bg-surface">
9455
<CardHeader>
9556
<CardTitle>Card Title</CardTitle>
9657
<CardDescription>Card description goes here.</CardDescription>
@@ -104,15 +65,15 @@ export default function Home() {
10465
</Card>
10566
</div>
10667
<div className="flex flex-col gap-2 items-center">
107-
<Text weight="bold">Section</Text>
108-
<Section spacing="md" maxWidth="md" align="center" className="bg-muted-foreground/10 rounded-lg p-4 w-80">
68+
<Text weight="bold" className="text-accent">Section</Text>
69+
<Section spacing="md" maxWidth="md" align="center" className="bg-surface rounded-lg p-4 w-80">
10970
<Heading as="h3" size="h4">Section Title</Heading>
11071
<Text>This is a section container with spacing and alignment.</Text>
11172
</Section>
11273
</div>
11374
</div>
11475
<div className="flex flex-col gap-2 items-center w-full">
115-
<Text weight="bold">Typography</Text>
76+
<Text weight="bold" className="text-accent">Typography</Text>
11677
<div className="flex flex-col gap-1 items-center w-full">
11778
<Heading as="h1" size="h1">Heading 1</Heading>
11879
<Heading as="h2" size="h2">Heading 2</Heading>
@@ -136,7 +97,7 @@ export default function Home() {
13697

13798
<footer className="row-start-3 flex gap-6 flex-wrap items-center justify-center">
13899
<a
139-
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
100+
className="flex items-center gap-2 hover:underline hover:underline-offset-4 text-accent"
140101
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
141102
target="_blank"
142103
rel="noopener noreferrer"
@@ -151,7 +112,7 @@ export default function Home() {
151112
Learn
152113
</a>
153114
<a
154-
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
115+
className="flex items-center gap-2 hover:underline hover:underline-offset-4 text-accent"
155116
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
156117
target="_blank"
157118
rel="noopener noreferrer"
@@ -166,7 +127,7 @@ export default function Home() {
166127
Examples
167128
</a>
168129
<a
169-
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
130+
className="flex items-center gap-2 hover:underline hover:underline-offset-4 text-accent"
170131
href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
171132
target="_blank"
172133
rel="noopener noreferrer"

tailwind.config.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,11 @@ export default {
1010
theme: {
1111
extend: {
1212
colors: {
13-
background: {
14-
light: "#ffffff",
15-
dark: "#0d1117",
16-
},
17-
text: {
18-
light: "#24292f",
19-
dark: "#f0f6fc",
20-
},
21-
accent: {
22-
light: "#0969da",
23-
dark: "#58a6ff",
24-
},
25-
muted: {
26-
light: "#656d76",
27-
dark: "#8b949e",
28-
},
29-
surface: {
30-
light: "#f6f8fa",
31-
dark: "#21262d",
32-
},
13+
background: "rgb(var(--background) / <alpha-value>)",
14+
text: "rgb(var(--text) / <alpha-value>)",
15+
accent: "rgb(var(--accent) / <alpha-value>)",
16+
muted: "rgb(var(--muted) / <alpha-value>)",
17+
surface: "rgb(var(--surface) / <alpha-value>)",
3318
},
3419
fontFamily: {
3520
mono: ["JetBrains Mono", "ui-monospace", "SFMono-Regular", "Menlo", "Monaco", "Consolas", "Liberation Mono", "Courier New", "monospace"],

0 commit comments

Comments
 (0)