fix: enhance admin dashboard drawer UX

Fix scrolling, layout, and collapsible sections; improve animations and sizing.

#VERCEL_SKIP

Co-authored-by: Allan K. Koech <44490960+allankoechke@users.noreply.github.com>
This commit is contained in:
v0
2025-06-23 11:54:58 +00:00
parent b9869a1bca
commit 8d83b194d7
4 changed files with 415 additions and 350 deletions

View File

@@ -65,8 +65,8 @@ export function EditItemDrawer({ table, item, apiClient, open, onClose, onItemUp
return ( return (
<Drawer open={open} onOpenChange={onClose}> <Drawer open={open} onOpenChange={onClose}>
<DrawerContent side="right" className="w-[700px] max-w-[90vw]"> <DrawerContent side="right" className="w-[700px] max-w-[95vw]">
<DrawerHeader className="border-b"> <DrawerHeader>
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<Edit className="h-5 w-5" /> <Edit className="h-5 w-5" />
@@ -79,32 +79,36 @@ export function EditItemDrawer({ table, item, apiClient, open, onClose, onItemUp
<DrawerDescription>Edit record in {table.name} table</DrawerDescription> <DrawerDescription>Edit record in {table.name} table</DrawerDescription>
</DrawerHeader> </DrawerHeader>
<ScrollArea className="flex-1"> <div className="flex-1 overflow-hidden">
<div className="p-6 space-y-6"> <ScrollArea className="h-full">
{table.fields?.map((field) => ( <div className="p-6 space-y-6">
<div key={field.name} className="space-y-2"> {table.fields?.map((field) => (
<Label htmlFor={field.name} className="text-sm font-medium capitalize"> <div key={field.name} className="space-y-2">
{field.name} <Label htmlFor={field.name} className="text-sm font-medium capitalize">
{!field.nullable && <span className="text-red-500 ml-1">*</span>} {field.name}
</Label> {!field.nullable && <span className="text-red-500 ml-1">*</span>}
<Input </Label>
id={field.name} <Input
type={field.name === "password" ? "password" : field.type === "datetime" ? "datetime-local" : "text"} id={field.name}
value={formData[field.name] || ""} type={
onChange={(e) => handleFieldChange(field.name, e.target.value)} field.name === "password" ? "password" : field.type === "datetime" ? "datetime-local" : "text"
disabled={isSystemField(field.name)} }
className={`w-full ${isSystemField(field.name) ? "bg-muted" : ""}`} value={formData[field.name] || ""}
placeholder={`Enter ${field.name}`} onChange={(e) => handleFieldChange(field.name, e.target.value)}
/> disabled={isSystemField(field.name)}
{isSystemField(field.name) && ( className={`w-full ${isSystemField(field.name) ? "bg-muted" : ""}`}
<p className="text-xs text-muted-foreground">System field - cannot be modified</p> placeholder={`Enter ${field.name}`}
)} />
</div> {isSystemField(field.name) && (
))} <p className="text-xs text-muted-foreground">System field - cannot be modified</p>
</div> )}
</ScrollArea> </div>
))}
</div>
</ScrollArea>
</div>
<DrawerFooter className="border-t mt-6"> <DrawerFooter>
<div className="flex gap-3"> <div className="flex gap-3">
<Button variant="outline" onClick={onClose} className="flex-1"> <Button variant="outline" onClick={onClose} className="flex-1">
Cancel Cancel

View File

@@ -1,7 +1,7 @@
"use client" "use client"
import * as React from "react" import * as React from "react"
import { Plus, Trash2, Cog, X } from "lucide-react" import { Plus, Trash2, Cog, X, ChevronDown } from "lucide-react"
import { Button } from "@/components/ui/button" import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input" import { Input } from "@/components/ui/input"
@@ -19,6 +19,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { ScrollArea } from "@/components/ui/scroll-area" import { ScrollArea } from "@/components/ui/scroll-area"
import { Textarea } from "@/components/ui/textarea" import { Textarea } from "@/components/ui/textarea"
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
import type { ApiClient, TableMetadata } from "@/lib/api" import type { ApiClient, TableMetadata } from "@/lib/api"
interface TableConfigDrawerProps { interface TableConfigDrawerProps {
@@ -114,8 +115,8 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
return ( return (
<Drawer open={open} onOpenChange={onClose}> <Drawer open={open} onOpenChange={onClose}>
<DrawerContent side="right" className="w-[800px] max-w-[90vw]"> <DrawerContent side="right" className="w-[900px] max-w-[95vw]">
<DrawerHeader className="border-b"> <DrawerHeader>
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<Cog className="h-5 w-5" /> <Cog className="h-5 w-5" />
@@ -128,276 +129,327 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
<DrawerDescription>Manage table schema and access control rules</DrawerDescription> <DrawerDescription>Manage table schema and access control rules</DrawerDescription>
</DrawerHeader> </DrawerHeader>
<ScrollArea className="flex-1"> <div className="flex-1 overflow-hidden">
<div className="p-6"> <ScrollArea className="h-full">
<Tabs value={activeTab} onValueChange={setActiveTab}> <div className="p-6">
<TabsList className="grid w-full grid-cols-2 mb-6"> <Tabs value={activeTab} onValueChange={setActiveTab} className="w-full">
<TabsTrigger value="schema">Schema</TabsTrigger> <TabsList className="grid w-full grid-cols-2 mb-6">
<TabsTrigger value="rules">Access Rules</TabsTrigger> <TabsTrigger value="schema">Schema</TabsTrigger>
</TabsList> <TabsTrigger value="rules">Access Rules</TabsTrigger>
</TabsList>
<TabsContent value="schema" className="space-y-6"> <TabsContent value="schema" className="space-y-6">
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<div>
<h4 className="text-lg font-medium">Table Structure</h4>
<p className="text-sm text-muted-foreground">Modify columns and their properties</p>
</div>
{table.type !== "view" && (
<Button type="button" variant="outline" size="sm" onClick={addColumn}>
<Plus className="h-4 w-4 mr-2" />
Add Column
</Button>
)}
</div>
{table.type === "view" ? (
<div className="p-4 bg-muted rounded-lg">
<h5 className="font-medium mb-3">SQL Query</h5>
<pre className="text-sm overflow-x-auto whitespace-pre-wrap">
<code>{table.sql}</code>
</pre>
</div>
) : (
<div className="space-y-4">
{columns.map((column, index) => {
const isSystem = isSystemColumn(column.name)
return (
<div key={index} className={`p-4 border rounded-lg space-y-4 ${isSystem ? "bg-muted/50" : ""}`}>
<div className="flex items-center gap-3">
<div className="flex-1">
<Label className="text-sm font-medium mb-2 block">Column Name</Label>
<div className="flex items-center gap-2">
<Input
placeholder="Column name"
value={column.name}
onChange={(e) => updateColumn(index, "name", e.target.value)}
disabled={isSystem}
className={`flex-1 ${isSystem ? "bg-muted" : ""}`}
/>
{isSystem && (
<Badge variant="outline" className="text-xs">
System
</Badge>
)}
</div>
</div>
<div className="w-40">
<Label className="text-sm font-medium mb-2 block">Data Type</Label>
<Select
value={column.type}
onValueChange={(value) => updateColumn(index, "type", value)}
disabled={isSystem}
>
<SelectTrigger className={isSystem ? "bg-muted" : ""}>
<SelectValue />
</SelectTrigger>
<SelectContent>
{dataTypes.map((type) => (
<SelectItem key={type} value={type}>
{type.toUpperCase()}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
<div className="pt-6">
<Button
type="button"
variant="ghost"
size="sm"
onClick={() => removeColumn(index)}
disabled={columns.length === 1 || isSystem}
className={isSystem ? "opacity-30" : ""}
>
<Trash2 className="h-4 w-4" />
</Button>
</div>
</div>
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`primary-${index}`}
checked={column.primaryKey}
onChange={(e) => updateColumn(index, "primaryKey", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`primary-${index}`} className="text-sm">
Primary Key
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`unique-${index}`}
checked={column.unique || false}
onChange={(e) => updateColumn(index, "unique", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`unique-${index}`} className="text-sm">
Unique
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`required-${index}`}
checked={!column.nullable}
onChange={(e) => updateColumn(index, "nullable", !e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`required-${index}`} className="text-sm">
Required
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`files-${index}`}
checked={column.isFile || false}
onChange={(e) => updateColumn(index, "isFile", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`files-${index}`} className="text-sm">
File Field
</Label>
</div>
</div>
</div>
)
})}
</div>
)}
{table.type !== "view" && (
<div className="text-sm text-muted-foreground p-3 bg-muted/50 rounded-lg">
<p>
<Badge variant="outline" className="text-xs mr-2">
System
</Badge>
System columns are automatically managed and cannot be modified.
</p>
</div>
)}
</TabsContent>
<TabsContent value="rules" className="space-y-6">
<div>
<h4 className="text-lg font-medium mb-4">Access Control Rules</h4>
<div className="space-y-6">
<div> <div>
<Label htmlFor="list-rule" className="text-sm font-medium"> <h4 className="text-lg font-medium">Table Structure</h4>
List Rule <p className="text-sm text-muted-foreground">Modify columns and their properties</p>
</Label>
<Textarea
id="list-rule"
placeholder='e.g., "True", "auth.id != None", ""'
value={rules.list}
onChange={(e) => setRules({ ...rules, list: e.target.value })}
className="mt-2"
rows={2}
/>
<p className="text-xs text-muted-foreground mt-1">Controls who can list records</p>
</div> </div>
<div>
<Label htmlFor="get-rule" className="text-sm font-medium">
Get Rule
</Label>
<Textarea
id="get-rule"
placeholder='e.g., "True", "auth.id == record.user_id"'
value={rules.get}
onChange={(e) => setRules({ ...rules, get: e.target.value })}
className="mt-2"
rows={2}
/>
<p className="text-xs text-muted-foreground mt-1">Controls who can view individual records</p>
</div>
{table.type !== "view" && ( {table.type !== "view" && (
<> <Button type="button" variant="outline" size="sm" onClick={addColumn}>
<div> <Plus className="h-4 w-4 mr-2" />
<Label htmlFor="add-rule" className="text-sm font-medium"> Add Column
Add Rule </Button>
</Label>
<Textarea
id="add-rule"
placeholder='e.g., "auth.id != None", "auth.role == "admin""'
value={rules.add}
onChange={(e) => setRules({ ...rules, add: e.target.value })}
className="mt-2"
rows={2}
/>
<p className="text-xs text-muted-foreground mt-1">Controls who can create new records</p>
</div>
<div>
<Label htmlFor="update-rule" className="text-sm font-medium">
Update Rule
</Label>
<Textarea
id="update-rule"
placeholder='e.g., "auth.id == record.user_id", ""'
value={rules.update}
onChange={(e) => setRules({ ...rules, update: e.target.value })}
className="mt-2"
rows={2}
/>
<p className="text-xs text-muted-foreground mt-1">Controls who can update records</p>
</div>
<div>
<Label htmlFor="delete-rule" className="text-sm font-medium">
Delete Rule
</Label>
<Textarea
id="delete-rule"
placeholder='e.g., "auth.role == "admin"", ""'
value={rules.delete}
onChange={(e) => setRules({ ...rules, delete: e.target.value })}
className="mt-2"
rows={2}
/>
<p className="text-xs text-muted-foreground mt-1">Controls who can delete records</p>
</div>
</>
)} )}
</div> </div>
<div className="mt-6 p-4 bg-muted rounded-lg"> {table.type === "view" ? (
<h5 className="font-medium mb-3">Rule Examples</h5> <div className="p-4 bg-muted rounded-lg">
<div className="space-y-2 text-sm text-muted-foreground"> <h5 className="font-medium mb-3">SQL Query</h5>
<div className="grid grid-cols-1 md:grid-cols-2 gap-2"> <ScrollArea className="h-32">
<p> <pre className="text-sm whitespace-pre-wrap">
<code className="bg-background px-2 py-1 rounded">""</code> - Admin access only <code>{table.sql}</code>
</p> </pre>
<p> </ScrollArea>
<code className="bg-background px-2 py-1 rounded">"True"</code> - Public access </div>
</p> ) : (
<p> <div className="space-y-4">
<code className="bg-background px-2 py-1 rounded">"auth.id != None"</code> - Authenticated {columns.map((column, index) => {
users const isSystem = isSystemColumn(column.name)
</p> return (
<p> <div key={index} className={`border rounded-lg ${isSystem ? "bg-muted/50" : ""}`}>
<code className="bg-background px-2 py-1 rounded">"auth.id == record.user_id"</code> - Owner <div className="p-4 space-y-4">
only {/* Basic Info */}
</p> <div className="grid grid-cols-1 md:grid-cols-3 gap-4">
<div className="md:col-span-2">
<Label className="text-sm font-medium mb-2 block">Column Name</Label>
<div className="flex items-center gap-2">
<Input
placeholder="Column name"
value={column.name}
onChange={(e) => updateColumn(index, "name", e.target.value)}
disabled={isSystem}
className={`flex-1 ${isSystem ? "bg-muted" : ""}`}
/>
{isSystem && (
<Badge variant="outline" className="text-xs">
System
</Badge>
)}
</div>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Data Type</Label>
<Select
value={column.type}
onValueChange={(value) => updateColumn(index, "type", value)}
disabled={isSystem}
>
<SelectTrigger className={isSystem ? "bg-muted" : ""}>
<SelectValue />
</SelectTrigger>
<SelectContent>
{dataTypes.map((type) => (
<SelectItem key={type} value={type}>
{type.toUpperCase()}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
</div>
{/* Basic Properties */}
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`primary-${index}`}
checked={column.primaryKey}
onChange={(e) => updateColumn(index, "primaryKey", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`primary-${index}`} className="text-sm">
Primary Key
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`required-${index}`}
checked={!column.nullable}
onChange={(e) => updateColumn(index, "nullable", !e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`required-${index}`} className="text-sm">
Required
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`unique-${index}`}
checked={column.unique || false}
onChange={(e) => updateColumn(index, "unique", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`unique-${index}`} className="text-sm">
Unique
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`files-${index}`}
checked={column.isFile || false}
onChange={(e) => updateColumn(index, "isFile", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`files-${index}`} className="text-sm">
File Field
</Label>
</div>
</div>
{/* Advanced Options - Collapsible */}
<Collapsible>
<CollapsibleTrigger asChild>
<Button variant="ghost" size="sm" className="w-full justify-between p-2">
<span className="text-sm">Advanced Options</span>
<ChevronDown className="h-4 w-4" />
</Button>
</CollapsibleTrigger>
<CollapsibleContent className="space-y-4 pt-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<Label className="text-sm font-medium mb-2 block">Default Value</Label>
<Input
placeholder="Default value"
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Max Length</Label>
<Input
type="number"
placeholder="Max length"
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Description</Label>
<Textarea
placeholder="Column description"
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
rows={2}
/>
</div>
</CollapsibleContent>
</Collapsible>
{/* Delete Button */}
<div className="flex justify-end pt-2 border-t">
<Button
type="button"
variant="ghost"
size="sm"
onClick={() => removeColumn(index)}
disabled={columns.length === 1 || isSystem}
className={`text-destructive hover:text-destructive ${isSystem ? "opacity-30" : ""}`}
>
<Trash2 className="h-4 w-4 mr-2" />
Remove Column
</Button>
</div>
</div>
</div>
)
})}
</div>
)}
{table.type !== "view" && (
<div className="text-sm text-muted-foreground p-3 bg-muted/50 rounded-lg">
<p>
<Badge variant="outline" className="text-xs mr-2">
System
</Badge>
System columns are automatically managed and cannot be modified.
</p>
</div>
)}
</TabsContent>
<TabsContent value="rules" className="space-y-6">
<div>
<h4 className="text-lg font-medium mb-4">Access Control Rules</h4>
<div className="space-y-6">
<div>
<Label htmlFor="list-rule" className="text-sm font-medium">
List Rule
</Label>
<Textarea
id="list-rule"
placeholder='e.g., "True", "auth.id != None", ""'
value={rules.list}
onChange={(e) => setRules({ ...rules, list: e.target.value })}
className="mt-2"
rows={3}
/>
<p className="text-xs text-muted-foreground mt-1">Controls who can list records</p>
</div>
<div>
<Label htmlFor="get-rule" className="text-sm font-medium">
Get Rule
</Label>
<Textarea
id="get-rule"
placeholder='e.g., "True", "auth.id == record.user_id"'
value={rules.get}
onChange={(e) => setRules({ ...rules, get: e.target.value })}
className="mt-2"
rows={3}
/>
<p className="text-xs text-muted-foreground mt-1">Controls who can view individual records</p>
</div>
{table.type !== "view" && (
<>
<div>
<Label htmlFor="add-rule" className="text-sm font-medium">
Add Rule
</Label>
<Textarea
id="add-rule"
placeholder='e.g., "auth.id != None", "auth.role == "admin""'
value={rules.add}
onChange={(e) => setRules({ ...rules, add: e.target.value })}
className="mt-2"
rows={3}
/>
<p className="text-xs text-muted-foreground mt-1">Controls who can create new records</p>
</div>
<div>
<Label htmlFor="update-rule" className="text-sm font-medium">
Update Rule
</Label>
<Textarea
id="update-rule"
placeholder='e.g., "auth.id == record.user_id", ""'
value={rules.update}
onChange={(e) => setRules({ ...rules, update: e.target.value })}
className="mt-2"
rows={3}
/>
<p className="text-xs text-muted-foreground mt-1">Controls who can update records</p>
</div>
<div>
<Label htmlFor="delete-rule" className="text-sm font-medium">
Delete Rule
</Label>
<Textarea
id="delete-rule"
placeholder='e.g., "auth.role == "admin"", ""'
value={rules.delete}
onChange={(e) => setRules({ ...rules, delete: e.target.value })}
className="mt-2"
rows={3}
/>
<p className="text-xs text-muted-foreground mt-1">Controls who can delete records</p>
</div>
</>
)}
</div>
<div className="mt-6 p-4 bg-muted rounded-lg">
<h5 className="font-medium mb-3">Rule Examples</h5>
<div className="space-y-2 text-sm text-muted-foreground">
<div className="grid grid-cols-1 gap-2">
<p>
<code className="bg-background px-2 py-1 rounded">""</code> - Admin access only
</p>
<p>
<code className="bg-background px-2 py-1 rounded">"True"</code> - Public access
</p>
<p>
<code className="bg-background px-2 py-1 rounded">"auth.id != None"</code> - Authenticated
users only
</p>
<p>
<code className="bg-background px-2 py-1 rounded">"auth.id == record.user_id"</code> - Owner
access only
</p>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </TabsContent>
</TabsContent> </Tabs>
</Tabs> </div>
</div> </ScrollArea>
</ScrollArea> </div>
<DrawerFooter className="border-t mt-6"> <DrawerFooter>
<div className="flex gap-3"> <div className="flex gap-3">
<Button variant="outline" onClick={onClose} className="flex-1"> <Button variant="outline" onClick={onClose} className="flex-1">
Cancel Cancel

View File

@@ -19,8 +19,8 @@ interface TableDocsDrawerProps {
export function TableDocsDrawer({ table, open, onClose }: TableDocsDrawerProps) { export function TableDocsDrawer({ table, open, onClose }: TableDocsDrawerProps) {
return ( return (
<Drawer open={open} onOpenChange={onClose}> <Drawer open={open} onOpenChange={onClose}>
<DrawerContent side="right" className="w-[900px] max-w-[90vw]"> <DrawerContent side="right" className="w-[1000px] max-w-[95vw]">
<DrawerHeader className="border-b"> <DrawerHeader>
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<FileText className="h-5 w-5" /> <FileText className="h-5 w-5" />
@@ -33,53 +33,55 @@ export function TableDocsDrawer({ table, open, onClose }: TableDocsDrawerProps)
<DrawerDescription>Auto-generated API endpoints and examples</DrawerDescription> <DrawerDescription>Auto-generated API endpoints and examples</DrawerDescription>
</DrawerHeader> </DrawerHeader>
<ScrollArea className="flex-1"> <div className="flex-1 overflow-hidden">
<div className="p-6 space-y-6"> <ScrollArea className="h-full">
<ApiEndpointCard <div className="p-6 space-y-6">
method="GET" <ApiEndpointCard
endpoint={`/api/v1/tables/${table.name}`} method="GET"
description={`List all records in the ${table.name} table`} endpoint={`/api/v1/tables/${table.name}`}
table={table} description={`List all records in the ${table.name} table`}
operation="list" table={table}
/> operation="list"
/>
<ApiEndpointCard <ApiEndpointCard
method="GET" method="GET"
endpoint={`/api/v1/tables/${table.name}/{id}`} endpoint={`/api/v1/tables/${table.name}/{id}`}
description="Get a specific record by ID" description="Get a specific record by ID"
table={table} table={table}
operation="get" operation="get"
/> />
{table.type !== "view" && ( {table.type !== "view" && (
<> <>
<ApiEndpointCard <ApiEndpointCard
method="POST" method="POST"
endpoint={`/api/v1/tables/${table.name}`} endpoint={`/api/v1/tables/${table.name}`}
description="Create a new record" description="Create a new record"
table={table} table={table}
operation="create" operation="create"
/> />
<ApiEndpointCard <ApiEndpointCard
method="PATCH" method="PATCH"
endpoint={`/api/v1/tables/${table.name}/{id}`} endpoint={`/api/v1/tables/${table.name}/{id}`}
description="Update a specific record" description="Update a specific record"
table={table} table={table}
operation="update" operation="update"
/> />
<ApiEndpointCard <ApiEndpointCard
method="DELETE" method="DELETE"
endpoint={`/api/v1/tables/${table.name}/{id}`} endpoint={`/api/v1/tables/${table.name}/{id}`}
description="Delete a specific record" description="Delete a specific record"
table={table} table={table}
operation="delete" operation="delete"
/> />
</> </>
)} )}
</div> </div>
</ScrollArea> </ScrollArea>
</div>
</DrawerContent> </DrawerContent>
</Drawer> </Drawer>
) )
@@ -232,9 +234,11 @@ function ApiEndpointCard({
Copy Copy
</Button> </Button>
</div> </div>
<pre className="bg-muted p-4 rounded text-sm overflow-x-auto border"> <ScrollArea className="h-48">
<code>{requestExample}</code> <pre className="bg-muted p-4 rounded text-sm border">
</pre> <code>{requestExample}</code>
</pre>
</ScrollArea>
</div> </div>
<div> <div>
@@ -245,9 +249,11 @@ function ApiEndpointCard({
Copy Copy
</Button> </Button>
</div> </div>
<pre className="bg-muted p-4 rounded text-sm overflow-x-auto border"> <ScrollArea className="h-48">
<code>{responseExample}</code> <pre className="bg-muted p-4 rounded text-sm border">
</pre> <code>{responseExample}</code>
</pre>
</ScrollArea>
</div> </div>
<div> <div>

View File

@@ -26,16 +26,16 @@ const DrawerOverlay = React.forwardRef<
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName
const drawerVariants = cva( const drawerVariants = cva(
"fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500", "fixed z-50 gap-4 bg-background shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
{ {
variants: { variants: {
side: { side: {
top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top", top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
bottom: bottom:
"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom", "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm", left: "inset-y-0 left-0 h-full border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",
right: right:
"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm", "inset-y-0 right-0 h-full border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right",
}, },
}, },
defaultVariants: { defaultVariants: {
@@ -52,11 +52,11 @@ const DrawerContent = React.forwardRef<React.ElementRef<typeof DrawerPrimitive.C
({ side = "right", className, children, ...props }, ref) => ( ({ side = "right", className, children, ...props }, ref) => (
<DrawerPortal> <DrawerPortal>
<DrawerOverlay /> <DrawerOverlay />
<DrawerPrimitive.Content ref={ref} className={cn(drawerVariants({ side }), className)} {...props}> <DrawerPrimitive.Content
{side === "right" && <div className="absolute left-0 top-1/2 h-4 w-1 -translate-y-1/2 rounded-r bg-muted" />} ref={ref}
{side === "left" && <div className="absolute right-0 top-1/2 h-4 w-1 -translate-y-1/2 rounded-l bg-muted" />} className={cn(drawerVariants({ side }), "flex flex-col", className)}
{side === "bottom" && <div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />} {...props}
{side === "top" && <div className="mx-auto mb-4 h-2 w-[100px] rounded-full bg-muted" />} >
{children} {children}
</DrawerPrimitive.Content> </DrawerPrimitive.Content>
</DrawerPortal> </DrawerPortal>
@@ -65,12 +65,15 @@ const DrawerContent = React.forwardRef<React.ElementRef<typeof DrawerPrimitive.C
DrawerContent.displayName = "DrawerContent" DrawerContent.displayName = "DrawerContent"
const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => ( const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} /> <div className={cn("flex flex-col space-y-1.5 text-center sm:text-left p-6 border-b", className)} {...props} />
) )
DrawerHeader.displayName = "DrawerHeader" DrawerHeader.displayName = "DrawerHeader"
const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => ( const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} /> <div
className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 p-6 border-t mt-auto", className)}
{...props}
/>
) )
DrawerFooter.displayName = "DrawerFooter" DrawerFooter.displayName = "DrawerFooter"