Skip to content

Commit ba08fe5

Browse files
committed
refactor: update color scheme and styles across components
1 parent ffc3b3c commit ba08fe5

File tree

3 files changed

+79
-74
lines changed

3 files changed

+79
-74
lines changed

src/pages/design.tsx

Lines changed: 68 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -36,92 +36,95 @@ export default function Design(): React.JSX.Element {
3636
</div>
3737
<p className='mt-2 text-secondary'>Font Family: Inter</p>
3838
<ul className='mt-3 grid grid-cols-[repeat(auto-fit,minmax(256px,1fr))] gap-4'>
39-
{colorPalette.map(({ title, hexCode, className }) => (
40-
<li className='flex items-center gap-2' key={title}>
41-
<div
42-
className={clsx('main-border h-10 w-10 rounded-md', className)}
43-
/>
44-
<div>
45-
<h3>{title}</h3>
46-
<p className='text-sm text-muted'>{hexCode}</p>
47-
</div>
48-
</li>
49-
))}
39+
{colorPalette.map(({ title, className, lightHex, darkHex }) => {
40+
let parsedHex: string;
41+
42+
if (!darkHex) parsedHex = lightHex;
43+
else {
44+
if (theme === 'dark') parsedHex = darkHex;
45+
else parsedHex = lightHex;
46+
}
47+
48+
return (
49+
<li className='flex items-center gap-2' key={title}>
50+
<div
51+
className={clsx(
52+
'main-border h-10 w-10 rounded-md',
53+
className
54+
)}
55+
/>
56+
<div>
57+
<h3>{title}</h3>
58+
<p className='text-sm text-muted'>{parsedHex}</p>
59+
</div>
60+
</li>
61+
);
62+
})}
5063
</ul>
5164
</motion.section>
5265
</main>
5366
);
5467
}
5568

56-
const colorPalette = [
57-
{
58-
title: 'White Background',
59-
hexCode: '#ffffff',
60-
className: 'bg-white'
61-
},
62-
{
63-
title: 'Black Background',
64-
hexCode: '#222222',
65-
className: 'bg-black'
66-
},
67-
{
68-
title: 'White Text',
69-
hexCode: '#ffffff',
70-
className: 'bg-white'
71-
},
72-
{
73-
title: 'Black Text',
74-
hexCode: '#000000',
75-
className: 'bg-black'
76-
},
77-
{
78-
title: 'Gray 100 Text',
79-
hexCode: '#f3f4f6',
80-
className: 'bg-gray-100'
81-
},
69+
type ColorPalette = {
70+
title: string;
71+
darkHex?: string;
72+
lightHex: string;
73+
className: string;
74+
};
75+
76+
const colorPalette: ColorPalette[] = [
8277
{
83-
title: 'Gray 200 Text',
84-
hexCode: '#e5e7eb',
85-
className: 'bg-gray-200'
78+
title: 'Background',
79+
className: 'bg-background',
80+
lightHex: '#ffffff',
81+
darkHex: '#000000'
8682
},
8783
{
88-
title: 'Gray 300 Text',
89-
hexCode: '#d1d5db',
90-
className: 'bg-gray-300'
84+
title: 'Foreground',
85+
className: 'bg-foreground',
86+
lightHex: '#000000',
87+
darkHex: '#ffffff'
9188
},
9289
{
93-
title: 'Gray 400 Text',
94-
hexCode: '#9ca3af',
95-
className: 'bg-gray-400'
90+
title: 'Primary',
91+
className: 'bg-primary',
92+
lightHex: '#111827',
93+
darkHex: '#f3f4f6'
9694
},
9795
{
98-
title: 'Gray 500 Text',
99-
hexCode: '#6b7280',
100-
className: 'bg-gray-500'
96+
title: 'Secondary',
97+
className: 'bg-secondary',
98+
lightHex: '#1f2937',
99+
darkHex: '#e5e7eb'
101100
},
102101
{
103-
title: 'Gray 600 Text',
104-
hexCode: '#4b5563',
105-
className: 'bg-gray-600'
102+
title: 'Muted',
103+
className: 'bg-muted',
104+
lightHex: '#4b5563',
105+
darkHex: '#9ca3af'
106106
},
107107
{
108-
title: 'Gray 700 Text',
109-
hexCode: '#374151',
110-
className: 'bg-gray-700'
108+
title: 'Border',
109+
className: 'bg-border',
110+
lightHex: '#d1d5db',
111+
darkHex: '#374151'
111112
},
112113
{
113-
title: 'Gray 800 Text',
114-
hexCode: '#1f2937',
115-
className: 'bg-gray-800'
114+
title: 'Muted background',
115+
className: 'bg-muted-background',
116+
lightHex: '#f3f4f6',
117+
darkHex: '#111827'
116118
},
117119
{
118-
title: 'Gray 900 Text',
119-
hexCode: '#111827',
120-
className: 'bg-gray-900'
120+
title: 'Accent foreground',
121+
className: 'bg-accent-foreground',
122+
lightHex: '#9ca3af',
123+
darkHex: '#4b5563'
121124
},
122125
{
123-
title: 'Gradient Color',
124-
hexCode: '#a855f7 to #f472b6',
125-
className: 'bg-gradient-to-tr from-accent-start to-accent-end'
126+
title: 'Gradient color',
127+
className: 'bg-gradient-to-tr from-accent-start to-accent-end',
128+
lightHex: '#a855f7 to #c084fc'
126129
}
127-
] as const;
130+
];

src/styles/globals.scss

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
--border: 209 213 219; /* gray-300 */
1717
--muted-background: 243 244 246; /* gray-100 */
1818
--accent-foreground: 156 163 175; /* gray-400 */
19+
20+
--accent-main: 244 114 182; /* pink-400 */
21+
--accent-start: 168 85 247; /* purple-500 */
22+
--accent-end: 244 114 182; /* pink-400 */
1923
}
2024

2125
.dark {
@@ -27,12 +31,11 @@
2731
--border: 55 65 81; /* gray-700 */
2832
--muted-background: 17 24 39; /* gray-900 */
2933
--accent-foreground: 75 85 99; /* gray-600 */
30-
}
3134

32-
/*
33-
Big refactor for global styles completed:
34-
Utilizing CSS variables to handle light/dark mode changes seamlessly.
35-
*/
35+
--accent-main: 244 114 182; /* pink-400 */
36+
--accent-start: 168 85 247; /* purple-500 */
37+
--accent-end: 244 114 182; /* pink-400 */
38+
}
3639

3740
html {
3841
// ! use important as a workaround for nextjs@13.1.0 bug that prevents smooth scroll

tailwind.config.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import colors from 'tailwindcss/colors';
21
import typography from '@tailwindcss/typography';
32
import type { Config } from 'tailwindcss';
43

@@ -20,9 +19,9 @@ export default {
2019
'muted-background': 'rgb(var(--muted-background) / <alpha-value>)',
2120
'accent-foreground': 'rgb(var(--accent-foreground) / <alpha-value>)',
2221
accent: {
23-
main: colors.pink[400],
24-
start: colors.purple[500],
25-
end: colors.pink[400]
22+
main: 'rgb(var(--accent-main) / <alpha-value>)',
23+
start: 'rgb(var(--accent-start) / <alpha-value>)',
24+
end: 'rgb(var(--accent-end) / <alpha-value>)'
2625
}
2726
}
2827
}

0 commit comments

Comments
 (0)