Skip to content

Commit 5ffe28d

Browse files
authored
refactor: origin colors again (#1175)
* refactor: origin colors again * fix: issue with on-origin-dark * fix: issue with pressed color
1 parent c004372 commit 5ffe28d

File tree

6 files changed

+441
-304
lines changed

6 files changed

+441
-304
lines changed

src/components/Customization/Settings/ColorSelection/ColorInputs/color-inputs.tsx

+30-16
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,41 @@ const ColorInputs = ({
1313
onColorChange,
1414
error,
1515
alternative,
16-
contrasts,
16+
contrastGroups,
1717
}: ColorInputsType) => {
1818
const { t } = useTranslation();
1919
return (
2020
<>
2121
<DBDivider />
22-
<p className="font-bold">{name}</p>
23-
<div className="flex flex-wrap gap-fix-sm">
24-
{contrasts?.map((contrast, index) => (
25-
<DBInfotext
26-
key={`${name}-contrast-${index}`}
27-
semantic={
28-
contrast.value < (contrast.min ?? 3) ? "critical" : "successful"
29-
}
30-
size="small"
31-
>
32-
{contrast.name ? `${contrast.name}: ` : ""}
33-
{contrast.value.toFixed(2)}:1
34-
</DBInfotext>
35-
))}
36-
</div>
22+
<span className="font-bold">{name}</span>
23+
{contrastGroups?.map((contrastGroup, indexGroup) => (
24+
<div
25+
className="flex flex-col gap-fix-2xs"
26+
key={`${name}-contrast-group-${indexGroup}`}
27+
>
28+
{contrastGroup.groupName && (
29+
<small className="text-adaptive-on-basic-emphasis-80-default">
30+
{contrastGroup.groupName}
31+
</small>
32+
)}
33+
<div className="flex flex-wrap gap-fix-sm">
34+
{contrastGroup.contrasts.map((contrast, index) => (
35+
<DBInfotext
36+
key={`${name}-contrast-${index}`}
37+
semantic={
38+
contrast.value < (contrast.min ?? 3)
39+
? "critical"
40+
: "successful"
41+
}
42+
size="small"
43+
>
44+
{contrast.name ? `${contrast.name}: ` : ""}
45+
{contrast.value.toFixed(2)}:1
46+
</DBInfotext>
47+
))}
48+
</div>
49+
</div>
50+
))}
3751
<div className="grid grid-cols-2 gap-fix-md">
3852
<DBInput
3953
label={t("colorInputPicker")}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
export type ContrastType = {
2+
value: number;
3+
min?: number;
4+
name?: string;
5+
};
6+
17
export type ColorInputsType = {
28
name: string;
39
color: string;
410
onColorChange: (color: string) => void;
511
error?: string;
612
alternative?: string;
7-
contrasts?: { value: number; min?: number; name?: string }[];
13+
contrastGroups?: { groupName?: string; contrasts: ContrastType[] }[];
814
};

0 commit comments

Comments
 (0)