fix(web): layout and scrollable

This commit is contained in:
BennyKok
2023-12-29 14:55:08 +08:00
parent d9f83dadd1
commit 9d0a52b7ab
7 changed files with 65 additions and 9 deletions
+1 -1
View File
@@ -91,7 +91,7 @@ export const columns: ColumnDef<Machine>[] = [
cell: ({ row }) => {
return (
// <a className="hover:underline" href={`/${row.original.id}`}>
<div className="flex flex-row gap-2">
<div className="flex flex-row gap-2 items-center">
<div>{row.getValue("name")}</div>
{row.original.disabled && (
<Badge variant="destructive">Disabled</Badge>
+7 -6
View File
@@ -12,6 +12,7 @@ import {
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Input } from "@/components/ui/input";
import { ScrollArea } from "@/components/ui/scroll-area";
import {
Table,
TableBody,
@@ -192,8 +193,8 @@ export function WorkflowList({ data }: { data: Payment[] }) {
});
return (
<div className="w-full">
<div className="flex items-center py-4">
<div className="grid grid-rows-[auto,1fr,auto] h-full">
<div className="flex flex-row w-full items-center py-4">
<Input
placeholder="Filter workflows..."
value={(table.getColumn("email")?.getFilterValue() as string) ?? ""}
@@ -229,9 +230,9 @@ export function WorkflowList({ data }: { data: Payment[] }) {
</DropdownMenuContent>
</DropdownMenu>
</div>
<div className="rounded-md border overflow-x-auto w-full">
<ScrollArea className="h-full w-full rounded-md border">
<Table>
<TableHeader>
<TableHeader className="bg-background top-0 sticky">
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => {
@@ -278,8 +279,8 @@ export function WorkflowList({ data }: { data: Payment[] }) {
)}
</TableBody>
</Table>
</div>
<div className="flex items-center justify-end space-x-2 py-4">
</ScrollArea>
<div className="flex flex-row items-center justify-end space-x-2 py-4">
<div className="flex-1 text-sm text-muted-foreground">
{table.getFilteredSelectedRowModel().rows.length} of{" "}
{table.getFilteredRowModel().rows.length} row(s) selected.
+48
View File
@@ -0,0 +1,48 @@
"use client";
import { cn } from "@/lib/utils";
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
import * as React from "react";
const ScrollArea = React.forwardRef<
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
>(({ className, children, ...props }, ref) => (
<ScrollAreaPrimitive.Root
ref={ref}
className={cn("relative overflow-hidden", className)}
{...props}
>
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
{children}
</ScrollAreaPrimitive.Viewport>
<ScrollBar />
<ScrollBar orientation="horizontal" />
<ScrollAreaPrimitive.Corner />
</ScrollAreaPrimitive.Root>
));
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
const ScrollBar = React.forwardRef<
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
>(({ className, orientation = "vertical", ...props }, ref) => (
<ScrollAreaPrimitive.ScrollAreaScrollbar
ref={ref}
orientation={orientation}
className={cn(
"flex touch-none select-none transition-colors",
orientation === "vertical" &&
"h-full w-2.5 border-l border-l-transparent p-[1px]",
orientation === "horizontal" &&
"h-2.5 flex-col border-t border-t-transparent p-[1px]",
className
)}
{...props}
>
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
</ScrollAreaPrimitive.ScrollAreaScrollbar>
));
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
export { ScrollArea, ScrollBar };