diff --git a/src/components/layout/user-menu.tsx b/src/components/layout/user-menu.tsx index 57487f5..69a9984 100644 --- a/src/components/layout/user-menu.tsx +++ b/src/components/layout/user-menu.tsx @@ -13,7 +13,7 @@ import { DropdownMenuSubTrigger, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; -import { IconChevronDown, IconEdit, IconGlobe, IconLogout, IconMoon, IconSun } from "@/components/ui/icons"; +import { IconChevronDown, IconGlobe, IconLogout, IconMoon, IconSettings, IconSun } from "@/components/ui/icons"; import { useAuth } from "@/stores/auth-context"; import { usePreferences, useT } from "@/stores/preferences-context"; import { cn } from "@/lib/cn"; @@ -180,8 +180,8 @@ export function UserMenu() { setProfileOpen(true)}> - - {t("profile.edit")} + + {t("nav.settings")} diff --git a/src/components/users/account-profile-dialog.tsx b/src/components/users/account-profile-dialog.tsx index fdc6ac8..b0a3968 100644 --- a/src/components/users/account-profile-dialog.tsx +++ b/src/components/users/account-profile-dialog.tsx @@ -1,25 +1,145 @@ -import { Show } from "solid-js"; -import { FormDialog } from "@/components/ui/form-dialog"; +import { For, Match, Show, Switch, createSignal, type JSX } from "solid-js"; +import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog"; +import { IconCheck, IconSparkles, IconUserCog } from "@/components/ui/icons"; import { ProfileForm } from "@/components/users/profile-form"; +import { cn } from "@/lib/cn"; +import { TRENDING_PALETTES } from "@/lib/palettes"; import { useAuth } from "@/stores/auth-context"; -import { useT } from "@/stores/preferences-context"; +import { usePreferences, useT } from "@/stores/preferences-context"; +type Section = "account" | "appearance"; + +/** + * Per-user settings, opened from the avatar menu. A left section rail (account + * profile · appearance) with the matching panel on the right — appearance + * gathers theme, language and accent colour, all personal browser preferences. + */ export function AccountProfileDialog(props: { open: boolean; onOpenChange: (open: boolean) => void }) { const auth = useAuth(); + const prefs = usePreferences(); const t = useT(); + const [section, setSection] = createSignal
("account"); + + const navItem = (id: Section, label: string, icon: JSX.Element) => ( + + ); + + const seg = (active: boolean, label: string, onClick: () => void) => ( + + ); return ( {(user) => ( - - { - await auth.refresh(); - props.onOpenChange(false); - }} - /> - + + +
+ + +
+ + + { + await auth.refresh(); + props.onOpenChange(false); + }} + /> + + + +
+
+

{t("theme.toggle")}

+
+ {seg(prefs.theme() === "light", t("theme.light"), () => prefs.setTheme("light"))} + {seg(prefs.theme() === "dark", t("theme.dark"), () => prefs.setTheme("dark"))} +
+
+ +
+

{t("lang.label")}

+
+ {seg(prefs.locale() === "tr", t("lang.tr"), () => prefs.setLocale("tr"))} + {seg(prefs.locale() === "en", t("lang.en"), () => prefs.setLocale("en"))} +
+
+ +
+

{t("settings.colorPalette")}

+

{t("settings.colorPaletteHelp")}

+
+ + {(palette) => ( +
+
+ + {(color) => ( + + )} + +
+

{palette.name}

+
+ )} +
+
+ +
+
+
+
+
+
+
+
)}
); diff --git a/src/lib/palettes.ts b/src/lib/palettes.ts new file mode 100644 index 0000000..1d0f9b9 --- /dev/null +++ b/src/lib/palettes.ts @@ -0,0 +1,10 @@ +// Accent palettes offered in the per-user appearance picker (account menu). +// A user picks one accent hex; `preferences-context` turns it into CSS vars. +export const TRENDING_PALETTES = [ + { name: "Sunny Beach Day", colors: ["#264653", "#2a9d8f", "#e9c46a", "#f4a261", "#e76f51"] }, + { name: "Olive Garden Feast", colors: ["#606c38", "#283618", "#fefae0", "#dda15e", "#bc6c25"] }, + { name: "Summer Ocean Breeze", colors: ["#e63946", "#f1faee", "#a8dadc", "#457b9d", "#1d3557"] }, + { name: "Refreshing Summer Fun", colors: ["#8ecae6", "#219ebc", "#023047", "#ffb703", "#fb8500"] }, + { name: "Pastel Dreamland Adventure", colors: ["#cdb4db", "#ffc8dd", "#ffafcc", "#bde0fe", "#a2d2ff"] }, + { name: "Golden Summer Fields", colors: ["#ccd5ae", "#e9edc9", "#fefae0", "#faedcd", "#d4a373"] }, +] as const; diff --git a/src/pages/settings-page.tsx b/src/pages/settings-page.tsx index 2b7161c..4018b60 100644 --- a/src/pages/settings-page.tsx +++ b/src/pages/settings-page.tsx @@ -1,4 +1,4 @@ -import { For, Index, Show, Suspense, createEffect, createResource, createSignal } from "solid-js"; +import { Index, Show, Suspense, createEffect, createResource, createSignal } from "solid-js"; import { getSettings } from "@/api/settings"; import { patchSettings } from "@/api/settings"; import { getLimits } from "@/api/limits"; @@ -10,7 +10,7 @@ import { Alert } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { ErrorAlert } from "@/components/ui/error-alert"; -import { IconCheck, IconPlus, IconTrash } from "@/components/ui/icons"; +import { IconPlus, IconTrash } from "@/components/ui/icons"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { PageSpinner } from "@/components/ui/page-spinner"; @@ -18,7 +18,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { getAttendanceStatusMeta } from "@/lib/attendance-status"; import { cn } from "@/lib/cn"; import { dirtySettingsPatch, minuteToUtcTime, utcTimeToMinute } from "@/lib/meals"; -import { usePreferences, useT } from "@/stores/preferences-context"; +import { useT } from "@/stores/preferences-context"; const CORE_ATTENDANCE = new Set(["present", "absent", "late", "excused"]); const CORE_ATTENDANCE_LABELS = { @@ -29,14 +29,6 @@ const CORE_ATTENDANCE_LABELS = { } as const; const BYTES_PER_MIB = 1024 * 1024; -const TRENDING_PALETTES = [ - { name: "Sunny Beach Day", colors: ["#264653", "#2a9d8f", "#e9c46a", "#f4a261", "#e76f51"] }, - { name: "Olive Garden Feast", colors: ["#606c38", "#283618", "#fefae0", "#dda15e", "#bc6c25"] }, - { name: "Summer Ocean Breeze", colors: ["#e63946", "#f1faee", "#a8dadc", "#457b9d", "#1d3557"] }, - { name: "Refreshing Summer Fun", colors: ["#8ecae6", "#219ebc", "#023047", "#ffb703", "#fb8500"] }, - { name: "Pastel Dreamland Adventure", colors: ["#cdb4db", "#ffc8dd", "#ffafcc", "#bde0fe", "#a2d2ff"] }, - { name: "Golden Summer Fields", colors: ["#ccd5ae", "#e9edc9", "#fefae0", "#faedcd", "#d4a373"] }, -] as const; // Neutralize the Tabs.Content card so it is just a container — the sections // inside already carry their own `data-shell` surfaces. @@ -56,7 +48,6 @@ export default function SettingsPage() { function SettingsContent() { const t = useT(); - const preferences = usePreferences(); const [settings, { refetch, mutate }] = createResource(() => getSettings()); const [examKinds, setExamKinds] = createSignal([]); const [attendanceStatuses, setAttendanceStatuses] = createSignal([]); @@ -187,7 +178,6 @@ function SettingsContent() { {t("settings.tabAssessment")} {t("settings.tabMeals")} {t("settings.tabSystem")} - {t("settings.tabAppearance")} }> @@ -590,57 +580,6 @@ function SettingsContent() { - - -
-
-

{t("settings.colorPalette")}

-

{t("settings.colorPaletteHelp")}

-
- -
- - {(palette) => ( -
-
- - {(color) => ( - - )} - -
-

{palette.name}

-
- )} -
-
- - -
-
);