Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: origin colors again #1175

Merged
merged 3 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,41 @@ const ColorInputs = ({
onColorChange,
error,
alternative,
contrasts,
contrastGroups,
}: ColorInputsType) => {
const { t } = useTranslation();
return (
<>
<DBDivider />
<p className="font-bold">{name}</p>
<div className="flex flex-wrap gap-fix-sm">
{contrasts?.map((contrast, index) => (
<DBInfotext
key={`${name}-contrast-${index}`}
semantic={
contrast.value < (contrast.min ?? 3) ? "critical" : "successful"
}
size="small"
>
{contrast.name ? `${contrast.name}: ` : ""}
{contrast.value.toFixed(2)}:1
</DBInfotext>
))}
</div>
<span className="font-bold">{name}</span>
{contrastGroups?.map((contrastGroup, indexGroup) => (
<div
className="flex flex-col gap-fix-2xs"
key={`${name}-contrast-group-${indexGroup}`}
>
{contrastGroup.groupName && (
<small className="text-adaptive-on-basic-emphasis-80-default">
{contrastGroup.groupName}
</small>
)}
<div className="flex flex-wrap gap-fix-sm">
{contrastGroup.contrasts.map((contrast, index) => (
<DBInfotext
key={`${name}-contrast-${index}`}
semantic={
contrast.value < (contrast.min ?? 3)
? "critical"
: "successful"
}
size="small"
>
{contrast.name ? `${contrast.name}: ` : ""}
{contrast.value.toFixed(2)}:1
</DBInfotext>
))}
</div>
</div>
))}
<div className="grid grid-cols-2 gap-fix-md">
<DBInput
label={t("colorInputPicker")}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
export type ContrastType = {
value: number;
min?: number;
name?: string;
};

export type ColorInputsType = {
name: string;
color: string;
onColorChange: (color: string) => void;
error?: string;
alternative?: string;
contrasts?: { value: number; min?: number; name?: string }[];
contrastGroups?: { groupName?: string; contrasts: ContrastType[] }[];
};
Loading
Loading