forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiBc35a83aBurak Boduroğlu4 months ago440 commits

data-toolbar.tsx34 lines, 1.3 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 onSearchInput?: (value: string) => void;
10 filters?: JSX.Element;
11 actions?: JSX.Element;
12 inline?: boolean;
13 class?: string;
14}) {
15 const hasSearch = () => props.searchValue !== undefined || props.searchPlaceholder !== undefined || props.onSearchInput !== undefined;
16 return (
17 <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)}>
18 <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")}>
19 <Show when={hasSearch()}>
20 <DataTableSearch
21 class={cn("sm:max-w-72", props.inline && "min-w-0 flex-1")}
22 value={props.searchValue ?? ""}
23 placeholder={props.searchPlaceholder}
24 onChange={(value) => props.onSearchInput?.(value)}
25 />
26 </Show>
27 {props.filters}
28 </div>
29 <Show when={props.actions}>
30 <div class="flex shrink-0 items-center gap-2 sm:justify-end">{props.actions}</div>
31 </Show>
32 </div>
33 );
34}