Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

Consolidate Pill-Shaped Button Variant (#760)

Eric Lee86348256fe8a
diff --git a/apps/web/src/app/[locale]/challenge/[id]/solutions/_components/index.tsx b/apps/web/src/app/[locale]/challenge/[id]/solutions/_components/index.tsx
index 5d0522a7..ef0a33ff 100644
--- a/apps/web/src/app/[locale]/challenge/[id]/solutions/_components/index.tsx
+++ b/apps/web/src/app/[locale]/challenge/[id]/solutions/_components/index.tsx
@@ -1,5 +1,5 @@
'use client';
-import { ArrowUp, MessageCircle } from '@repo/ui/icons';
+import { Calendar, MessageCircle, ThumbsUp } from '@repo/ui/icons';
import { useSession } from '@repo/auth/react';
import Link from 'next/link';
import { useState } from 'react';
@@ -8,7 +8,8 @@ import { NoSolutions } from './nosolutions';
import { SubmitSolution } from './submit-solution';
import type { ChallengeSolution } from '../getSolutionRouteData';
import { getRelativeTime } from '~/utils/relativeTime';
-import { Button } from '@repo/ui/components/button';
+import { Badge } from '@repo/ui/components/badge';
+import { UserBadge } from '@repo/ui/components/user-badge';
interface Props {
challenge: ChallengeSolution;
@@ -67,28 +68,25 @@ function SolutionRow({
}) {
return (
<Link
- className="group flex cursor-pointer flex-col gap-2 p-4 duration-300 hover:bg-neutral-100 dark:hover:bg-zinc-700/50"
+ className="flex cursor-pointer flex-col gap-2 p-4 duration-300 hover:bg-neutral-100 dark:hover:bg-zinc-700/50"
href={`/challenge/${solution.challengeId}/solutions/${solution.id}`}
>
<h3 className="truncate font-bold">{solution.title}</h3>
- <div className="flex items-center gap-1 text-neutral-600 dark:text-neutral-400">
- <Button
- className="-ml-[0.33rem] flex h-auto w-fit items-center rounded-full bg-transparent py-1 pl-[0.33rem] pr-2 text-xs font-bold text-neutral-700 hover:bg-black/10 dark:text-white dark:hover:bg-white/20"
- size="sm"
- >
- @{solution.user?.name ?? ''}
- </Button>
- <div className="mr-auto text-sm text-neutral-500">
- {getRelativeTime(solution.createdAt)}
+ <div className="flex items-center gap-2">
+ <UserBadge username={solution.user?.name ?? ''} linkComponent={Link} />
+ <div className="text-muted-foreground flex flex-1 items-center gap-2">
+ <Calendar className=" h-4 w-4" />
+ <span className="text-xs">{getRelativeTime(solution.createdAt)}</span>
</div>
- <button className="mr-2 flex cursor-pointer items-center gap-2 rounded-full bg-neutral-100 px-2 py-1 text-sm duration-300 hover:bg-neutral-200 dark:bg-zinc-700 dark:hover:bg-zinc-600">
- <MessageCircle className="h-4 w-4 stroke-1" /> {solution._count.solutionComment}
- </button>
- {/* TODO: voted state */}
- {/* bg-emerald-600/10 text-emerald-600 duration-300 hover:bg-emerald-600/20 dark:bg-emerald-400/20 dark:text-emerald-400 dark:hover:bg-emerald-400/40*/}
- <button className="flex cursor-pointer items-center gap-2 rounded-full bg-neutral-100 px-2 py-1 text-sm duration-300 hover:bg-neutral-200 dark:bg-zinc-700 dark:hover:bg-zinc-600 ">
- <ArrowUp className="h-4 w-4 stroke-1" /> {solution._count.vote}
- </button>
+ {/* TODO: Use `Vote` component here instead which handles voted state */}
+ <Badge variant="secondary" size="xs" className="gap-1">
+ <ThumbsUp className="h-4 w-4" />
+ <span>{solution._count.vote}</span>
+ </Badge>
+ <Badge variant="secondary" size="xs" className="gap-1">
+ <MessageCircle className="h-4 w-4" />
+ <span>{solution._count.solutionComment}</span>
+ </Badge>
</div>
</Link>
);
diff --git a/apps/web/src/app/[locale]/challenge/[id]/solutions/_components/solution-detail.tsx b/apps/web/src/app/[locale]/challenge/[id]/solutions/_components/solution-detail.tsx
index d412d724..919f3818 100644
--- a/apps/web/src/app/[locale]/challenge/[id]/solutions/_components/solution-detail.tsx
+++ b/apps/web/src/app/[locale]/challenge/[id]/solutions/_components/solution-detail.tsx
@@ -4,6 +4,7 @@ import { Calendar, Flag, Share, X } from '@repo/ui/icons';
import Link from 'next/link';
import type { ChallengeSolution } from '~/app/[locale]/challenge/[id]/solutions/[solutionId]/page';
import { ReportDialog } from '~/components/ReportDialog';
+import { getRelativeTime } from '~/utils/relativeTime';
import { ActionMenu } from '@repo/ui/components/action-menu';
import { Avatar, AvatarImage, AvatarFallback } from '@repo/ui/components/avatar';
import { Button } from '@repo/ui/components/button';
@@ -52,20 +53,6 @@ export function SolutionDetails({ solution }: Props) {
<TypographyLarge>{solution.title}</TypographyLarge>
</div>
<div className="flex items-center gap-2">
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- className="group p-0 text-gray-500 group-hover:text-gray-400"
- onClick={handleShareClick}
- variant="ghost"
- >
- <Share className="mr-2 h-4 w-4 stroke-gray-500 group-hover:stroke-gray-400" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Share challenge</p>
- </TooltipContent>
- </Tooltip>
<ReportDialog reportType="SOLUTION" solutionId={solution.id!}>
<ActionMenu
items={[
@@ -82,13 +69,12 @@ export function SolutionDetails({ solution }: Props) {
</ReportDialog>
</div>
</div>
+ {/* Author, Time, Action Buttons */}
<div className="flex items-center gap-4">
<UserBadge username={solution.user?.name ?? ''} linkComponent={Link} />
- <div className="flex items-center">
- <Calendar className="mr-2 h-4 w-4 stroke-gray-400" />
- <span className="text-xs text-gray-400">
- {solution.createdAt?.toLocaleString()}
- </span>
+ <div className="text-muted-foreground flex items-center gap-2">
+ <Calendar className="h-4 w-4" />
+ <span className="text-xs">{getRelativeTime(solution.createdAt)}</span>
</div>
<Vote
voteCount={solution._count.vote}
@@ -107,6 +93,16 @@ export function SolutionDetails({ solution }: Props) {
solution._count.vote += didUpvote ? 1 : -1;
}}
/>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button onClick={handleShareClick} variant="secondary" size="xs">
+ <Share className="h-4 w-4" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>Share</p>
+ </TooltipContent>
+ </Tooltip>
</div>
</div>
<Markdown>{solution.description || ''}</Markdown>
diff --git a/apps/web/src/app/[locale]/challenge/[id]/submissions/[[...catchAll]]/_components/index.tsx b/apps/web/src/app/[locale]/challenge/[id]/submissions/[[...catchAll]]/_components/index.tsx
index 3fb2145e..55c80c03 100644
--- a/apps/web/src/app/[locale]/challenge/[id]/submissions/[[...catchAll]]/_components/index.tsx
+++ b/apps/web/src/app/[locale]/challenge/[id]/submissions/[[...catchAll]]/_components/index.tsx
@@ -1,6 +1,7 @@
'use client';
import type { Submission } from '@repo/db/types';
+import { Calendar } from '@repo/ui/icons';
import clsx from 'clsx';
import Link from 'next/link';
import { useMemo, useState } from 'react';
@@ -97,7 +98,10 @@ function SubmissionRow({
>
{submission.isSuccessful ? 'Accepted' : 'Rejected'}
</div>
- <div className="text-sm text-neutral-500">{getRelativeTime(submission.createdAt)}</div>
+ <div className="text-muted-foreground flex items-center gap-2">
+ <Calendar className=" h-4 w-4" />
+ <span className="text-xs">{getRelativeTime(submission.createdAt)}</span>
+ </div>
</Link>
</li>
);
diff --git a/apps/web/src/app/[locale]/challenge/_components/comments/comment.tsx b/apps/web/src/app/[locale]/challenge/_components/comments/comment.tsx
index c133e442..6ec515a6 100644
--- a/apps/web/src/app/[locale]/challenge/_components/comments/comment.tsx
+++ b/apps/web/src/app/[locale]/challenge/_components/comments/comment.tsx
@@ -9,6 +9,7 @@ import { UserBadge } from '@repo/ui/components/user-badge';
import {
ChevronDown,
ChevronUp,
+ Calendar,
Pencil,
Reply,
Share,
@@ -374,9 +375,10 @@ function SingleComment({
</div>
<Tooltip delayDuration={0.05}>
<TooltipTrigger asChild>
- <span className="whitespace-nowrap text-[0.8rem] text-neutral-500 dark:text-neutral-400">
- {getRelativeTime(comment.createdAt)}
- </span>
+ <div className="text-muted-foreground flex items-center gap-2 whitespace-nowrap text-xs">
+ <Calendar className="h-4 w-4" />
+ <span>{getRelativeTime(comment.createdAt)}</span>
+ </div>
</TooltipTrigger>
<TooltipContent align="start" alignOffset={-55} className="rounded-xl">
<span className="text-foreground text-xs">{comment.createdAt.toLocaleString()}</span>
@@ -405,7 +407,7 @@ function SingleComment({
/>
</div>
) : null}
- <div className="my-auto mt-3 flex items-center gap-4">
+ <div className="my-auto mt-3 flex items-center gap-2">
{!readonly && (
<>
<Vote
@@ -425,50 +427,84 @@ function SingleComment({
comment._count.vote += didUpvote ? 1 : -1;
}}
/>
- <div
- className="flex cursor-pointer items-center gap-1 text-neutral-500 duration-200 hover:text-neutral-400 dark:text-neutral-400 dark:hover:text-neutral-300"
- onClick={() => {
- copyPathNotifyUser(Boolean(isReply), challengeId);
- }}
- >
- <Share className="h-3 w-3" />
- <div className="hidden text-[0.8rem] sm:block">Share</div>
- </div>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="secondary"
+ size="xs"
+ className="gap-2"
+ onClick={() => {
+ copyPathNotifyUser(Boolean(isReply), challengeId);
+ }}
+ >
+ <Share className="h-3 w-3" />
+ <span className="sr-only">Share this comment</span>
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>Share</p>
+ </TooltipContent>
+ </Tooltip>
{!isReply && (
- <button
- className="flex cursor-pointer items-center gap-1 text-neutral-500 duration-200 disabled:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-300"
- onClick={onClickReply}
- >
- <Reply className="h-4 w-4" />
- <div className="hidden text-[0.8rem] sm:block">Reply</div>
- </button>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button variant="secondary" size="xs" onClick={onClickReply}>
+ <Reply className="h-3 w-3" />
+ <span className="sr-only">Create a reply</span>
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>Reply</p>
+ </TooltipContent>
+ </Tooltip>
)}
{isAuthor ? (
- <button
- className="flex cursor-pointer items-center gap-1 text-neutral-500 duration-200 hover:text-neutral-400 dark:text-neutral-400 dark:hover:text-neutral-300"
- onClick={() => setIsEditing(!isEditing)}
- >
- <Pencil className="h-3 w-3" />
- <div className="hidden text-[0.8rem] sm:block">Edit</div>
- </button>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button variant="secondary" size="xs" onClick={() => setIsEditing(!isEditing)}>
+ <Pencil className="h-3 w-3" />
+ <span className="sr-only">Edit this comment</span>
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>Edit</p>
+ </TooltipContent>
+ </Tooltip>
) : null}
{isAuthor ? (
- <CommentDeleteDialog asChild comment={comment}>
- <button className="flex cursor-pointer items-center gap-1 text-neutral-500 duration-200 hover:text-neutral-400 dark:text-neutral-400 dark:hover:text-neutral-300">
- <Trash2 className="h-3 w-3" />
- <div className="hidden text-[0.8rem] sm:block">Delete</div>
- </button>
- </CommentDeleteDialog>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <CommentDeleteDialog asChild comment={comment}>
+ <Button variant="secondary" size="xs">
+ <Trash2 className="h-3 w-3" />
+ <span className="sr-only">Delete this comment</span>
+ </Button>
+ </CommentDeleteDialog>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>Delete</p>
+ </TooltipContent>
+ </Tooltip>
) : (
- <ReportDialog commentId={comment.id} reportType="COMMENT">
- <div className="flex cursor-pointer items-center text-[0.8rem] text-neutral-500 duration-200 hover:text-neutral-400 dark:text-neutral-400 dark:hover:text-neutral-300">
- Report
- </div>
- </ReportDialog>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <ReportDialog triggerAsChild commentId={comment.id} reportType="COMMENT">
+ <Button variant="secondary" size="xs">
+ <span className="hidden text-[0.8rem] sm:block">Flag</span>
+ <span className="sr-only">Report this comment</span>
+ </Button>
+ </ReportDialog>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>Report</p>
+ </TooltipContent>
+ </Tooltip>
)}
{comment._count.replies > 0 && (
- <button
- className="z-50 flex cursor-pointer items-center gap-1 text-neutral-500 duration-200 hover:text-neutral-400 dark:text-neutral-400 dark:hover:text-neutral-300"
+ <Button
+ variant="ghost"
+ size="xs"
+ className="z-50 ml-auto gap-1"
onClick={onClickToggleReply}
>
{isToggleReply ? (
@@ -480,7 +516,8 @@ function SingleComment({
<div className="text-xs">
{comment._count.replies === 1 ? '1 reply' : `${comment._count.replies} replies`}
</div>
- </button>
+ <span className="sr-only">Toggle replies view</span>
+ </Button>
)}
</>
)}
diff --git a/apps/web/src/app/[locale]/challenge/_components/description/index.tsx b/apps/web/src/app/[locale]/challenge/_components/description/index.tsx
index 220ba204..96930225 100644
--- a/apps/web/src/app/[locale]/challenge/_components/description/index.tsx
+++ b/apps/web/src/app/[locale]/challenge/_components/description/index.tsx
@@ -1,8 +1,8 @@
'use client';
import { useSession } from '@repo/auth/react';
-import { Bookmark as BookmarkIcon, Flag, Share } from '@repo/ui/icons';
-import { clsx } from 'clsx';
+import { Bookmark as BookmarkIcon, Calendar, Flag, Share } from '@repo/ui/icons';
+import clsx from 'clsx';
import { debounce } from 'lodash';
import Link from 'next/link';
import { useRef, useState } from 'react';
@@ -57,7 +57,7 @@ export function Description({ challenge }: Props) {
return (
<div className="custom-scrollable-element h-full overflow-y-auto px-4 pb-36 pt-3">
- <div className="flex items-center gap-3">
+ <div className="flex items-center">
<TypographyH3 className="mr-auto max-w-[75%] items-center truncate text-2xl font-bold">
{challenge.name}
</TypographyH3>
@@ -79,27 +79,37 @@ export function Description({ challenge }: Props) {
{/* Author & Time */}
<div className="mt-2 flex items-center gap-4">
<UserBadge username={challenge.user.name} linkComponent={Link} />
- <span className="text-muted-foreground -ml-1 text-xs">
- {getRelativeTime(challenge.updatedAt)}
- </span>
+ <div className="text-muted-foreground flex items-center gap-2">
+ <Calendar className=" h-4 w-4" />
+ <span className="text-xs">{getRelativeTime(challenge.updatedAt)}</span>
+ </div>
</div>
{/* Difficulty & Action Buttons */}
<div className="mt-3 flex items-center gap-3">
<DifficultyBadge difficulty={challenge.difficulty} />
+ <Vote
+ voteCount={challenge._count.vote}
+ initialHasVoted={challenge.vote.length > 0}
+ disabled={!session?.data?.user?.id}
+ rootType="CHALLENGE"
+ rootId={challenge?.id}
+ />
<Dialog>
<DialogTrigger>
<Tooltip>
<TooltipTrigger asChild>
- <Share className="h-4 w-4 stroke-zinc-500 group-hover:stroke-zinc-600 dark:stroke-zinc-300 group-hover:dark:stroke-zinc-100" />
+ <Button className="text-accent-foreground" size="xs" variant="secondary">
+ <Share className="h-4 w-4" />
+ </Button>
</TooltipTrigger>
<TooltipContent>
- <p>Share challenge</p>
+ <p>Share</p>
</TooltipContent>
</Tooltip>
</DialogTrigger>
<DialogContent>
<DialogHeader>
- <DialogTitle>Share this challenge</DialogTitle>
+ <DialogTitle>Share</DialogTitle>
</DialogHeader>
<div className="pt-4">
<ShareForm />
@@ -109,7 +119,14 @@ export function Description({ challenge }: Props) {
<Tooltip>
<TooltipTrigger asChild>
<Button
- className="group flex h-6 items-center rounded-full bg-zinc-200 px-3 focus:outline-none focus-visible:ring-2 disabled:cursor-not-allowed disabled:bg-zinc-100 dark:bg-zinc-700 disabled:dark:bg-zinc-700/50"
+ variant="secondary"
+ size="xs"
+ className={clsx(
+ 'border border-transparent [&:not(:disabled)]:hover:border-blue-500 [&:not(:disabled)]:hover:text-blue-500',
+ {
+ 'border-blue-500 text-blue-500': hasBookmarked,
+ },
+ )}
disabled={!session.data?.user.id}
onClick={() => {
let shouldBookmark = false;
@@ -127,29 +144,13 @@ export function Description({ challenge }: Props) {
);
}}
>
- <BookmarkIcon
- className={clsx(
- {
- 'stroke-blue-500': hasBookmarked,
- 'stroke-zinc-500 group-hover:stroke-zinc-600 group-disabled:stroke-zinc-300 dark:stroke-zinc-300 group-hover:dark:stroke-zinc-100 group-disabled:dark:stroke-zinc-500/50':
- !hasBookmarked,
- },
- 'h-4 w-4',
- )}
- />
+ <BookmarkIcon className="h-4 w-4" />
</Button>
</TooltipTrigger>
<TooltipContent>
<p>{session.data?.user.id ? 'Bookmark' : 'Login to Bookmark'}</p>
</TooltipContent>
</Tooltip>
- <Vote
- voteCount={challenge._count.vote}
- initialHasVoted={challenge.vote.length > 0}
- disabled={!session?.data?.user?.id}
- rootType="CHALLENGE"
- rootId={challenge?.id}
- />
</div>
{/* Challenge Description */}
<div className="prose-invert prose-h3:text-xl mt-6 leading-8">
diff --git a/apps/web/src/app/[locale]/challenge/_components/vote.tsx b/apps/web/src/app/[locale]/challenge/_components/vote.tsx
index 51fabf14..5b254f05 100644
--- a/apps/web/src/app/[locale]/challenge/_components/vote.tsx
+++ b/apps/web/src/app/[locale]/challenge/_components/vote.tsx
@@ -41,7 +41,14 @@ export function Vote({
<Tooltip>
<TooltipTrigger asChild>
<Button
- className="group flex h-6 items-center gap-1 rounded-full bg-zinc-200 py-0 pl-[0.675rem] pr-2 text-sm focus:outline-none focus-visible:ring-2 disabled:cursor-not-allowed disabled:bg-zinc-100 dark:bg-zinc-700 disabled:dark:bg-zinc-700/50"
+ className={clsx(
+ 'gap-2 border border-transparent [&:not(:disabled)]:hover:border-emerald-600 [&:not(:disabled)]:hover:text-emerald-600',
+ {
+ 'border-emerald-600 text-emerald-600': hasVoted,
+ },
+ )}
+ variant="secondary"
+ size="xs"
disabled={disabled}
onClick={() => {
let shouldIncrement = false;
@@ -67,29 +74,8 @@ export function Vote({
});
}}
>
- <ThumbsUp
- className={clsx(
- {
- 'stroke-emerald-600 group-hover:stroke-emerald-600 dark:stroke-emerald-400 group-hover:dark:stroke-emerald-400':
- hasVoted,
- 'stroke-zinc-500 group-hover:stroke-zinc-600 group-disabled:stroke-zinc-300 dark:stroke-zinc-300 group-hover:dark:stroke-zinc-100 group-disabled:dark:stroke-zinc-500/50':
- !hasVoted,
- },
- 'my-auto h-4 w-4 duration-200',
- )}
- />
- <span
- className={clsx(
- {
- 'text-emerald-600 dark:text-emerald-400': hasVoted,
- 'text-zinc-500 group-hover:text-zinc-600 group-disabled:text-zinc-300 dark:text-zinc-300 group-hover:dark:text-zinc-100 group-disabled:dark:text-zinc-500/50':
- !hasVoted,
- },
- 'my-auto w-4 self-end duration-300',
- )}
- >
- {votes}
- </span>
+ <ThumbsUp className="h-4 w-4" />
+ <span className="font-bold">{votes}</span>
</Button>
</TooltipTrigger>
<TooltipContent>
diff --git a/apps/web/tests/e2e/authenticated/comment.test.ts b/apps/web/tests/e2e/authenticated/comment.test.ts
index 36c6c859..bf0f5478 100644
--- a/apps/web/tests/e2e/authenticated/comment.test.ts
+++ b/apps/web/tests/e2e/authenticated/comment.test.ts
@@ -32,7 +32,7 @@ test.describe('create, edit, and delete comments', () => {
const commentBlock = page.locator('div[id^=comment]', {
hasText: `${parentComment} ${parentCodeText}`,
});
- await commentBlock.getByRole('button', { name: 'Reply' }).click();
+ await commentBlock.getByRole('button', { name: 'Create a reply' }).click();
await page.locator('*:focus').fill(`${replyComment}${wrapTypescriptCode(replyCodeText)}`);
await page.getByRole('button', { name: 'Comment', exact: true, disabled: false }).click();
@@ -44,7 +44,7 @@ test.describe('create, edit, and delete comments', () => {
const commentBlock = page.locator('div[id^=comment]', {
hasText: `${parentComment} ${parentCodeText}`,
});
- await commentBlock.getByRole('button', { name: 'Edit' }).click();
+ await commentBlock.getByRole('button', { name: 'Edit this comment' }).click();
await page
.locator('*:focus')
@@ -63,7 +63,7 @@ test.describe('create, edit, and delete comments', () => {
const replyBlock = page.locator('div[id^=comment]', {
hasText: `${replyComment} ${replyCodeText}`,
});
- await replyBlock.getByRole('button', { name: 'Edit' }).click();
+ await replyBlock.getByRole('button', { name: 'Edit this comment' }).click();
await page.locator('*:focus').fill(`${editedReplyComment}${wrapTypescriptCode(replyCodeText)}`);
await page.getByRole('button', { name: 'Comment', exact: true, disabled: false }).click();
@@ -80,7 +80,7 @@ test.describe('create, edit, and delete comments', () => {
const replyBlock = page.locator('div[id^=comment]', {
hasText: `${editedReplyComment} ${replyCodeText}`,
});
- await replyBlock.getByRole('button', { name: 'Delete' }).click();
+ await replyBlock.getByRole('button', { name: 'Delete this comment' }).click();
await page.getByRole('button', { name: 'Delete' }).click();
await expect(
@@ -92,7 +92,7 @@ test.describe('create, edit, and delete comments', () => {
const commentBlock = page.locator('div[id^=comment]', {
hasText: `${editedParentComment} ${parentCodeText}`,
});
- await commentBlock.getByRole('button', { name: 'Delete' }).click();
+ await commentBlock.getByRole('button', { name: 'Delete this comment' }).click();
await page.getByRole('button', { name: 'Delete' }).click();
await expect(
@@ -118,7 +118,7 @@ test.describe('share comment', () => {
await page.getByRole('button', { name: 'Comments' }).click();
const commentBlock = page.locator('div[id^=comment]', { hasText: parentComment });
- await commentBlock.getByText('Share').click();
+ await commentBlock.getByText('Share this comment').click();
await page.getByPlaceholder('Enter your comment here.').focus();
await ctrlV(page);
diff --git a/packages/ui/src/components/badge.tsx b/packages/ui/src/components/badge.tsx
index 3ceab79f..763256af 100644
--- a/packages/ui/src/components/badge.tsx
+++ b/packages/ui/src/components/badge.tsx
@@ -5,20 +5,25 @@ import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '../cn';
const badgeVariants = cva(
- 'inline-flex items-center border rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-0',
+ 'inline-flex items-center border rounded-full font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-0',
{
variants: {
variant: {
- default: 'bg-primary hover:bg-primary/80 border-transparent text-primary-foreground',
- secondary:
- 'bg-secondary hover:bg-secondary/80 border-transparent text-secondary-foreground',
- destructive:
- 'bg-destructive hover:bg-destructive/80 border-transparent text-destructive-foreground',
+ default: 'bg-primary border-transparent text-primary-foreground',
+ secondary: 'bg-secondary border-transparent text-secondary-foreground',
+ destructive: 'bg-destructive border-transparent text-destructive-foreground',
outline: 'text-foreground',
},
+ size: {
+ default: 'px-2.5 py-0.5 text-xs',
+ xs: 'px-0 py-0 text-xs',
+ sm: 'px-1 text-xs',
+ lg: 'px-2.5 py-0.5 text-sm',
+ },
},
defaultVariants: {
variant: 'default',
+ size: 'default',
},
},
);
diff --git a/packages/ui/src/components/button.tsx b/packages/ui/src/components/button.tsx
index 6390a3f4..f163f2ba 100644
--- a/packages/ui/src/components/button.tsx
+++ b/packages/ui/src/components/button.tsx
@@ -18,6 +18,7 @@ const buttonVariants = cva(
},
size: {
default: 'h-10 py-2 px-4',
+ xs: 'h-6 px-2 rounded-full text-xs', // pill-shaped
sm: 'h-9 px-3 rounded-md',
lg: 'h-11 px-8 rounded-md',
},
diff --git a/packages/ui/src/components/user-badge.tsx b/packages/ui/src/components/user-badge.tsx
index 1e5810cf..424f5669 100644
--- a/packages/ui/src/components/user-badge.tsx
+++ b/packages/ui/src/components/user-badge.tsx
@@ -14,10 +14,7 @@ function UserBadge(props: UserBadgeProps) {
<Tooltip>
<TooltipTrigger asChild>
<Link href={`/@${props.username}`} className="focus:outline-none focus-visible:ring-0">
- <Button
- className="-ml-[0.33rem] flex h-auto w-fit items-center rounded-full bg-transparent py-1 pl-[0.33rem] pr-2 text-xs font-bold text-neutral-700 hover:bg-black/10 dark:text-white dark:hover:bg-white/20"
- size="sm"
- >
+ <Button className="-ml-2 font-bold" variant="ghost" size="xs">
@{props.username}
</Button>
</Link>