Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/components/screens/settings/UiPreferencesSettingsPage.tsx
T

87 lines
3.2 KiB
TypeScript

import { useTranslation } from "react-i18next";
import type { UiPreferences } from "~/components/app/UiPreferencesContext";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Card } from "~/ui/components/Card";
import { Switch } from "~/ui/components/Switch";
import { PageBody, PageIntro, PageShell } from "../shared/PageShell";
export type UiPreferencesSettingsPageProps = {
preferences: UiPreferences;
actions: {
onSetAutoCollapseSidebar: (enabled: boolean) => void;
onSetVisualEffectsEnabled: (enabled: boolean) => void;
};
};
export function UiPreferencesSettingsPage({ preferences, actions }: UiPreferencesSettingsPageProps): React.JSX.Element {
const { t } = useTranslation();
return (
<PageShell uiId="ui.settings.appearance.page">
<PageBody>
<div className="flex w-full justify-center">
<div className="flex w-full max-w-3xl flex-col gap-6">
<PageIntro uiId="ui.settings.appearance.intro">{t("settings.appearance.description")}</PageIntro>
<div className="flex w-full flex-col gap-4">
<PreferenceCard
title={t("settings.appearance.autoCollapse.title")}
description={t("settings.appearance.autoCollapse.description")}
checked={preferences.autoCollapseSidebar}
onCheckedChange={actions.onSetAutoCollapseSidebar}
uiId="ui.settings.appearance.autoCollapse"
badge={t("settings.appearance.recommended")}
/>
<PreferenceCard
title={t("settings.appearance.effects.title")}
description={t("settings.appearance.effects.description")}
checked={preferences.visualEffectsEnabled}
onCheckedChange={actions.onSetVisualEffectsEnabled}
uiId="ui.settings.appearance.effects"
/>
</div>
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
{t("settings.appearance.browserHint")}
</p>
</div>
</div>
</PageBody>
</PageShell>
);
}
function PreferenceCard({
title,
description,
checked,
onCheckedChange,
uiId,
badge,
}: {
title: string;
description: string;
checked: boolean;
onCheckedChange: (enabled: boolean) => void;
uiId: string;
badge?: string;
}): React.JSX.Element {
return (
<Card className="flex-row flex-wrap items-center justify-between gap-4" data-ui-id={uiId}>
<div className="flex min-w-0 grow basis-80 flex-col gap-1">
<div className="flex flex-wrap items-center gap-2">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{title}</span>
{badge ? (
<BadgeFeedback farbe="subtle-brand-primary" size="small">
{badge}
</BadgeFeedback>
) : null}
</div>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{description}</span>
</div>
<Switch checked={checked} onCheckedChange={onCheckedChange} aria-label={title} data-ui-id={`${uiId}.switch`} />
</Card>
);
}