Skip to content

Commit

Permalink
feat: move rating display from tooltip to badge
Browse files Browse the repository at this point in the history
  • Loading branch information
dinkelspiel committed May 10, 2024
1 parent 9f4b308 commit 6fe51fa
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
13 changes: 5 additions & 8 deletions components/modifyUserEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Input } from './ui/input';
import { cn } from '@/lib/utils';
import UserEntryCard from './userEntryCard';
import { useMediaQuery } from 'usehooks-ts';
import { Badge } from './ui/badge';

const ModifyUserEntry = ({
userEntry,
Expand Down Expand Up @@ -144,14 +145,10 @@ const ModifyUserEntry = ({
<div className="grid h-full w-full grow grid-rows-[max-content,max-content,1fr,max-content]">
<Header />
<div className="flex flex-row items-center gap-3 border-b border-b-gray-200 py-3 text-sm">
<div className="w-max text-muted-foreground">
<TooltipProvider>
<Tooltip>
<TooltipTrigger>Rating</TooltipTrigger>
<TooltipContent>{rating / 20}</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
<div className="w-max text-muted-foreground">Rating</div>
<Badge className="min-w-[50px] max-w-[50px] justify-center">
{rating / 20}
</Badge>
<div className="w-full">
<Slider
value={[rating]}
Expand Down
36 changes: 36 additions & 0 deletions components/ui/badge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"

import { cn } from "@/lib/utils"

const badgeVariants = cva(
"inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
{
variants: {
variant: {
default:
"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
secondary:
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
destructive:
"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
outline: "text-foreground",
},
},
defaultVariants: {
variant: "default",
},
}
)

export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {}

function Badge({ className, variant, ...props }: BadgeProps) {
return (
<div className={cn(badgeVariants({ variant }), className)} {...props} />
)
}

export { Badge, badgeVariants }

0 comments on commit 6fe51fa

Please sign in to comment.