Skip to content

Commit 37a11e6

Browse files
committed
chore: predefined color classes to ensure Tailwind compilation
1 parent 207a750 commit 37a11e6

File tree

1 file changed

+36
-8
lines changed

1 file changed

+36
-8
lines changed

src/components/ProductTable/PresetFilters.tsx

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,29 @@ const PresetFilters = ({
1717
showMobileSidebar = false,
1818
presetFilterCounts,
1919
}: PresetFiltersProps) => {
20-
const colors = ["primary", "accent-b", "accent-c", "accent-a", "[#BEBF3B]"]
20+
const colors = {
21+
text: [
22+
"text-primary",
23+
"text-accent-b",
24+
"text-accent-c",
25+
"text-accent-a",
26+
"text-[#BEBF3B]",
27+
],
28+
border: [
29+
"border-primary",
30+
"border-accent-b",
31+
"border-accent-c",
32+
"border-accent-a",
33+
"border-[#BEBF3B]",
34+
],
35+
bg: [
36+
"bg-primary",
37+
"bg-accent-b",
38+
"bg-accent-c",
39+
"bg-accent-a",
40+
"bg-[#BEBF3B]",
41+
],
42+
}
2143

2244
return (
2345
<div>
@@ -29,7 +51,7 @@ const PresetFilters = ({
2951
}`}
3052
>
3153
{presets.map((preset, idx) => {
32-
const color = colors[idx]
54+
const colorIdx = colors.text[idx] ? idx : idx % colors.text.length
3355
return (
3456
<div
3557
key={idx}
@@ -48,8 +70,9 @@ const PresetFilters = ({
4870
<div className="items-top flex gap-2 px-1.5">
4971
<div
5072
className={cn(
51-
`relative mt-1 flex h-5 w-5 shrink-0 items-center justify-center rounded border-2 border-${color}`,
52-
activePresets.includes(idx) && `bg-${color}`
73+
"relative mt-1 flex h-5 w-5 shrink-0 items-center justify-center rounded border-2",
74+
colors.border[colorIdx],
75+
activePresets.includes(idx) && colors.bg[colorIdx]
5376
)}
5477
>
5578
{activePresets.includes(idx) && (
@@ -68,12 +91,17 @@ const PresetFilters = ({
6891
)}
6992
</div>
7093
<h3
71-
className={`duration-50 hyphens-auto text-left text-xl text-${color} transition-all`}
94+
className={cn(
95+
"duration-50 hyphens-auto text-left text-xl transition-all",
96+
colors.text[colorIdx]
97+
)}
7298
>
7399
{preset.title}{" "}
74-
<span className="font-normal">
75-
({presetFilterCounts?.[idx]})
76-
</span>
100+
{presetFilterCounts?.[idx] && (
101+
<span className="font-normal">
102+
({presetFilterCounts[idx]})
103+
</span>
104+
)}
77105
</h3>
78106
</div>
79107
{!showMobileSidebar && (

0 commit comments

Comments
 (0)