hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiBc35a83aBurak Boduroğlu4 months ago440 commits
| 1 | import { For } from "solid-js"; |
| 2 | import { |
| 3 | DropdownMenu, |
| 4 | DropdownMenuCheckboxItem, |
| 5 | DropdownMenuContent, |
| 6 | DropdownMenuLabel, |
| 7 | DropdownMenuTrigger, |
| 8 | } from "@/components/ui/dropdown-menu"; |
| 9 | import { IconChevronDown } from "@/components/ui/icons"; |
| 10 | import { useT } from "@/stores/preferences-context"; |
| 11 | |
| 12 | export type ViewMenuColumn = { |
| 13 | id: string; |
| 14 | label: string; |
| 15 | visible: boolean; |
| 16 | toggle: (visible: boolean) => void; |
| 17 | }; |
| 18 | |
| 19 | export type DataTableViewMenuProps = { |
| 20 | columns: ViewMenuColumn[]; |
| 21 | }; |
| 22 | |
| 23 | /** Column visibility menu (rounded-lg, no density/resize controls). */ |
| 24 | export function DataTableViewMenu(props: DataTableViewMenuProps) { |
| 25 | const t = useT(); |
| 26 | |
| 27 | return ( |
| 28 | <DropdownMenu placement="bottom-end" gutter={6}> |
| 29 | <DropdownMenuTrigger class="ml-auto inline-flex h-8 items-center justify-center gap-2 whitespace-nowrap rounded-lg border border-border/70 bg-muted/40 px-3 text-[13px] font-medium transition-all hover:bg-muted active:scale-[0.98] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"> |
| 30 | {t("common.columns")} |
| 31 | <IconChevronDown class="h-3.5 w-3.5 opacity-60" /> |
| 32 | </DropdownMenuTrigger> |
| 33 | <DropdownMenuContent class="w-56"> |
| 34 | <DropdownMenuLabel>{t("common.visibleColumns")}</DropdownMenuLabel> |
| 35 | <For each={props.columns}> |
| 36 | {(column) => ( |
| 37 | <DropdownMenuCheckboxItem |
| 38 | checked={column.visible} |
| 39 | onChange={(value) => column.toggle(!!value)} |
| 40 | > |
| 41 | {column.label} |
| 42 | </DropdownMenuCheckboxItem> |
| 43 | )} |
| 44 | </For> |
| 45 | </DropdownMenuContent> |
| 46 | </DropdownMenu> |
| 47 | ); |
| 48 | } |