forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits

data-toolbar.tsx37 lines, 1.5 KiBHistoryRawDownload
1import { Show } from "solid-js";
2import type { JSX } from "solid-js";
3import { DataTableSearch } from "@/components/ui/data-table-search";
4import { cn } from "@/lib/cn";
5
6export function DataToolbar(props: {
7 searchValue?: string;
8 searchPlaceholder?: string;
9 /** On-focus hint under the search box naming the fields it matches. */
10 searchHint?: string;
11 onSearchInput?: (value: string) => void;
12 filters?: JSX.Element;
13 actions?: JSX.Element;
14 inline?: boolean;
15 class?: string;
16}) {
17 const hasSearch = () => props.searchValue !== undefined || props.searchPlaceholder !== undefined || props.onSearchInput !== undefined;
18 return (
19 <div class={cn("flex gap-3", props.inline ? "flex-row items-center" : "flex-col sm:flex-row sm:items-center sm:justify-between", props.class)}>
20 <div class={cn("flex min-w-0 flex-1 gap-2", props.inline ? "flex-row flex-nowrap items-center" : "flex-col sm:flex-row sm:flex-wrap sm:items-center")}>
21 <Show when={hasSearch()}>
22 <DataTableSearch
23 class={cn("sm:max-w-72", props.inline && "min-w-0 flex-1")}
24 value={props.searchValue ?? ""}
25 placeholder={props.searchPlaceholder}
26 hint={props.searchHint}
27 onChange={(value) => props.onSearchInput?.(value)}
28 />
29 </Show>
30 {props.filters}
31 </div>
32 <Show when={props.actions}>
33 <div class="flex shrink-0 items-center gap-2 sm:justify-end">{props.actions}</div>
34 </Show>
35 </div>
36 );
37}