💄 Sidebar styling, avatar minimalism, user search focus fix
Browse files at this commit3d3511a246b63582b93db94295dd6fa1b4f647dbParent: 944aa14- fix
- 💄 Sidebar styling, avatar minimalism, user search focus fix
4 changed files +67 -45
- src/components/layout/app-shell.tsx +2 -2
- src/components/layout/side-nav.tsx +6 -6
- src/components/layout/sidebar-account.tsx +15 -12
- src/components/users/user-search-select.tsx +44 -25
src/components/layout/app-shell.tsxmodified+2 -2
| @@ -55,7 +55,7 @@ export function AppShell(props: ParentProps) { | |||
| 55 | <div | 55 | <div |
| 56 | class={cn( | 56 | class={cn( |
| 57 | "flex h-16 shrink-0 items-center gap-2 border-b border-border/70", | 57 | "flex h-16 shrink-0 items-center gap-2 border-b border-border/70", |
| 58 | - collapsed() ? "justify-center px-2" : "px-3", | 58 | + collapsed() ? "justify-center px-2" : "px-2", |
| 59 | )} | 59 | )} |
| 60 | > | 60 | > |
| 61 | <Link to="/" class={cn("flex min-w-0 flex-1 items-center gap-2", collapsed() && "hidden")}> | 61 | <Link to="/" class={cn("flex min-w-0 flex-1 items-center gap-2", collapsed() && "hidden")}> |
| @@ -82,7 +82,7 @@ export function AppShell(props: ParentProps) { | |||
| 82 | </Button> | 82 | </Button> |
| 83 | </div> | 83 | </div> |
| 84 | 84 | ||
| 85 | - <div class="min-h-0 flex-1 overflow-y-auto overflow-x-hidden py-4"> | 85 | + <div class="min-h-0 flex-1 overflow-y-auto overflow-x-hidden pt-4 pb-1"> |
| 86 | <SideNav collapsed={collapsed()} /> | 86 | <SideNav collapsed={collapsed()} /> |
| 87 | </div> | 87 | </div> |
| 88 | 88 | ||
src/components/layout/side-nav.tsxmodified+6 -6
| @@ -63,9 +63,9 @@ function NavLink(props: { | |||
| 63 | title={t(props.item.labelKey)} | 63 | title={t(props.item.labelKey)} |
| 64 | aria-current={active() ? "page" : undefined} | 64 | aria-current={active() ? "page" : undefined} |
| 65 | class={cn( | 65 | class={cn( |
| 66 | - "group relative flex h-10 w-full items-center rounded-xl text-sm font-medium outline-none", | 66 | + "relative flex h-10 w-full items-center rounded-md text-sm font-medium outline-none", |
| 67 | "transition-all duration-150", | 67 | "transition-all duration-150", |
| 68 | - props.collapsed ? "justify-center px-0" : "gap-2 px-2", | 68 | + props.collapsed ? "justify-center px-0" : "gap-1.5 px-2", |
| 69 | active() | 69 | active() |
| 70 | ? "bg-primary/10 text-primary shadow-sm ring-1 ring-primary/20" | 70 | ? "bg-primary/10 text-primary shadow-sm ring-1 ring-primary/20" |
| 71 | : "text-sidebar-foreground/75 hover:bg-muted/70 hover:text-foreground", | 71 | : "text-sidebar-foreground/75 hover:bg-muted/70 hover:text-foreground", |
| @@ -76,8 +76,8 @@ function NavLink(props: { | |||
| 76 | </Show> | 76 | </Show> |
| 77 | <span | 77 | <span |
| 78 | class={cn( | 78 | class={cn( |
| 79 | - "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition-colors", | 79 | + "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md transition-colors", |
| 80 | - active() ? "bg-primary text-primary-foreground shadow-sm" : "text-muted-foreground group-hover:bg-background/60 group-hover:text-foreground", | 80 | + active() ? "text-primary" : "text-muted-foreground", |
| 81 | )} | 81 | )} |
| 82 | > | 82 | > |
| 83 | <props.item.Icon class="h-4 w-4" /> | 83 | <props.item.Icon class="h-4 w-4" /> |
| @@ -105,7 +105,7 @@ export function SideNav(props: { onNavigate?: () => void; collapsed?: boolean }) | |||
| 105 | 105 | ||
| 106 | return ( | 106 | return ( |
| 107 | <nav class="flex h-full flex-col" aria-label="Main"> | 107 | <nav class="flex h-full flex-col" aria-label="Main"> |
| 108 | - <div class="flex flex-col gap-1 px-2"> | 108 | + <div class="flex flex-col gap-0.5 px-2"> |
| 109 | <For each={items()}> | 109 | <For each={items()}> |
| 110 | {(item, index) => ( | 110 | {(item, index) => ( |
| 111 | <> | 111 | <> |
| @@ -133,7 +133,7 @@ export function SideNav(props: { onNavigate?: () => void; collapsed?: boolean }) | |||
| 133 | </For> | 133 | </For> |
| 134 | </div> | 134 | </div> |
| 135 | 135 | ||
| 136 | - <div class="mt-auto border-t border-border px-2 py-1.5"> | 136 | + <div class="mt-auto border-t border-border px-2 py-1"> |
| 137 | <NavLink item={GUIDE_ITEM} collapsed={props.collapsed} onNavigate={props.onNavigate} /> | 137 | <NavLink item={GUIDE_ITEM} collapsed={props.collapsed} onNavigate={props.onNavigate} /> |
| 138 | </div> | 138 | </div> |
| 139 | </nav> | 139 | </nav> |
src/components/layout/sidebar-account.tsxmodified+15 -12
| @@ -36,46 +36,49 @@ export function SidebarAccount(props: { collapsed?: boolean; onLogout: () => voi | |||
| 36 | {(u) => { | 36 | {(u) => { |
| 37 | const name = () => displayName(u()); | 37 | const name = () => displayName(u()); |
| 38 | return ( | 38 | return ( |
| 39 | - <div class={cn("shrink-0 border-t border-border/80 p-3", props.collapsed && "px-2")}> | 39 | + <div class={cn("shrink-0 border-t border-border/80 p-2 pb-1.5", props.collapsed && "px-2")}> |
| 40 | <DropdownMenu placement="right-end" gutter={8}> | 40 | <DropdownMenu placement="right-end" gutter={8}> |
| 41 | <DropdownMenuTrigger | 41 | <DropdownMenuTrigger |
| 42 | class={cn( | 42 | class={cn( |
| 43 | - "flex w-full items-center rounded-xl border border-border/80 bg-muted/35 text-left outline-none transition-colors", | 43 | + "flex w-full items-center rounded-md text-left outline-none transition-colors", |
| 44 | - "hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring data-[expanded]:bg-muted/70", | 44 | + "hover:bg-muted/70 focus-visible:ring-2 focus-visible:ring-ring data-[expanded]:bg-muted/70", |
| 45 | - props.collapsed ? "h-11 justify-center px-0" : "gap-3 p-2", | 45 | + props.collapsed ? "h-9 justify-center px-0" : "gap-1.5 px-2", |
| 46 | + props.collapsed ? "" : "h-10", | ||
| 46 | )} | 47 | )} |
| 47 | aria-label={t("nav.account")} | 48 | aria-label={t("nav.account")} |
| 48 | > | 49 | > |
| 49 | - <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-primary text-xs font-bold text-primary-foreground"> | 50 | + <span class="flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-[11px] font-bold text-primary-foreground"> |
| 50 | {initials(name())} | 51 | {initials(name())} |
| 51 | </span> | 52 | </span> |
| 52 | <Show when={!props.collapsed}> | 53 | <Show when={!props.collapsed}> |
| 53 | <span class="min-w-0 flex-1"> | 54 | <span class="min-w-0 flex-1"> |
| 54 | <span class="block truncate text-sm font-semibold">{name()}</span> | 55 | <span class="block truncate text-sm font-semibold">{name()}</span> |
| 55 | - <span class="block truncate text-xs text-muted-foreground">{t(`role.${u().role}` as MessageKey)}</span> | 56 | + <span class="block text-[10px] text-muted-foreground">{t(`role.${u().role}` as MessageKey)}</span> |
| 56 | </span> | 57 | </span> |
| 57 | - <IconChevronRight class="h-4 w-4 text-muted-foreground" /> | 58 | + <IconChevronRight class="h-4 w-4 shrink-0 text-muted-foreground transition-transform data-[expanded]:rotate-90" /> |
| 58 | </Show> | 59 | </Show> |
| 59 | </DropdownMenuTrigger> | 60 | </DropdownMenuTrigger> |
| 60 | 61 | ||
| 61 | - <DropdownMenuContent class="w-52 rounded-xl border-border/80 bg-popover p-1.5 shadow-soft"> | 62 | + <DropdownMenuContent class="w-52 rounded-lg border-border/80 bg-popover p-1 shadow-soft"> |
| 62 | - <DropdownMenuItem class="rounded-lg" onSelect={() => void navigate({ to: "/profile" })}> | 63 | + <DropdownMenuItem class="rounded-md" onSelect={() => void navigate({ to: "/profile" })}> |
| 64 | + <IconChevronRight class="h-4 w-4 shrink-0" /> | ||
| 63 | <span>{t("profile.edit")}</span> | 65 | <span>{t("profile.edit")}</span> |
| 64 | </DropdownMenuItem> | 66 | </DropdownMenuItem> |
| 65 | - <DropdownMenuItem class="rounded-lg" onSelect={() => prefs.toggleTheme()}> | 67 | + <p class="px-2 text-center text-[10px] tracking-[0.2em] text-muted-foreground/40 select-none">······</p> |
| 68 | + <DropdownMenuItem class="rounded-md" onSelect={() => prefs.toggleTheme()}> | ||
| 66 | <Show when={prefs.theme() === "dark"} fallback={<IconSun class="h-4 w-4 shrink-0" />}> | 69 | <Show when={prefs.theme() === "dark"} fallback={<IconSun class="h-4 w-4 shrink-0" />}> |
| 67 | <IconMoon class="h-4 w-4 shrink-0" /> | 70 | <IconMoon class="h-4 w-4 shrink-0" /> |
| 68 | </Show> | 71 | </Show> |
| 69 | <span class="min-w-0 flex-1">{t("theme.toggle")}</span> | 72 | <span class="min-w-0 flex-1">{t("theme.toggle")}</span> |
| 70 | <span class="text-xs text-muted-foreground">{prefs.theme() === "dark" ? t("theme.dark") : t("theme.light")}</span> | 73 | <span class="text-xs text-muted-foreground">{prefs.theme() === "dark" ? t("theme.dark") : t("theme.light")}</span> |
| 71 | </DropdownMenuItem> | 74 | </DropdownMenuItem> |
| 72 | - <DropdownMenuItem class="rounded-lg" onSelect={() => prefs.setLocale(prefs.locale() === "tr" ? "en" : "tr")}> | 75 | + <DropdownMenuItem class="rounded-md" onSelect={() => prefs.setLocale(prefs.locale() === "tr" ? "en" : "tr")}> |
| 73 | <IconGlobe class="h-4 w-4 shrink-0" /> | 76 | <IconGlobe class="h-4 w-4 shrink-0" /> |
| 74 | <span class="min-w-0 flex-1">{t("lang.label")}</span> | 77 | <span class="min-w-0 flex-1">{t("lang.label")}</span> |
| 75 | <span class="text-xs text-muted-foreground">{prefs.locale() === "tr" ? "TR" : "EN"}</span> | 78 | <span class="text-xs text-muted-foreground">{prefs.locale() === "tr" ? "TR" : "EN"}</span> |
| 76 | </DropdownMenuItem> | 79 | </DropdownMenuItem> |
| 77 | <DropdownMenuSeparator /> | 80 | <DropdownMenuSeparator /> |
| 78 | - <DropdownMenuItem destructive class="rounded-lg" onSelect={() => void props.onLogout()}> | 81 | + <DropdownMenuItem destructive class="rounded-md" onSelect={() => void props.onLogout()}> |
| 79 | <IconLogout class="h-4 w-4 shrink-0" /> | 82 | <IconLogout class="h-4 w-4 shrink-0" /> |
| 80 | <span>{t("nav.logout")}</span> | 83 | <span>{t("nav.logout")}</span> |
| 81 | </DropdownMenuItem> | 84 | </DropdownMenuItem> |
src/components/users/user-search-select.tsxmodified+44 -25
| @@ -1,4 +1,4 @@ | |||
| 1 | -import { For, Show, createEffect, createMemo, createResource, createSignal } from "solid-js"; | 1 | +import { For, Show, createEffect, createMemo, createSignal } from "solid-js"; |
| 2 | import { getUserSearch } from "@/api/getUserSearch"; | 2 | import { getUserSearch } from "@/api/getUserSearch"; |
| 3 | import type { PersonRef } from "@/api/types"; | 3 | import type { PersonRef } from "@/api/types"; |
| 4 | import { Input } from "@/components/ui/input"; | 4 | import { Input } from "@/components/ui/input"; |
| @@ -26,38 +26,51 @@ export function UserSearchSelect(props: { | |||
| 26 | const [open, setOpen] = createSignal(false); | 26 | const [open, setOpen] = createSignal(false); |
| 27 | const [selectedUser, setSelectedUser] = createSignal<PersonRef | null>(null); | 27 | const [selectedUser, setSelectedUser] = createSignal<PersonRef | null>(null); |
| 28 | const [lastSelectedLabel, setLastSelectedLabel] = createSignal(""); | 28 | const [lastSelectedLabel, setLastSelectedLabel] = createSignal(""); |
| 29 | - const search = createMemo(() => { | 29 | + const [users, setUsers] = createSignal<PersonRef[]>([]); |
| 30 | - const q = query().trim(); | 30 | + const [loading, setLoading] = createSignal(false); |
| 31 | - if (q.length === 0) return null; | ||
| 32 | - return q; | ||
| 33 | - }); | ||
| 34 | - const [users] = createResource(search, async (source) => { | ||
| 35 | - if (!source) return []; | ||
| 36 | - return getUserSearch(source); | ||
| 37 | - }); | ||
| 38 | const options = createMemo(() => { | 31 | const options = createMemo(() => { |
| 39 | const excluded = new Set(props.excludeIds ?? []); | 32 | const excluded = new Set(props.excludeIds ?? []); |
| 40 | - return (users() ?? []).filter((user) => !excluded.has(user.id)).slice(0, MAX_VISIBLE_RESULTS); | 33 | + return users().filter((user) => !excluded.has(user.id)).slice(0, MAX_VISIBLE_RESULTS); |
| 41 | }); | 34 | }); |
| 42 | const showResults = createMemo(() => query().trim().length > 0 && options().length > 0); | 35 | const showResults = createMemo(() => query().trim().length > 0 && options().length > 0); |
| 43 | const dropdownOpen = createMemo(() => open() && showResults()); | 36 | const dropdownOpen = createMemo(() => open() && showResults()); |
| 44 | - const hasManualValue = createMemo(() => { | 37 | + const hintText = createMemo(() => { |
| 45 | - const value = props.value.trim(); | 38 | + const q = query().trim(); |
| 46 | - return props.allowManualValue && value.length > 0 && !options().some((user) => user.id === value); | 39 | + if (q.length === 0) return ""; |
| 47 | - }); | 40 | + if (loading()) return t("common.loading"); |
| 48 | - const hint = () => { | 41 | + if (props.value.trim() && !options().some((u) => u.id === props.value.trim())) return props.value; |
| 49 | - if (query().trim().length === 0) return ""; | ||
| 50 | - if (users.loading) return t("common.loading"); | ||
| 51 | - if (hasManualValue()) return props.value; | ||
| 52 | if (options().length === 0) return props.emptyMessage ?? t("form.noStudents"); | 42 | if (options().length === 0) return props.emptyMessage ?? t("form.noStudents"); |
| 53 | return ""; | 43 | return ""; |
| 54 | - }; | 44 | + }); |
| 45 | + | ||
| 46 | + let abortController: AbortController | null = null; | ||
| 47 | + createEffect(async () => { | ||
| 48 | + const q = query().trim(); | ||
| 49 | + if (abortController) abortController.abort(); | ||
| 50 | + if (q.length === 0) { | ||
| 51 | + setUsers([]); | ||
| 52 | + return; | ||
| 53 | + } | ||
| 54 | + abortController = new AbortController(); | ||
| 55 | + setLoading(true); | ||
| 56 | + try { | ||
| 57 | + const data = await getUserSearch(q, abortController.signal); | ||
| 58 | + setUsers(data); | ||
| 59 | + } catch { | ||
| 60 | + if (!abortController?.signal.aborted) setUsers([]); | ||
| 61 | + } finally { | ||
| 62 | + if (!abortController?.signal.aborted) setLoading(false); | ||
| 63 | + } | ||
| 64 | + }); | ||
| 55 | 65 | ||
| 56 | createEffect(() => { | 66 | createEffect(() => { |
| 57 | const value = props.value.trim(); | 67 | const value = props.value.trim(); |
| 58 | if (!value) { | 68 | if (!value) { |
| 59 | if (selectedUser()) setSelectedUser(null); | 69 | if (selectedUser()) setSelectedUser(null); |
| 60 | - if (query() === lastSelectedLabel()) setQuery(""); | 70 | + if (query() === lastSelectedLabel()) { |
| 71 | + setQuery(""); | ||
| 72 | + if (inputRef) inputRef.value = ""; | ||
| 73 | + } | ||
| 61 | setLastSelectedLabel(""); | 74 | setLastSelectedLabel(""); |
| 62 | return; | 75 | return; |
| 63 | } | 76 | } |
| @@ -69,7 +82,10 @@ export function UserSearchSelect(props: { | |||
| 69 | if (!match) return; | 82 | if (!match) return; |
| 70 | 83 | ||
| 71 | setSelectedUser(match); | 84 | setSelectedUser(match); |
| 72 | - setLastSelectedLabel(personLabelWithId(match)); | 85 | + const label = personLabelWithId(match); |
| 86 | + setLastSelectedLabel(label); | ||
| 87 | + setQuery(label); | ||
| 88 | + if (inputRef) inputRef.value = label; | ||
| 73 | }); | 89 | }); |
| 74 | 90 | ||
| 75 | const onInput = (value: string) => { | 91 | const onInput = (value: string) => { |
| @@ -95,6 +111,7 @@ export function UserSearchSelect(props: { | |||
| 95 | setQuery(label); | 111 | setQuery(label); |
| 96 | setOpen(false); | 112 | setOpen(false); |
| 97 | props.onChange(user.id); | 113 | props.onChange(user.id); |
| 114 | + if (inputRef) inputRef.value = label; | ||
| 98 | queueMicrotask(() => inputRef?.focus({ preventScroll: true })); | 115 | queueMicrotask(() => inputRef?.focus({ preventScroll: true })); |
| 99 | }; | 116 | }; |
| 100 | 117 | ||
| @@ -106,13 +123,15 @@ export function UserSearchSelect(props: { | |||
| 106 | <Input | 123 | <Input |
| 107 | ref={(el) => { | 124 | ref={(el) => { |
| 108 | inputRef = el; | 125 | inputRef = el; |
| 126 | + if (el && lastSelectedLabel() && !el.value) { | ||
| 127 | + el.value = lastSelectedLabel(); | ||
| 128 | + } | ||
| 109 | }} | 129 | }} |
| 110 | id={`${props.id}-query`} | 130 | id={`${props.id}-query`} |
| 111 | role="combobox" | 131 | role="combobox" |
| 112 | aria-expanded={dropdownOpen()} | 132 | aria-expanded={dropdownOpen()} |
| 113 | aria-controls={`${props.id}-results`} | 133 | aria-controls={`${props.id}-results`} |
| 114 | autocomplete="off" | 134 | autocomplete="off" |
| 115 | - value={query()} | ||
| 116 | disabled={props.disabled} | 135 | disabled={props.disabled} |
| 117 | placeholder={props.placeholder ?? props.selectPlaceholder ?? t("common.searchPlaceholder")} | 136 | placeholder={props.placeholder ?? props.selectPlaceholder ?? t("common.searchPlaceholder")} |
| 118 | onFocus={() => setOpen(query().trim().length > 0)} | 137 | onFocus={() => setOpen(query().trim().length > 0)} |
| @@ -145,8 +164,8 @@ export function UserSearchSelect(props: { | |||
| 145 | </ul> | 164 | </ul> |
| 146 | </div> | 165 | </div> |
| 147 | </Show> | 166 | </Show> |
| 148 | - <Show when={hint()}> | 167 | + <Show when={hintText()}> |
| 149 | - {(message) => <p class="text-xs text-muted-foreground">{message()}</p>} | 168 | + <p class="text-xs text-muted-foreground">{hintText()}</p> |
| 150 | </Show> | 169 | </Show> |
| 151 | </div> | 170 | </div> |
| 152 | ); | 171 | ); |