-
Notifications
You must be signed in to change notification settings - Fork 0
🎨 Palette: Enhance SongCard with tooltips and loading feedback #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,15 @@ | ||
| import { Link } from "wouter"; | ||
| import { Music, Calendar, Trash2, Globe, Lock } from "lucide-react"; | ||
| import { Music, Calendar, Trash2, Globe, Lock, Loader2 } from "lucide-react"; | ||
| import { type Song } from "@shared/schema"; | ||
| import { format } from "date-fns"; | ||
| import { useDeleteSong } from "@/hooks/use-songs"; | ||
| import { Button } from "@/components/ui/button"; | ||
| import { memo } from "react"; | ||
| import { | ||
| Tooltip, | ||
| TooltipContent, | ||
| TooltipTrigger, | ||
| } from "@/components/ui/tooltip"; | ||
| import { | ||
| AlertDialog, | ||
| AlertDialogAction, | ||
|
|
@@ -45,30 +50,48 @@ export const SongCard = memo(function SongCard({ song }: SongCardProps) { | |
| </div> | ||
|
|
||
| <div className="flex items-center gap-1 relative z-20 pointer-events-auto"> | ||
| {song.isPublic ? ( | ||
| <span className="p-2 text-primary" title="Public"> | ||
| <Globe className="w-4 h-4" /> | ||
| </span> | ||
| ) : ( | ||
| <span className="p-2 text-muted-foreground" title="Private"> | ||
| <Lock className="w-4 h-4" /> | ||
| </span> | ||
| )} | ||
| <Tooltip> | ||
| <TooltipTrigger asChild> | ||
| {song.isPublic ? ( | ||
| <span className="p-2 text-primary cursor-default" tabIndex={0} role="img" aria-label="Public song"> | ||
| <Globe className="w-4 h-4" /> | ||
| </span> | ||
| ) : ( | ||
| <span className="p-2 text-muted-foreground cursor-default" tabIndex={0} role="img" aria-label="Private song"> | ||
| <Lock className="w-4 h-4" /> | ||
| </span> | ||
| )} | ||
| </TooltipTrigger> | ||
| <TooltipContent> | ||
| <p>{song.isPublic ? "Public - visible to everyone" : "Private - only visible to you"}</p> | ||
| </TooltipContent> | ||
|
Comment on lines
+65
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new Useful? React with 👍 / 👎. |
||
| </Tooltip> | ||
|
|
||
| <AlertDialog> | ||
| <AlertDialogTrigger asChild> | ||
| <Button | ||
| size="icon" | ||
| variant="ghost" | ||
| onClick={(e) => e.stopPropagation()} | ||
| disabled={isPending} | ||
| className="opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity" | ||
| data-testid={`button-delete-${song.id}`} | ||
| aria-label="Delete song" | ||
| > | ||
| <Trash2 className="w-4 h-4 text-destructive" /> | ||
| </Button> | ||
| </AlertDialogTrigger> | ||
| <Tooltip> | ||
| <TooltipTrigger asChild> | ||
| <AlertDialogTrigger asChild> | ||
| <Button | ||
| size="icon" | ||
| variant="ghost" | ||
| onClick={(e) => e.stopPropagation()} | ||
| disabled={isPending} | ||
| className="opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity" | ||
| data-testid={`button-delete-${song.id}`} | ||
| aria-label="Delete song" | ||
| > | ||
| {isPending ? ( | ||
| <Loader2 className="w-4 h-4 animate-spin" /> | ||
| ) : ( | ||
| <Trash2 className="w-4 h-4 text-destructive" /> | ||
| )} | ||
| </Button> | ||
| </AlertDialogTrigger> | ||
| </TooltipTrigger> | ||
| <TooltipContent> | ||
| <p>Delete song</p> | ||
| </TooltipContent> | ||
| </Tooltip> | ||
| <AlertDialogContent> | ||
| <AlertDialogHeader> | ||
| <AlertDialogTitle>Delete Song</AlertDialogTitle> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Frontend server running at http://localhost:3000 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of code for displaying the public/private icon can be simplified to be more DRY (Don't Repeat Yourself). You can use a single
<span>element and conditionally set theclassName,aria-label, and the icon component based onsong.isPublic. This will make the code cleaner and easier to maintain.