hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import { For } from "solid-js"; |
| 2 | import { Link, useRouterState } from "@tanstack/solid-router"; |
| 3 | import { IconMenu, IconSearch } from "@/components/ui/icons"; |
| 4 | import { primaryNavItems, primaryPathActive } from "@/components/layout/nav-items"; |
| 5 | import { cn } from "@/lib/cn"; |
| 6 | import { useAuth } from "@/stores/auth-context"; |
| 7 | import { useModules } from "@/stores/modules-context"; |
| 8 | import { useT } from "@/stores/preferences-context"; |
| 9 | |
| 10 | export function MobileTabBar(props: { onMenu: () => void; onSearch: () => void }) { |
| 11 | const auth = useAuth(); |
| 12 | const t = useT(); |
| 13 | const modules = useModules(); |
| 14 | const pathname = useRouterState({ select: (state) => state.location.pathname }); |
| 15 | const items = () => primaryNavItems(auth.user()?.role, modules.enabled()); |
| 16 | |
| 17 | return ( |
| 18 | <nav |
| 19 | class="fixed inset-x-0 bottom-0 z-40 border-t border-border/80 bg-background pb-[max(env(safe-area-inset-bottom),var(--android-nav-inset,0px))] lg:hidden" |
| 20 | aria-label={t("nav.menu")} |
| 21 | > |
| 22 | <ul |
| 23 | class="mx-auto grid h-14 max-w-3xl" |
| 24 | style={{ "grid-template-columns": `repeat(${items().length + 2}, minmax(0, 1fr))` }} |
| 25 | > |
| 26 | <For each={items()}> |
| 27 | {(item) => { |
| 28 | const active = () => primaryPathActive(pathname(), item); |
| 29 | return ( |
| 30 | <li class="min-w-0"> |
| 31 | <Link |
| 32 | to={item.to} |
| 33 | aria-current={active() ? "page" : undefined} |
| 34 | class={cn( |
| 35 | "flex h-full flex-col items-center justify-center gap-1 px-1 text-[11px] font-medium", |
| 36 | active() ? "text-foreground" : "text-muted-foreground", |
| 37 | )} |
| 38 | > |
| 39 | <span class="flex h-7 w-10 items-center justify-center"> |
| 40 | <item.Icon class="h-[22px] w-[22px]" /> |
| 41 | </span> |
| 42 | <span class="max-w-full truncate">{t(item.labelKey)}</span> |
| 43 | </Link> |
| 44 | </li> |
| 45 | ); |
| 46 | }} |
| 47 | </For> |
| 48 | <li class="min-w-0"> |
| 49 | <button |
| 50 | type="button" |
| 51 | aria-label={t("common.search")} |
| 52 | class="flex h-full w-full flex-col items-center justify-center gap-1 px-1 text-[11px] font-medium text-muted-foreground" |
| 53 | onClick={() => props.onSearch()} |
| 54 | > |
| 55 | <span class="flex h-7 w-10 items-center justify-center"> |
| 56 | <IconSearch class="h-[22px] w-[22px]" /> |
| 57 | </span> |
| 58 | <span class="truncate">{t("common.search")}</span> |
| 59 | </button> |
| 60 | </li> |
| 61 | <li class="min-w-0"> |
| 62 | <button |
| 63 | id="mobile-menu-trigger" |
| 64 | type="button" |
| 65 | aria-label={t("nav.menu")} |
| 66 | class="flex h-full w-full flex-col items-center justify-center gap-1 px-1 text-[11px] font-medium text-muted-foreground" |
| 67 | onClick={() => props.onMenu()} |
| 68 | > |
| 69 | <span class="flex h-7 w-10 items-center justify-center"> |
| 70 | <IconMenu class="h-[22px] w-[22px]" /> |
| 71 | </span> |
| 72 | <span class="truncate">{t("nav.menu")}</span> |
| 73 | </button> |
| 74 | </li> |
| 75 | </ul> |
| 76 | </nav> |
| 77 | ); |
| 78 | } |