hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import { IconSearch } from "@/components/ui/icons"; |
| 2 | import { cn } from "@/lib/cn"; |
| 3 | import { openCommandPalette } from "@/stores/command-palette"; |
| 4 | import { useAuth } from "@/stores/auth-context"; |
| 5 | import { useT } from "@/stores/preferences-context"; |
| 6 | |
| 7 | /** The home page's search field: the one visible door into the command |
| 8 | * palette now that the topbar no longer carries it (Ctrl/Cmd K still works). */ |
| 9 | export function CommandSearchField(props: { class?: string }) { |
| 10 | const t = useT(); |
| 11 | const auth = useAuth(); |
| 12 | const placeholder = () => |
| 13 | auth.user()?.role === "admin" ? t("dashboard.hero.searchPlaceholderAdmin") : t("dashboard.hero.searchPlaceholderAll"); |
| 14 | |
| 15 | return ( |
| 16 | <button |
| 17 | type="button" |
| 18 | onClick={openCommandPalette} |
| 19 | class={cn( |
| 20 | "group flex h-[46px] w-full max-w-xl items-center gap-3 rounded-lg border border-border-line bg-surface-base pl-4 pr-2 text-left text-sm shadow-sm outline-hidden transition-colors hover:border-primary/40 focus-visible:ring-2 focus-visible:ring-ring", |
| 21 | props.class, |
| 22 | )} |
| 23 | aria-label={t("dashboard.commandCenter")} |
| 24 | > |
| 25 | <IconSearch class="h-4 w-4 shrink-0 text-text-subtle group-hover:text-primary-text" /> |
| 26 | <span class="min-w-0 flex-1 truncate text-text-placeholder">{placeholder()}</span> |
| 27 | <kbd class="hidden shrink-0 rounded-md border border-border/80 bg-background/80 px-1.5 py-0.5 font-mono text-[11px] font-semibold text-muted-foreground sm:inline-block"> |
| 28 | Ctrl/Cmd K |
| 29 | </kbd> |
| 30 | </button> |
| 31 | ); |
| 32 | } |