Skip to content

Commit 3291b5d

Browse files
committed
refactor: remove tailwindcss import in @nbw/config package and add inline colors
Historically, we had imported the colors from Tailwind CSS as it made sense to avoid handling our own color definitions. This has caused mroe trouble than it's worth after Tailwind changed their internal color structure, even switching to OKLab instead of RGB. We're now inlining the color definitions from Tailwind v3.4.19 (last v3.x release), which ensures predictability in builds and also lets us change the color definition as we wish, since we're now in complete control.
1 parent 3c69523 commit 3291b5d

File tree

2 files changed

+321
-18
lines changed

2 files changed

+321
-18
lines changed

packages/configs/src/colors.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
11
/*
2-
32
Obtains the background colors from the Tailwind CSS color palette
43
and creates a dictionary with the light and dark shades of each color.
54
6-
Importing from 'tailwindcss/colors' returns undefined in the backend,
7-
somehow due to commonjs/esm?
8-
So we have to import directly the public colors file instead, which
9-
there are no types for.
10-
11-
It's also possible to reference the default theme from JavaScript,
12-
as shown in the link below:
13-
https://tailwindcss.com/docs/configuration#referencing-in-java-script
14-
Similar idea at:
15-
https://github.com/tailwindlabs/tailwindcss/discussions/11127#discussioncomment-9162723
16-
However, again in the backend, we also have a problem with 'resolveConfig
17-
is not a function'.
18-
This may come down to Tailwind being a browser-only library, and not meant
19-
to be used in the backend.
20-
215
Full list of colors is available at:
226
https://tailwindcss.com/docs/customizing-colors
23-
247
*/
25-
import colors from 'tailwindcss/colors';
8+
import colors from './tailwindColors.ts';
269

2710
export const BG_COLORS = {
2811
red: {
Lines changed: 320 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,320 @@
1+
/*
2+
Tailwind CSS Default Color Palette
3+
Adapted from: https://github.com/tailwindlabs/tailwindcss/blob/v3.4.19/src/public/colors.js
4+
5+
MIT License
6+
7+
Copyright (c) Tailwind Labs, Inc.
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.
26+
*/
27+
28+
export default {
29+
inherit: 'inherit',
30+
current: 'currentColor',
31+
transparent: 'transparent',
32+
black: '#000',
33+
white: '#fff',
34+
slate: {
35+
50: '#f8fafc',
36+
100: '#f1f5f9',
37+
200: '#e2e8f0',
38+
300: '#cbd5e1',
39+
400: '#94a3b8',
40+
500: '#64748b',
41+
600: '#475569',
42+
700: '#334155',
43+
800: '#1e293b',
44+
900: '#0f172a',
45+
950: '#020617',
46+
},
47+
gray: {
48+
50: '#f9fafb',
49+
100: '#f3f4f6',
50+
200: '#e5e7eb',
51+
300: '#d1d5db',
52+
400: '#9ca3af',
53+
500: '#6b7280',
54+
600: '#4b5563',
55+
700: '#374151',
56+
800: '#1f2937',
57+
900: '#111827',
58+
950: '#030712',
59+
},
60+
zinc: {
61+
50: '#fafafa',
62+
100: '#f4f4f5',
63+
200: '#e4e4e7',
64+
300: '#d4d4d8',
65+
400: '#a1a1aa',
66+
500: '#71717a',
67+
600: '#52525b',
68+
700: '#3f3f46',
69+
800: '#27272a',
70+
900: '#18181b',
71+
950: '#09090b',
72+
},
73+
neutral: {
74+
50: '#fafafa',
75+
100: '#f5f5f5',
76+
200: '#e5e5e5',
77+
300: '#d4d4d4',
78+
400: '#a3a3a3',
79+
500: '#737373',
80+
600: '#525252',
81+
700: '#404040',
82+
800: '#262626',
83+
900: '#171717',
84+
950: '#0a0a0a',
85+
},
86+
stone: {
87+
50: '#fafaf9',
88+
100: '#f5f5f4',
89+
200: '#e7e5e4',
90+
300: '#d6d3d1',
91+
400: '#a8a29e',
92+
500: '#78716c',
93+
600: '#57534e',
94+
700: '#44403c',
95+
800: '#292524',
96+
900: '#1c1917',
97+
950: '#0c0a09',
98+
},
99+
red: {
100+
50: '#fef2f2',
101+
100: '#fee2e2',
102+
200: '#fecaca',
103+
300: '#fca5a5',
104+
400: '#f87171',
105+
500: '#ef4444',
106+
600: '#dc2626',
107+
700: '#b91c1c',
108+
800: '#991b1b',
109+
900: '#7f1d1d',
110+
950: '#450a0a',
111+
},
112+
orange: {
113+
50: '#fff7ed',
114+
100: '#ffedd5',
115+
200: '#fed7aa',
116+
300: '#fdba74',
117+
400: '#fb923c',
118+
500: '#f97316',
119+
600: '#ea580c',
120+
700: '#c2410c',
121+
800: '#9a3412',
122+
900: '#7c2d12',
123+
950: '#431407',
124+
},
125+
amber: {
126+
50: '#fffbeb',
127+
100: '#fef3c7',
128+
200: '#fde68a',
129+
300: '#fcd34d',
130+
400: '#fbbf24',
131+
500: '#f59e0b',
132+
600: '#d97706',
133+
700: '#b45309',
134+
800: '#92400e',
135+
900: '#78350f',
136+
950: '#451a03',
137+
},
138+
yellow: {
139+
50: '#fefce8',
140+
100: '#fef9c3',
141+
200: '#fef08a',
142+
300: '#fde047',
143+
400: '#facc15',
144+
500: '#eab308',
145+
600: '#ca8a04',
146+
700: '#a16207',
147+
800: '#854d0e',
148+
900: '#713f12',
149+
950: '#422006',
150+
},
151+
lime: {
152+
50: '#f7fee7',
153+
100: '#ecfccb',
154+
200: '#d9f99d',
155+
300: '#bef264',
156+
400: '#a3e635',
157+
500: '#84cc16',
158+
600: '#65a30d',
159+
700: '#4d7c0f',
160+
800: '#3f6212',
161+
900: '#365314',
162+
950: '#1a2e05',
163+
},
164+
green: {
165+
50: '#f0fdf4',
166+
100: '#dcfce7',
167+
200: '#bbf7d0',
168+
300: '#86efac',
169+
400: '#4ade80',
170+
500: '#22c55e',
171+
600: '#16a34a',
172+
700: '#15803d',
173+
800: '#166534',
174+
900: '#14532d',
175+
950: '#052e16',
176+
},
177+
emerald: {
178+
50: '#ecfdf5',
179+
100: '#d1fae5',
180+
200: '#a7f3d0',
181+
300: '#6ee7b7',
182+
400: '#34d399',
183+
500: '#10b981',
184+
600: '#059669',
185+
700: '#047857',
186+
800: '#065f46',
187+
900: '#064e3b',
188+
950: '#022c22',
189+
},
190+
teal: {
191+
50: '#f0fdfa',
192+
100: '#ccfbf1',
193+
200: '#99f6e4',
194+
300: '#5eead4',
195+
400: '#2dd4bf',
196+
500: '#14b8a6',
197+
600: '#0d9488',
198+
700: '#0f766e',
199+
800: '#115e59',
200+
900: '#134e4a',
201+
950: '#042f2e',
202+
},
203+
cyan: {
204+
50: '#ecfeff',
205+
100: '#cffafe',
206+
200: '#a5f3fc',
207+
300: '#67e8f9',
208+
400: '#22d3ee',
209+
500: '#06b6d4',
210+
600: '#0891b2',
211+
700: '#0e7490',
212+
800: '#155e75',
213+
900: '#164e63',
214+
950: '#083344',
215+
},
216+
sky: {
217+
50: '#f0f9ff',
218+
100: '#e0f2fe',
219+
200: '#bae6fd',
220+
300: '#7dd3fc',
221+
400: '#38bdf8',
222+
500: '#0ea5e9',
223+
600: '#0284c7',
224+
700: '#0369a1',
225+
800: '#075985',
226+
900: '#0c4a6e',
227+
950: '#082f49',
228+
},
229+
blue: {
230+
50: '#eff6ff',
231+
100: '#dbeafe',
232+
200: '#bfdbfe',
233+
300: '#93c5fd',
234+
400: '#60a5fa',
235+
500: '#3b82f6',
236+
600: '#2563eb',
237+
700: '#1d4ed8',
238+
800: '#1e40af',
239+
900: '#1e3a8a',
240+
950: '#172554',
241+
},
242+
indigo: {
243+
50: '#eef2ff',
244+
100: '#e0e7ff',
245+
200: '#c7d2fe',
246+
300: '#a5b4fc',
247+
400: '#818cf8',
248+
500: '#6366f1',
249+
600: '#4f46e5',
250+
700: '#4338ca',
251+
800: '#3730a3',
252+
900: '#312e81',
253+
950: '#1e1b4b',
254+
},
255+
violet: {
256+
50: '#f5f3ff',
257+
100: '#ede9fe',
258+
200: '#ddd6fe',
259+
300: '#c4b5fd',
260+
400: '#a78bfa',
261+
500: '#8b5cf6',
262+
600: '#7c3aed',
263+
700: '#6d28d9',
264+
800: '#5b21b6',
265+
900: '#4c1d95',
266+
950: '#2e1065',
267+
},
268+
purple: {
269+
50: '#faf5ff',
270+
100: '#f3e8ff',
271+
200: '#e9d5ff',
272+
300: '#d8b4fe',
273+
400: '#c084fc',
274+
500: '#a855f7',
275+
600: '#9333ea',
276+
700: '#7e22ce',
277+
800: '#6b21a8',
278+
900: '#581c87',
279+
950: '#3b0764',
280+
},
281+
fuchsia: {
282+
50: '#fdf4ff',
283+
100: '#fae8ff',
284+
200: '#f5d0fe',
285+
300: '#f0abfc',
286+
400: '#e879f9',
287+
500: '#d946ef',
288+
600: '#c026d3',
289+
700: '#a21caf',
290+
800: '#86198f',
291+
900: '#701a75',
292+
950: '#4a044e',
293+
},
294+
pink: {
295+
50: '#fdf2f8',
296+
100: '#fce7f3',
297+
200: '#fbcfe8',
298+
300: '#f9a8d4',
299+
400: '#f472b6',
300+
500: '#ec4899',
301+
600: '#db2777',
302+
700: '#be185d',
303+
800: '#9d174d',
304+
900: '#831843',
305+
950: '#500724',
306+
},
307+
rose: {
308+
50: '#fff1f2',
309+
100: '#ffe4e6',
310+
200: '#fecdd3',
311+
300: '#fda4af',
312+
400: '#fb7185',
313+
500: '#f43f5e',
314+
600: '#e11d48',
315+
700: '#be123c',
316+
800: '#9f1239',
317+
900: '#881337',
318+
950: '#4c0519',
319+
},
320+
};

0 commit comments

Comments
 (0)