The open-source AI voice studio. Clone, dictate, create.
Refactor HistoryTable and ProfileList components for improved UI and functionality
Jamie Pinea1b0f268c95d
diff --git a/app/src/components/History/HistoryTable.tsx b/app/src/components/History/HistoryTable.tsxindex ee029df6..62938442 100644--- a/app/src/components/History/HistoryTable.tsx+++ b/app/src/components/History/HistoryTable.tsx@@ -1,8 +1,13 @@-import { Download, Play, Trash2 } from 'lucide-react';+import { Download, MoreHorizontal, Play, Trash2 } from 'lucide-react';import { useState } from 'react';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';-import { CircleButton } from '@/components/ui/circle-button';+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuTrigger,+} from '@/components/ui/dropdown-menu';import {Table,TableBody,@@ -79,12 +84,12 @@ export function HistoryTable() {<Table className="w-full table-fixed"><TableHeader className="sticky top-0 bg-background z-10"><TableRow>- <TableHead className="w-[35%]">Text</TableHead>- <TableHead className="w-[12%]">Profile</TableHead>- <TableHead className="w-[8%]">Language</TableHead>- <TableHead className="w-[8%]">Duration</TableHead>- <TableHead className="w-[12%]">Created</TableHead>- <TableHead className="w-[15%] text-right min-w-[100px]">Actions</TableHead>+ <TableHead className="w-[38%]">Text</TableHead>+ <TableHead className="w-[13%]">Profile</TableHead>+ <TableHead className="w-[9%]">Language</TableHead>+ <TableHead className="w-[9%]">Duration</TableHead>+ <TableHead className="w-[13%]">Created</TableHead>+ <TableHead className="w-[8%] text-right">Actions</TableHead></TableRow></TableHeader><TableBody>@@ -107,27 +112,45 @@ export function HistoryTable() {<TableCell className="text-xs text-muted-foreground/60">{formatDate(gen.created_at)}</TableCell>- <TableCell className="text-right min-w-[100px]">+ <TableCell className="text-right"><div- className="flex justify-end gap-0.5 flex-nowrap"+ className="flex justify-end"onClick={(e) => e.stopPropagation()}>- <CircleButton- icon={Play}- onClick={() => handlePlay(gen.id, gen.text)}- aria-label="Play audio"- />- <CircleButton- icon={Download}- onClick={() => handleDownload(gen.id, gen.text)}- aria-label="Download audio"- />- <CircleButton- icon={Trash2}- onClick={() => deleteGeneration.mutate(gen.id)}- disabled={deleteGeneration.isPending}- aria-label="Delete generation"- />+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button+ variant="ghost"+ size="icon"+ className="h-7 w-7 rounded-full"+ aria-label="Actions"+ >+ <MoreHorizontal className="h-3.5 w-3.5" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuItem+ onClick={() => handlePlay(gen.id, gen.text)}+ >+ <Play className="mr-2 h-4 w-4" />+ Play+ </DropdownMenuItem>+ <DropdownMenuItem+ onClick={() => handleDownload(gen.id, gen.text)}+ >+ <Download className="mr-2 h-4 w-4" />+ Download+ </DropdownMenuItem>+ <DropdownMenuItem+ onClick={() => deleteGeneration.mutate(gen.id)}+ disabled={deleteGeneration.isPending}+ className="text-destructive focus:text-destructive"+ >+ <Trash2 className="mr-2 h-4 w-4" />+ Delete+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu></div></TableCell></TableRow>diff --git a/app/src/components/VoiceProfiles/ProfileList.tsx b/app/src/components/VoiceProfiles/ProfileList.tsxindex 811bf520..7706a3c2 100644--- a/app/src/components/VoiceProfiles/ProfileList.tsx+++ b/app/src/components/VoiceProfiles/ProfileList.tsx@@ -1,4 +1,4 @@-import { Mic, Plus } from 'lucide-react';+import { Mic, Sparkles } from 'lucide-react';import { Button } from '@/components/ui/button';import { Card, CardContent } from '@/components/ui/card';import { useProfiles } from '@/lib/hooks/useProfiles';@@ -33,12 +33,12 @@ export function ProfileList() {<div className="flex items-center justify-between mb-4 shrink-0"><h2 className="text-2xl font-bold">Voicebox</h2><Button onClick={() => setDialogOpen(true)}>- <Plus className="mr-2 h-4 w-4" />+ <Sparkles className="mr-2 h-4 w-4" />New Profile</Button></div>- <div className="min-h-[280px] shrink-0">+ <div className="shrink-0">{allProfiles.length === 0 ? (<Card><CardContent className="flex flex-col items-center justify-center py-12">@@ -47,13 +47,13 @@ export function ProfileList() {No voice profiles yet. Create your first profile to get started.</p><Button onClick={() => setDialogOpen(true)}>- <Plus className="mr-2 h-4 w-4" />+ <Sparkles className="mr-2 h-4 w-4" />Create Profile</Button></CardContent></Card>) : (- <div className="grid gap-4 grid-cols-3 auto-rows-fr p-1">+ <div className="grid gap-4 grid-cols-3 auto-rows-auto p-1">{allProfiles.map((profile) => (<ProfileCard key={profile.id} profile={profile} />))}diff --git a/app/src/components/ui/dropdown-menu.tsx b/app/src/components/ui/dropdown-menu.tsxnew file mode 100644index 00000000..d59c291c--- /dev/null+++ b/app/src/components/ui/dropdown-menu.tsx@@ -0,0 +1,177 @@+import * as React from 'react';+import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';+import { MoreHorizontal } from 'lucide-react';+import { cn } from '@/lib/utils/cn';++const DropdownMenu = DropdownMenuPrimitive.Root;+const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;+const DropdownMenuGroup = DropdownMenuPrimitive.Group;+const DropdownMenuPortal = DropdownMenuPrimitive.Portal;+const DropdownMenuSub = DropdownMenuPrimitive.Sub;+const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;++const DropdownMenuSubTrigger = React.forwardRef<+ React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {+ inset?: boolean;+ }+>(({ className, inset, children, ...props }, ref) => (+ <DropdownMenuPrimitive.SubTrigger+ ref={ref}+ className={cn(+ 'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent',+ inset && 'pl-8',+ className,+ )}+ {...props}+ >+ {children}+ <MoreHorizontal className="ml-auto h-4 w-4" />+ </DropdownMenuPrimitive.SubTrigger>+));+DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;++const DropdownMenuSubContent = React.forwardRef<+ React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>+>(({ className, ...props }, ref) => (+ <DropdownMenuPrimitive.SubContent+ ref={ref}+ className={cn(+ 'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',+ className,+ )}+ {...props}+ />+));+DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;++const DropdownMenuContent = React.forwardRef<+ React.ElementRef<typeof DropdownMenuPrimitive.Content>,+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>+>(({ className, sideOffset = 4, ...props }, ref) => (+ <DropdownMenuPrimitive.Portal>+ <DropdownMenuPrimitive.Content+ ref={ref}+ sideOffset={sideOffset}+ className={cn(+ 'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',+ className,+ )}+ {...props}+ />+ </DropdownMenuPrimitive.Portal>+));+DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;++const DropdownMenuItem = React.forwardRef<+ React.ElementRef<typeof DropdownMenuPrimitive.Item>,+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {+ inset?: boolean;+ }+>(({ className, inset, ...props }, ref) => (+ <DropdownMenuPrimitive.Item+ ref={ref}+ className={cn(+ 'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',+ inset && 'pl-8',+ className,+ )}+ {...props}+ />+));+DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;++const DropdownMenuCheckboxItem = React.forwardRef<+ React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>+>(({ className, children, checked, ...props }, ref) => (+ <DropdownMenuPrimitive.CheckboxItem+ ref={ref}+ className={cn(+ 'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',+ className,+ )}+ checked={checked}+ {...props}+ >+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">+ <DropdownMenuPrimitive.ItemIndicator>+ <MoreHorizontal className="h-4 w-4" />+ </DropdownMenuPrimitive.ItemIndicator>+ </span>+ {children}+ </DropdownMenuPrimitive.CheckboxItem>+));+DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;++const DropdownMenuRadioItem = React.forwardRef<+ React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>+>(({ className, children, ...props }, ref) => (+ <DropdownMenuPrimitive.RadioItem+ ref={ref}+ className={cn(+ 'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',+ className,+ )}+ {...props}+ >+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">+ <DropdownMenuPrimitive.ItemIndicator>+ <MoreHorizontal className="h-2 w-2 fill-current" />+ </DropdownMenuPrimitive.ItemIndicator>+ </span>+ {children}+ </DropdownMenuPrimitive.RadioItem>+));+DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;++const DropdownMenuLabel = React.forwardRef<+ React.ElementRef<typeof DropdownMenuPrimitive.Label>,+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {+ inset?: boolean;+ }+>(({ className, inset, ...props }, ref) => (+ <DropdownMenuPrimitive.Label+ ref={ref}+ className={cn('px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', className)}+ {...props}+ />+));+DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;++const DropdownMenuSeparator = React.forwardRef<+ React.ElementRef<typeof DropdownMenuPrimitive.Separator>,+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>+>(({ className, ...props }, ref) => (+ <DropdownMenuPrimitive.Separator+ ref={ref}+ className={cn('-mx-1 my-1 h-px bg-muted', className)}+ {...props}+ />+));+DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;++const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {+ return <span className={cn('ml-auto text-xs tracking-widest opacity-60', className)} {...props} />;+};+DropdownMenuShortcut.displayName = 'DropdownMenuShortcut';++export {+ DropdownMenu,+ DropdownMenuTrigger,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuCheckboxItem,+ DropdownMenuRadioItem,+ DropdownMenuLabel,+ DropdownMenuSeparator,+ DropdownMenuShortcut,+ DropdownMenuGroup,+ DropdownMenuPortal,+ DropdownMenuSub,+ DropdownMenuSubContent,+ DropdownMenuSubTrigger,+ DropdownMenuRadioGroup,+};diff --git a/app/src/components/ui/slider.tsx b/app/src/components/ui/slider.tsxindex d20d1b27..8c944ec7 100644--- a/app/src/components/ui/slider.tsx+++ b/app/src/components/ui/slider.tsx@@ -14,7 +14,7 @@ const Slider = React.forwardRef<<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary"><SliderPrimitive.Range className="absolute h-full bg-primary" /></SliderPrimitive.Track>- <SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />+ <SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 translate-x-0.5" /></SliderPrimitive.Root>));Slider.displayName = SliderPrimitive.Root.displayName;