-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5df65c1
commit 9e0fd81
Showing
3 changed files
with
100 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Skeleton } from "@repo/ui/components/ui/skeleton"; | ||
|
||
export function SkeletonVote() { | ||
return ( | ||
<div className="flex flex-col space-y-3"> | ||
<div className="h-12 flex justify-between items-center"> | ||
<Skeleton className="w-3/5 h-5" /> | ||
<Skeleton className="w-1/5 h-3" /> | ||
</div> | ||
|
||
<div className="space-y-2 mt-4"> | ||
<Skeleton className="h-10" /> | ||
<Skeleton className="h-10" /> | ||
<Skeleton className="h-10" /> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Button } from "@repo/ui/components/ui/button"; | ||
import { Input } from "@repo/ui/components/ui/input"; | ||
|
||
export function VoteInput({ | ||
value, | ||
onChange, | ||
max, | ||
min = 0, | ||
total, | ||
increment, | ||
disabled, | ||
}: { | ||
value: number; | ||
onChange: (value: number) => void; | ||
max: number; | ||
min?: number; | ||
total: number; | ||
increment: number; | ||
disabled: boolean; | ||
}) { | ||
return ( | ||
<div className="flex items-center"> | ||
<Button | ||
disabled={disabled || value <= min} | ||
onClick={() => onChange(Math.max(min, value - increment))} | ||
className="bg-gray-700 w-8 py-1 text-white hover:bg-gray-500 rounded-r-none" | ||
> | ||
- | ||
</Button> | ||
<Input | ||
disabled={disabled} | ||
type="number" | ||
value={value} | ||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => | ||
onChange( | ||
Math.max(min, Math.min(max, Number.parseInt(e.target.value) || 0)), | ||
) | ||
} | ||
className="w-16 bg-gray-600 text-center text-white rounded-none px-3 py-1 input-number-hide-arrows border-none focus-visible:ring-0 focus-visible:ring-offset-0 disabled:cursor-default" | ||
/> | ||
<Button | ||
disabled={disabled || value >= max} | ||
onClick={() => onChange(Math.min(max, value + increment))} | ||
className="bg-gray-700 w-8 py-1 text-white hover:bg-gray-500 rounded-l-none" | ||
> | ||
+ | ||
</Button> | ||
<span className="w-12 text-right hidden sm:block"> | ||
{value > 0 ? Math.round((value / total) * 100) : 0}% | ||
</span> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters