mirror of
https://github.com/allankoechke/mantisbase-admin.git
synced 2026-11-30 10:19:37 +00:00
feat: enhance admin dashboard UX and functionality
Improve table view layout, dark theme, data protection, schema config, and documentation links. Add theme system, data protection, and professional polish. #VERCEL_SKIP Co-authored-by: Allan K. Koech <44490960+allankoechke@users.noreply.github.com>
This commit is contained in:
103
app/globals.css
103
app/globals.css
@@ -2,85 +2,50 @@
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
body {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
@layer utilities {
|
||||
.text-balance {
|
||||
text-wrap: balance;
|
||||
}
|
||||
}
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
--background: 0 0% 100%;
|
||||
--foreground: 0 0% 3.9%;
|
||||
--foreground: 222.2 84% 4.9%;
|
||||
--card: 0 0% 100%;
|
||||
--card-foreground: 0 0% 3.9%;
|
||||
--card-foreground: 222.2 84% 4.9%;
|
||||
--popover: 0 0% 100%;
|
||||
--popover-foreground: 0 0% 3.9%;
|
||||
--primary: 0 0% 9%;
|
||||
--primary-foreground: 0 0% 98%;
|
||||
--secondary: 0 0% 96.1%;
|
||||
--secondary-foreground: 0 0% 9%;
|
||||
--muted: 0 0% 96.1%;
|
||||
--muted-foreground: 0 0% 45.1%;
|
||||
--accent: 0 0% 96.1%;
|
||||
--accent-foreground: 0 0% 9%;
|
||||
--popover-foreground: 222.2 84% 4.9%;
|
||||
--primary: 221.2 83.2% 53.3%;
|
||||
--primary-foreground: 210 40% 98%;
|
||||
--secondary: 210 40% 96%;
|
||||
--secondary-foreground: 222.2 84% 4.9%;
|
||||
--muted: 210 40% 96%;
|
||||
--muted-foreground: 215.4 16.3% 46.9%;
|
||||
--accent: 210 40% 96%;
|
||||
--accent-foreground: 222.2 84% 4.9%;
|
||||
--destructive: 0 84.2% 60.2%;
|
||||
--destructive-foreground: 0 0% 98%;
|
||||
--border: 0 0% 89.8%;
|
||||
--input: 0 0% 89.8%;
|
||||
--ring: 0 0% 3.9%;
|
||||
--chart-1: 12 76% 61%;
|
||||
--chart-2: 173 58% 39%;
|
||||
--chart-3: 197 37% 24%;
|
||||
--chart-4: 43 74% 66%;
|
||||
--chart-5: 27 87% 67%;
|
||||
--destructive-foreground: 210 40% 98%;
|
||||
--border: 214.3 31.8% 91.4%;
|
||||
--input: 214.3 31.8% 91.4%;
|
||||
--ring: 221.2 83.2% 53.3%;
|
||||
--radius: 0.5rem;
|
||||
--sidebar-background: 0 0% 98%;
|
||||
--sidebar-foreground: 240 5.3% 26.1%;
|
||||
--sidebar-primary: 240 5.9% 10%;
|
||||
--sidebar-primary-foreground: 0 0% 98%;
|
||||
--sidebar-accent: 240 4.8% 95.9%;
|
||||
--sidebar-accent-foreground: 240 5.9% 10%;
|
||||
--sidebar-border: 220 13% 91%;
|
||||
--sidebar-ring: 217.2 91.2% 59.8%;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: 0 0% 3.9%;
|
||||
--foreground: 0 0% 98%;
|
||||
--card: 0 0% 3.9%;
|
||||
--card-foreground: 0 0% 98%;
|
||||
--popover: 0 0% 3.9%;
|
||||
--popover-foreground: 0 0% 98%;
|
||||
--primary: 0 0% 98%;
|
||||
--primary-foreground: 0 0% 9%;
|
||||
--secondary: 0 0% 14.9%;
|
||||
--secondary-foreground: 0 0% 98%;
|
||||
--muted: 0 0% 14.9%;
|
||||
--muted-foreground: 0 0% 63.9%;
|
||||
--accent: 0 0% 14.9%;
|
||||
--accent-foreground: 0 0% 98%;
|
||||
--background: 222.2 84% 4.9%;
|
||||
--foreground: 210 40% 98%;
|
||||
--card: 222.2 84% 4.9%;
|
||||
--card-foreground: 210 40% 98%;
|
||||
--popover: 222.2 84% 4.9%;
|
||||
--popover-foreground: 210 40% 98%;
|
||||
--primary: 217.2 91.2% 59.8%;
|
||||
--primary-foreground: 222.2 84% 4.9%;
|
||||
--secondary: 217.2 32.6% 17.5%;
|
||||
--secondary-foreground: 210 40% 98%;
|
||||
--muted: 217.2 32.6% 17.5%;
|
||||
--muted-foreground: 215 20.2% 65.1%;
|
||||
--accent: 217.2 32.6% 17.5%;
|
||||
--accent-foreground: 210 40% 98%;
|
||||
--destructive: 0 62.8% 30.6%;
|
||||
--destructive-foreground: 0 0% 98%;
|
||||
--border: 0 0% 14.9%;
|
||||
--input: 0 0% 14.9%;
|
||||
--ring: 0 0% 83.1%;
|
||||
--chart-1: 220 70% 50%;
|
||||
--chart-2: 160 60% 45%;
|
||||
--chart-3: 30 80% 55%;
|
||||
--chart-4: 280 65% 60%;
|
||||
--chart-5: 340 75% 55%;
|
||||
--sidebar-background: 240 5.9% 10%;
|
||||
--sidebar-foreground: 240 4.8% 95.9%;
|
||||
--sidebar-primary: 224.3 76.3% 48%;
|
||||
--sidebar-primary-foreground: 0 0% 100%;
|
||||
--sidebar-accent: 240 3.7% 15.9%;
|
||||
--sidebar-accent-foreground: 240 4.8% 95.9%;
|
||||
--sidebar-border: 240 3.7% 15.9%;
|
||||
--sidebar-ring: 217.2 91.2% 59.8%;
|
||||
--destructive-foreground: 210 40% 98%;
|
||||
--border: 217.2 32.6% 17.5%;
|
||||
--input: 217.2 32.6% 17.5%;
|
||||
--ring: 224.3 76.3% 94.1%;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import * as React from "react"
|
||||
import { LoginForm } from "@/components/login-form"
|
||||
import { AdminDashboard } from "@/components/admin-dashboard"
|
||||
import { Toaster } from "@/components/ui/toaster"
|
||||
import { ThemeProvider } from "@/components/theme-provider"
|
||||
|
||||
export default function Page() {
|
||||
const [token, setToken] = React.useState<string | null>(null)
|
||||
@@ -37,9 +38,9 @@ export default function Page() {
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange>
|
||||
{!token ? <LoginForm onLogin={handleLogin} /> : <AdminDashboard token={token} onLogout={handleLogout} />}
|
||||
<Toaster />
|
||||
</>
|
||||
</ThemeProvider>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Table, Settings, Shield, LogOut, FileText, RefreshCw } from "lucide-react"
|
||||
import { Table, Settings, Shield, LogOut, FileText, RefreshCw, ExternalLink } from "lucide-react"
|
||||
import {
|
||||
Sidebar,
|
||||
SidebarContent,
|
||||
@@ -22,6 +22,7 @@ import { SettingsSection } from "./settings/settings-section"
|
||||
import { LogsSection } from "./logs/logs-section"
|
||||
import { SyncSection } from "./sync/sync-section"
|
||||
import { useToast } from "@/hooks/use-toast"
|
||||
import { ThemeToggle } from "./theme-toggle"
|
||||
|
||||
interface AdminDashboardProps {
|
||||
token: string
|
||||
@@ -144,6 +145,17 @@ export function AdminDashboard({ token, onLogout }: AdminDashboardProps) {
|
||||
</SidebarContent>
|
||||
<SidebarFooter>
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem>
|
||||
<SidebarMenuButton asChild>
|
||||
<a href="https://docs.example.com" target="_blank" rel="noopener noreferrer">
|
||||
<ExternalLink className="h-4 w-4" />
|
||||
<span>Documentation</span>
|
||||
</a>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
<SidebarMenuItem>
|
||||
<ThemeToggle />
|
||||
</SidebarMenuItem>
|
||||
<SidebarMenuItem>
|
||||
<SidebarMenuButton onClick={handleLogout}>
|
||||
<LogOut className="h-4 w-4" />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use client"
|
||||
import { Eye, EyeOff, Settings } from "lucide-react"
|
||||
import { Eye, EyeOff } from "lucide-react"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import {
|
||||
@@ -40,7 +40,7 @@ export function ColumnVisibilityDropdown({ table, visibleColumns, onVisibilityCh
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" size="sm">
|
||||
<Settings className="h-4 w-4 mr-2" />
|
||||
<Eye className="h-4 w-4 mr-2" />
|
||||
Columns
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
@@ -29,10 +29,12 @@ interface EditItemDrawerProps {
|
||||
export function EditItemDrawer({ table, item, apiClient, open, onClose, onItemUpdate }: EditItemDrawerProps) {
|
||||
const [formData, setFormData] = React.useState<any>({})
|
||||
const [isLoading, setIsLoading] = React.useState(false)
|
||||
const [hasUnsavedChanges, setHasUnsavedChanges] = React.useState(false)
|
||||
|
||||
React.useEffect(() => {
|
||||
if (open && item) {
|
||||
setFormData({ ...item })
|
||||
setHasUnsavedChanges(false)
|
||||
}
|
||||
}, [open, item])
|
||||
|
||||
@@ -57,14 +59,26 @@ export function EditItemDrawer({ table, item, apiClient, open, onClose, onItemUp
|
||||
...prev,
|
||||
[fieldName]: value,
|
||||
}))
|
||||
setHasUnsavedChanges(true)
|
||||
}
|
||||
|
||||
const isSystemField = (fieldName: string) => {
|
||||
return ["id", "created", "updated"].includes(fieldName)
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
if (hasUnsavedChanges) {
|
||||
if (confirm("You have unsaved changes. Are you sure you want to close?")) {
|
||||
setHasUnsavedChanges(false)
|
||||
onClose()
|
||||
}
|
||||
} else {
|
||||
onClose()
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Drawer open={open} onOpenChange={onClose}>
|
||||
<Drawer open={open} onOpenChange={handleClose}>
|
||||
<DrawerContent side="right" className="w-[700px] max-w-[95vw]">
|
||||
<DrawerHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
@@ -72,7 +86,7 @@ export function EditItemDrawer({ table, item, apiClient, open, onClose, onItemUp
|
||||
<Edit className="h-5 w-5" />
|
||||
<DrawerTitle>Edit Record</DrawerTitle>
|
||||
</div>
|
||||
<Button variant="ghost" size="sm" onClick={onClose}>
|
||||
<Button variant="ghost" size="sm" onClick={handleClose}>
|
||||
<X className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
@@ -110,7 +124,7 @@ export function EditItemDrawer({ table, item, apiClient, open, onClose, onItemUp
|
||||
|
||||
<DrawerFooter>
|
||||
<div className="flex gap-3">
|
||||
<Button variant="outline" onClick={onClose} className="flex-1">
|
||||
<Button variant="outline" onClick={handleClose} className="flex-1">
|
||||
Cancel
|
||||
</Button>
|
||||
<Button onClick={handleSubmit} disabled={isLoading} className="flex-1">
|
||||
|
||||
@@ -35,11 +35,15 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
|
||||
const [rules, setRules] = React.useState(table.rules)
|
||||
const [isLoading, setIsLoading] = React.useState(false)
|
||||
const [activeTab, setActiveTab] = React.useState("schema")
|
||||
const [hasUnsavedChanges, setHasUnsavedChanges] = React.useState(false)
|
||||
const [systemFieldsCollapsed, setSystemFieldsCollapsed] = React.useState(true)
|
||||
|
||||
React.useEffect(() => {
|
||||
if (open) {
|
||||
setColumns(table.fields || [])
|
||||
setRules(table.rules)
|
||||
setHasUnsavedChanges(false)
|
||||
setSystemFieldsCollapsed(true)
|
||||
}
|
||||
}, [open, table])
|
||||
|
||||
@@ -64,6 +68,7 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
|
||||
|
||||
const addColumn = () => {
|
||||
setColumns([...columns, { name: "", type: "string", primaryKey: false, nullable: true }])
|
||||
setHasUnsavedChanges(true)
|
||||
}
|
||||
|
||||
const removeColumn = (index: number) => {
|
||||
@@ -77,6 +82,7 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
|
||||
const updateColumn = (index: number, field: string, value: any) => {
|
||||
const updatedColumns = columns.map((col, i) => (i === index ? { ...col, [field]: value } : col))
|
||||
setColumns(updatedColumns)
|
||||
setHasUnsavedChanges(true)
|
||||
}
|
||||
|
||||
const handleSaveSchema = async () => {
|
||||
@@ -113,8 +119,19 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
|
||||
return ["id", "created", "updated", "email", "password"].includes(columnName)
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
if (hasUnsavedChanges) {
|
||||
if (confirm("You have unsaved changes. Are you sure you want to close?")) {
|
||||
setHasUnsavedChanges(false)
|
||||
onClose()
|
||||
}
|
||||
} else {
|
||||
onClose()
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Drawer open={open} onOpenChange={onClose}>
|
||||
<Drawer open={open} onOpenChange={handleClose}>
|
||||
<DrawerContent side="right" className="w-[900px] max-w-[95vw]">
|
||||
<DrawerHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
@@ -162,11 +179,195 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
|
||||
</ScrollArea>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{/* System Fields - Collapsible */}
|
||||
{columns.filter((col) => isSystemColumn(col.name)).length > 0 && (
|
||||
<Collapsible
|
||||
open={!systemFieldsCollapsed}
|
||||
onOpenChange={(open) => setSystemFieldsCollapsed(!open)}
|
||||
>
|
||||
<CollapsibleTrigger asChild>
|
||||
<Button variant="ghost" className="w-full justify-between p-2 mb-4">
|
||||
<span className="text-sm font-medium">
|
||||
System Fields ({columns.filter((col) => isSystemColumn(col.name)).length})
|
||||
</span>
|
||||
<ChevronDown
|
||||
className={`h-4 w-4 transition-transform ${systemFieldsCollapsed ? "" : "rotate-180"}`}
|
||||
/>
|
||||
</Button>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsibleContent className="space-y-4 mb-6">
|
||||
{columns.map((column, index) => {
|
||||
const isSystem = isSystemColumn(column.name)
|
||||
if (!isSystem) return null
|
||||
return (
|
||||
<div key={index} className="border rounded-lg bg-muted/50">
|
||||
<div className="p-4 space-y-4">
|
||||
{/* Basic Info */}
|
||||
<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>
|
||||
)
|
||||
})}
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
)}
|
||||
|
||||
{/* Regular Fields */}
|
||||
<div className="space-y-4">
|
||||
{columns.map((column, index) => {
|
||||
const isSystem = isSystemColumn(column.name)
|
||||
if (isSystem) return null // Skip system fields as they're in collapsible section
|
||||
return (
|
||||
<div key={index} className={`border rounded-lg ${isSystem ? "bg-muted/50" : ""}`}>
|
||||
<div key={index} className="border rounded-lg">
|
||||
<div className="p-4 space-y-4">
|
||||
{/* Basic Info */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
@@ -323,6 +524,7 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{table.type !== "view" && (
|
||||
@@ -451,7 +653,7 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
|
||||
|
||||
<DrawerFooter>
|
||||
<div className="flex gap-3">
|
||||
<Button variant="outline" onClick={onClose} className="flex-1">
|
||||
<Button variant="outline" onClick={handleClose} className="flex-1">
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
|
||||
@@ -161,32 +161,26 @@ export function TableDetailView({ table, onBack, apiClient, onTableUpdate }: Tab
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-4">
|
||||
<div>
|
||||
<CardTitle>Table Data</CardTitle>
|
||||
<CardDescription>Current records in the {table.name} table</CardDescription>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{selectedItems.length > 0 && (
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
onClick={handleDeleteSelected}
|
||||
disabled={isDeleting}
|
||||
className="ml-auto"
|
||||
>
|
||||
<Button variant="destructive" size="sm" onClick={handleDeleteSelected} disabled={isDeleting}>
|
||||
<Trash2 className="h-4 w-4 mr-2" />
|
||||
{isDeleting
|
||||
? "Deleting..."
|
||||
: `Delete ${selectedItems.length} item${selectedItems.length > 1 ? "s" : ""}`}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<ColumnVisibilityDropdown
|
||||
table={table}
|
||||
visibleColumns={visibleColumns}
|
||||
onVisibilityChange={setVisibleColumns}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="rounded-md border">
|
||||
|
||||
@@ -17,8 +17,12 @@ interface TableDocsDrawerProps {
|
||||
}
|
||||
|
||||
export function TableDocsDrawer({ table, open, onClose }: TableDocsDrawerProps) {
|
||||
const handleClose = () => {
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<Drawer open={open} onOpenChange={onClose}>
|
||||
<Drawer open={open} onOpenChange={handleClose}>
|
||||
<DrawerContent side="right" className="w-[1000px] max-w-[95vw]">
|
||||
<DrawerHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import * as React from 'react'
|
||||
import {
|
||||
ThemeProvider as NextThemesProvider,
|
||||
type ThemeProviderProps,
|
||||
} from 'next-themes'
|
||||
"use client"
|
||||
import { ThemeProvider as NextThemesProvider } from "next-themes"
|
||||
import type { ThemeProviderProps } from "next-themes"
|
||||
|
||||
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
|
||||
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
|
||||
|
||||
31
components/theme-toggle.tsx
Normal file
31
components/theme-toggle.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Moon, Sun } from "lucide-react"
|
||||
import { useTheme } from "next-themes"
|
||||
import { SidebarMenuButton } from "@/components/ui/sidebar"
|
||||
|
||||
export function ThemeToggle() {
|
||||
const { theme, setTheme } = useTheme()
|
||||
const [mounted, setMounted] = React.useState(false)
|
||||
|
||||
React.useEffect(() => {
|
||||
setMounted(true)
|
||||
}, [])
|
||||
|
||||
if (!mounted) {
|
||||
return (
|
||||
<SidebarMenuButton>
|
||||
<div className="h-4 w-4" />
|
||||
<span>Theme</span>
|
||||
</SidebarMenuButton>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<SidebarMenuButton onClick={() => setTheme(theme === "dark" ? "light" : "dark")}>
|
||||
{theme === "dark" ? <Sun className="h-4 w-4" /> : <Moon className="h-4 w-4" />}
|
||||
<span>{theme === "dark" ? "Light Mode" : "Dark Mode"}</span>
|
||||
</SidebarMenuButton>
|
||||
)
|
||||
}
|
||||
@@ -46,7 +46,7 @@
|
||||
"input-otp": "1.4.1",
|
||||
"lucide-react": "^0.454.0",
|
||||
"next": "15.2.4",
|
||||
"next-themes": "^0.4.4",
|
||||
"next-themes": "latest",
|
||||
"react": "^19",
|
||||
"react-day-picker": "8.10.1",
|
||||
"react-dom": "^19",
|
||||
|
||||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@@ -120,8 +120,8 @@ importers:
|
||||
specifier: 15.2.4
|
||||
version: 15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
|
||||
next-themes:
|
||||
specifier: ^0.4.4
|
||||
version: 0.4.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
|
||||
specifier: latest
|
||||
version: 0.4.6(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
|
||||
react:
|
||||
specifier: ^19
|
||||
version: 19.0.0
|
||||
@@ -1604,8 +1604,8 @@ packages:
|
||||
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
||||
hasBin: true
|
||||
|
||||
next-themes@0.4.4:
|
||||
resolution: {integrity: sha512-LDQ2qIOJF0VnuVrrMSMLrWGjRMkq+0mpgl6e0juCLqdJ+oo8Q84JRWT6Wh11VDQKkMMe+dVzDKLWs5n87T+PkQ==}
|
||||
next-themes@0.4.6:
|
||||
resolution: {integrity: sha512-pZvgD5L0IEvX5/9GWyHMf3m8BKiVQwsCMHfoFosXtXBMnaS0ZnIJ9ST4b4NqLVKDEm8QBxoNNGNaBv2JNF6XNA==}
|
||||
peerDependencies:
|
||||
react: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc
|
||||
react-dom: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc
|
||||
@@ -3369,7 +3369,7 @@ snapshots:
|
||||
|
||||
nanoid@3.3.11: {}
|
||||
|
||||
next-themes@0.4.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0):
|
||||
next-themes@0.4.6(react-dom@19.0.0(react@19.0.0))(react@19.0.0):
|
||||
dependencies:
|
||||
react: 19.0.0
|
||||
react-dom: 19.0.0(react@19.0.0)
|
||||
|
||||
@@ -1,96 +1,81 @@
|
||||
import type { Config } from "tailwindcss";
|
||||
import type { Config } from "tailwindcss"
|
||||
|
||||
const config: Config = {
|
||||
darkMode: ["class"],
|
||||
content: [
|
||||
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"./components/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"./app/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"*.{js,ts,jsx,tsx,mdx}"
|
||||
"./pages/**/*.{ts,tsx}",
|
||||
"./components/**/*.{ts,tsx}",
|
||||
"./app/**/*.{ts,tsx}",
|
||||
"./src/**/*.{ts,tsx}",
|
||||
"*.{js,ts,jsx,tsx,mdx}",
|
||||
],
|
||||
prefix: "",
|
||||
theme: {
|
||||
container: {
|
||||
center: true,
|
||||
padding: "2rem",
|
||||
screens: {
|
||||
"2xl": "1400px",
|
||||
},
|
||||
},
|
||||
extend: {
|
||||
colors: {
|
||||
background: 'hsl(var(--background))',
|
||||
foreground: 'hsl(var(--foreground))',
|
||||
card: {
|
||||
DEFAULT: 'hsl(var(--card))',
|
||||
foreground: 'hsl(var(--card-foreground))'
|
||||
},
|
||||
popover: {
|
||||
DEFAULT: 'hsl(var(--popover))',
|
||||
foreground: 'hsl(var(--popover-foreground))'
|
||||
},
|
||||
border: "hsl(var(--border))",
|
||||
input: "hsl(var(--input))",
|
||||
ring: "hsl(var(--ring))",
|
||||
background: "hsl(var(--background))",
|
||||
foreground: "hsl(var(--foreground))",
|
||||
primary: {
|
||||
DEFAULT: 'hsl(var(--primary))',
|
||||
foreground: 'hsl(var(--primary-foreground))'
|
||||
DEFAULT: "hsl(var(--primary))",
|
||||
foreground: "hsl(var(--primary-foreground))",
|
||||
},
|
||||
secondary: {
|
||||
DEFAULT: 'hsl(var(--secondary))',
|
||||
foreground: 'hsl(var(--secondary-foreground))'
|
||||
},
|
||||
muted: {
|
||||
DEFAULT: 'hsl(var(--muted))',
|
||||
foreground: 'hsl(var(--muted-foreground))'
|
||||
},
|
||||
accent: {
|
||||
DEFAULT: 'hsl(var(--accent))',
|
||||
foreground: 'hsl(var(--accent-foreground))'
|
||||
DEFAULT: "hsl(var(--secondary))",
|
||||
foreground: "hsl(var(--secondary-foreground))",
|
||||
},
|
||||
destructive: {
|
||||
DEFAULT: 'hsl(var(--destructive))',
|
||||
foreground: 'hsl(var(--destructive-foreground))'
|
||||
DEFAULT: "hsl(var(--destructive))",
|
||||
foreground: "hsl(var(--destructive-foreground))",
|
||||
},
|
||||
border: 'hsl(var(--border))',
|
||||
input: 'hsl(var(--input))',
|
||||
ring: 'hsl(var(--ring))',
|
||||
chart: {
|
||||
'1': 'hsl(var(--chart-1))',
|
||||
'2': 'hsl(var(--chart-2))',
|
||||
'3': 'hsl(var(--chart-3))',
|
||||
'4': 'hsl(var(--chart-4))',
|
||||
'5': 'hsl(var(--chart-5))'
|
||||
muted: {
|
||||
DEFAULT: "hsl(var(--muted))",
|
||||
foreground: "hsl(var(--muted-foreground))",
|
||||
},
|
||||
accent: {
|
||||
DEFAULT: "hsl(var(--accent))",
|
||||
foreground: "hsl(var(--accent-foreground))",
|
||||
},
|
||||
popover: {
|
||||
DEFAULT: "hsl(var(--popover))",
|
||||
foreground: "hsl(var(--popover-foreground))",
|
||||
},
|
||||
card: {
|
||||
DEFAULT: "hsl(var(--card))",
|
||||
foreground: "hsl(var(--card-foreground))",
|
||||
},
|
||||
sidebar: {
|
||||
DEFAULT: 'hsl(var(--sidebar-background))',
|
||||
foreground: 'hsl(var(--sidebar-foreground))',
|
||||
primary: 'hsl(var(--sidebar-primary))',
|
||||
'primary-foreground': 'hsl(var(--sidebar-primary-foreground))',
|
||||
accent: 'hsl(var(--sidebar-accent))',
|
||||
'accent-foreground': 'hsl(var(--sidebar-accent-foreground))',
|
||||
border: 'hsl(var(--sidebar-border))',
|
||||
ring: 'hsl(var(--sidebar-ring))'
|
||||
}
|
||||
},
|
||||
borderRadius: {
|
||||
lg: 'var(--radius)',
|
||||
md: 'calc(var(--radius) - 2px)',
|
||||
sm: 'calc(var(--radius) - 4px)'
|
||||
lg: "var(--radius)",
|
||||
md: "calc(var(--radius) - 2px)",
|
||||
sm: "calc(var(--radius) - 4px)",
|
||||
},
|
||||
keyframes: {
|
||||
'accordion-down': {
|
||||
from: {
|
||||
height: '0'
|
||||
"accordion-down": {
|
||||
from: { height: "0" },
|
||||
to: { height: "var(--radix-accordion-content-height)" },
|
||||
},
|
||||
to: {
|
||||
height: 'var(--radix-accordion-content-height)'
|
||||
}
|
||||
"accordion-up": {
|
||||
from: { height: "var(--radix-accordion-content-height)" },
|
||||
to: { height: "0" },
|
||||
},
|
||||
'accordion-up': {
|
||||
from: {
|
||||
height: 'var(--radix-accordion-content-height)'
|
||||
},
|
||||
to: {
|
||||
height: '0'
|
||||
}
|
||||
}
|
||||
},
|
||||
animation: {
|
||||
'accordion-down': 'accordion-down 0.2s ease-out',
|
||||
'accordion-up': 'accordion-up 0.2s ease-out'
|
||||
}
|
||||
}
|
||||
"accordion-down": "accordion-down 0.2s ease-out",
|
||||
"accordion-up": "accordion-up 0.2s ease-out",
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [require("tailwindcss-animate")],
|
||||
};
|
||||
export default config;
|
||||
} satisfies Config
|
||||
|
||||
export default config
|
||||
|
||||
Reference in New Issue
Block a user