Skip to content

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

comment length warning & other things, resolves #221 (#231)

PickleNikdeab643c9535
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index fa29f652..f63e27b9 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -204,7 +204,7 @@ model ChallengeComment {
userId String
challenge Challenge @relation(fields: [challengeId], references: [id])
challengeId Int
- text String
+ text String @db.VarChar(1000)
visibility Visibility @default(VISIBLE)
replies ChallengeReply[]
CommentReport CommentReport[]
@@ -233,7 +233,7 @@ model SolutionComment {
userId String
solution SharedSolution @relation(fields: [solutionId], references: [id])
solutionId Int
- text String
+ text String @db.VarChar(1000)
visibility Visibility @default(VISIBLE)
solutionReply SolutionReply[]
CommentReport CommentReport[]
diff --git a/src/app/challenge/[id]/page.tsx b/src/app/challenge/[id]/page.tsx
index a2ab320c..47707185 100644
--- a/src/app/challenge/[id]/page.tsx
+++ b/src/app/challenge/[id]/page.tsx
@@ -20,13 +20,8 @@ export default async function Challenges({ params: { id } }: Props) {
return (
<div className="relative flex h-full flex-col justify-between">
- <div className="px-4 py-3">
- <Description challenge={challenge}></Description>
- </div>
-
- <div className="sticky bottom-0 -mx-[1px] overflow-hidden rounded-xl border border-zinc-300 border-b-background bg-background/90 shadow-[0_0_3rem_-0.25rem_#0004] backdrop-blur-sm duration-300 dark:border-zinc-700 dark:border-b-muted dark:bg-muted/90 dark:shadow-[0_0_3rem_-0.25rem_#0008]">
- <Comments challengeId={challenge.id} commentCount={challenge.comment.length} />
- </div>
+ <Description challenge={challenge}></Description>
+ <Comments challengeId={challenge.id} commentCount={challenge.comment.length} />
</div>
);
}
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 0560d045..b36a979a 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -12,21 +12,19 @@ export default async function Index() {
/>
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
</Head>
- <div className="relative mb-[56px] flex min-h-[calc(100dvh-112px)] flex-col items-center justify-center gap-4 overflow-x-hidden overflow-y-visible px-4">
- <div className="absolute left-1/2 top-1/2 -z-10 hidden h-64 w-64 -translate-x-[30%] -translate-y-[69%] rounded-full bg-white/20 blur-3xl dark:block lg:h-96 lg:w-96"></div>
- <div className="absolute right-1/2 top-1/2 -z-10 hidden h-64 w-64 -translate-y-[69%] translate-x-[30%] rounded-full bg-[#3178c6]/20 blur-3xl dark:block lg:h-96 lg:w-96"></div>
- <h1 className="bg-gradient-to-r from-[#3178c6] to-black bg-clip-text text-center text-9xl font-black text-transparent dark:to-white">
+ <div className="mb-[56px] flex min-h-[calc(100dvh-112px)] flex-col items-center justify-center gap-24 overflow-x-hidden overflow-y-visible px-8 py-24">
+ <h1 className="relative bg-gradient-to-r from-[#3178c6] to-black bg-clip-text text-center text-8xl font-black text-transparent dark:to-white md:text-9xl">
+ <div className="absolute left-1/2 top-1/2 -z-10 hidden h-56 w-56 -translate-x-[30%] -translate-y-1/2 rounded-full bg-white/20 blur-2xl dark:block lg:h-96 lg:w-96 lg:blur-3xl"></div>
+ <div className="absolute right-1/2 top-1/2 -z-10 hidden h-56 w-56 -translate-y-1/2 translate-x-[30%] rounded-full bg-[#3178c6]/20 blur-2xl dark:block lg:h-96 lg:w-96 lg:blur-3xl"></div>
Type
<br />
Hero
</h1>
- <p className="font-bold">πŸ’ͺ Challenge 🧠 Learn πŸ“ˆ Excel</p>
-
- <p className="max-w-[80ch] bg-transparent text-center text-neutral-600 dark:text-neutral-400">
- Connect and collaborate with a community of TypeScript developers on Type Hero. Engage in
- discussions, create challenges, and share insights with fellow typescript enthusiasts.
- Type Hero has collaborative coding challenges that foster a supportive and inspiring
- environment, where you can learn from others and showcase your expertise.
+ <p className="mx-auto max-w-[67ch] bg-transparent text-lg leading-9 text-neutral-600 dark:text-neutral-500">
+ &emsp;Connect and collaborate with a community of TypeScript developers on Type Hero.
+ Engage in discussions, create challenges, and share insights with fellow typescript
+ enthusiasts. Type Hero has collaborative coding challenges that foster a supportive and
+ inspiring environment, where you can learn from others and showcase your expertise.
</p>
</div>
<Footsies />
diff --git a/src/components/challenge/comment-skeleton.tsx b/src/components/challenge/comments/comment-skeleton.tsx
similarity index 100%
rename from src/components/challenge/comment-skeleton.tsx
rename to src/components/challenge/comments/comment-skeleton.tsx
diff --git a/src/components/challenge/comments/comment.tsx b/src/components/challenge/comments/comment.tsx
index 406ff442..487badb5 100644
--- a/src/components/challenge/comments/comment.tsx
+++ b/src/components/challenge/comments/comment.tsx
@@ -1,6 +1,6 @@
'use client';
import { zodResolver } from '@hookform/resolvers/zod';
-import { Delete } from 'lucide-react';
+import { Delete, Trash2, Reply } from 'lucide-react';
import { useState } from 'react';
import { useForm } from 'react-hook-form';
import { z } from 'zod';
@@ -16,6 +16,8 @@ import { toast } from '~/components/ui/use-toast';
import { reportChallengeComment } from './comment.action';
import { Tooltip, TooltipContent, TooltipTrigger } from '~/components/ui/tooltip';
import { UserBadge } from '~/components/ui/user-badge';
+import { useSession } from 'next-auth/react';
+// import { Markdown } from '~/components/ui/markdown';
interface CommentProps {
comment: ChallengeRouteData['comment'][number];
@@ -91,54 +93,82 @@ const Comment = ({ comment }: CommentProps) => {
const text = form.watch('text');
+ const loggedinUser = useSession();
+
+ const isAuthor = loggedinUser.data?.user?.id === comment.user.id;
+
return (
- <div className="flex cursor-pointer flex-col gap-2 p-4 pt-2 duration-300 hover:bg-neutral-100 dark:rounded-none dark:hover:bg-zinc-700/50">
- <div className="flex justify-between">
- <div className="flex items-center gap-2">
- <UserBadge username={comment.user.name} />
+ <div className="flex flex-col gap-1 p-3 pt-2">
+ <div className="flex justify-between pr-[0.4rem]">
+ <div className="flex items-center gap-1">
+ <UserBadge username={comment.user.name ?? ''} />
<Tooltip delayDuration={0.05}>
<TooltipTrigger asChild>
<span className="text-sm text-neutral-500">{getRelativeTime(comment.createdAt)}</span>
</TooltipTrigger>
- <TooltipContent>
- <span className="text-white-500 text-sm">{comment.createdAt.toLocaleString()}</span>
+ <TooltipContent align="start" className="rounded-xl">
+ <span className="text-white-500 text-xs">{comment.createdAt.toLocaleString()}</span>
</TooltipContent>
</Tooltip>
</div>
- <button
- onClick={() => {
- setDialogOpen(true);
- }}
- className="flex text-sm text-neutral-400 hover:text-neutral-400 hover:underline dark:text-neutral-600"
- >
- Report
- </button>
+
+ <div className="flex gap-2">
+ {/* TODO: make dis work */}
+ <button className="flex cursor-pointer items-center gap-1 text-sm text-neutral-400 duration-200 hover:text-neutral-500 hover:underline dark:text-neutral-600 dark:hover:text-neutral-500">
+ <Reply className="h-3 w-3" />
+ Reply
+ </button>
+ {/* TODO: make dis work */}
+ {isAuthor ? (
+ <button className="flex cursor-pointer items-center gap-1 text-sm text-neutral-400 duration-200 hover:text-neutral-500 hover:underline dark:text-neutral-600 dark:hover:text-neutral-500">
+ <Trash2 className="h-3 w-3" />
+ Delete
+ </button>
+ ) : (
+ <button
+ onClick={() => {
+ setDialogOpen(true);
+ }}
+ className="flex cursor-pointer items-center text-sm text-neutral-400 duration-200 hover:text-neutral-500 hover:underline dark:text-neutral-600 dark:hover:text-neutral-500"
+ >
+ Report
+ </button>
+ )}
+ </div>
</div>
- <p className="w-full break-words">{comment.text}</p>
+ <p className="w-full break-words pl-[1px] text-sm">
+ {/* TODO: <code></code> is <Markdown /> does not wrap long lines causing overflow */}
+ {/* <Markdown>{comment.text}</Markdown> */}
+ {comment.text}
+ </p>
<Dialog
open={dialogOpen}
onOpenChange={() => {
setDialogOpen(!dialogOpen);
}}
>
+ {/* TODO: make a separate component */}
<DialogContent className="max-w-lg">
<DialogHeader>
<DialogTitle>Report Comment</DialogTitle>
</DialogHeader>
<div className="space-y-2">
- <div className="flex flex-col space-y-2 rounded-3xl border bg-zinc-900 p-3">
- <div className="flex items-center gap-2">
+ <div className="flex flex-col space-y-2 rounded-3xl border p-3 dark:bg-zinc-900">
+ {/* TODO: use comment template component inside this new separate component */}
+ <div className="flex items-center gap-1">
<UserBadge username={comment.user.name} />
<Tooltip>
<span className="text-sm text-neutral-500">
{getRelativeTime(comment.createdAt)}
</span>
- <TooltipContent>
- <p>Add to library</p>
+ <TooltipContent className="rounded-xl">
+ <span className="text-white-500 text-sm">
+ {comment.createdAt.toLocaleString()}
+ </span>
</TooltipContent>
</Tooltip>
</div>
- <p>{comment.text}</p>
+ <p className="max-h-[30vh] overflow-y-auto">{comment.text}</p>
</div>
<Form {...form}>
{/* eslint-disable-next-line @typescript-eslint/no-misused-promises */}
diff --git a/src/components/challenge/comments/index.tsx b/src/components/challenge/comments/index.tsx
index 8c73b1e9..cd29e5c0 100644
--- a/src/components/challenge/comments/index.tsx
+++ b/src/components/challenge/comments/index.tsx
@@ -1,19 +1,21 @@
'use client';
import clsx from 'clsx';
-import { ChevronDown, MessageCircle } from 'lucide-react';
+import { ChevronDown, MessageCircle, Loader2, Code, Link2 } from 'lucide-react';
import { useRouter } from 'next/navigation';
import { useEffect, useState } from 'react';
import Comment from '~/components/challenge/comments/comment';
import { Button } from '~/components/ui/button';
import { toast } from '~/components/ui/use-toast';
-import NoComments from '../nocomments';
+import NoComments from './nocomments';
import { addChallengeComment } from './comment.action';
import { Textarea } from '~/components/ui/textarea';
import { useInfiniteQuery } from '@tanstack/react-query';
import { useInView } from 'react-intersection-observer';
import { getInfiniteComments } from './getCommentRouteData';
-import { CommentSkeleton } from '../comment-skeleton';
+import { CommentSkeleton } from './comment-skeleton';
+
+const MAX_COMMENT_LENGTH = 1000;
interface Props {
challengeId: number;
@@ -77,62 +79,100 @@ const Comments = ({ challengeId, commentCount }: Props) => {
}, [hasNextPage, inView, fetchNextPage]);
return (
- <div className="relative">
- <button
- className="flex w-full items-center justify-between gap-2 p-3 font-medium text-neutral-500 duration-300 hover:text-neutral-700 dark:hover:text-zinc-300"
- onClick={() => handleClick()}
- >
- <div className="flex items-center">
- <MessageCircle className="h-5 w-5"></MessageCircle>
- &nbsp; Comments ({commentCount})
- </div>
- <ChevronDown
- className={clsx('h-4 w-4 duration-300', {
- '-rotate-180': !showComments,
+ <div
+ className={clsx(
+ 'sticky bottom-0 overflow-hidden border-zinc-300 bg-background/90 shadow-[0_0_3rem_-0.25rem_#0004] backdrop-blur-sm duration-300 dark:border-zinc-700 dark:border-b-muted dark:bg-muted/90 dark:shadow-[0_0_3rem_-0.25rem_#0008]',
+ {
+ 'border-t': !showComments,
+ },
+ )}
+ >
+ <div className="relative">
+ <button
+ className="flex w-full items-center justify-between gap-2 p-3 font-medium text-neutral-500 duration-300 hover:text-neutral-700 focus:outline-none dark:hover:text-zinc-300"
+ onClick={() => handleClick()}
+ >
+ <div className="flex items-center gap-2">
+ <MessageCircle className="h-5 w-5"></MessageCircle>
+ Comments ({commentCount})
+ </div>
+ <ChevronDown
+ className={clsx('h-4 w-4 duration-300', {
+ '-rotate-180': !showComments,
+ })}
+ ></ChevronDown>
+ </button>
+ <div
+ className={clsx('flex flex-col-reverse overscroll-contain duration-300', {
+ 'h-[64] pb-2 md:h-[calc(100vh_-_247px)]': showComments,
+ 'h-0 overflow-y-hidden': !showComments,
+ 'overflow-y-auto': showComments && data?.pages[0]?.data.length !== 0,
})}
- ></ChevronDown>
- </button>
- <div
- className={clsx('flex flex-col-reverse overscroll-contain duration-300', {
- 'h-64 overflow-y-auto': showComments,
- 'h-0 overflow-y-hidden': !showComments,
- })}
- >
- {(status === 'loading' || isFetchingNextPage) && <CommentSkeleton />}
- {status === 'success' &&
- (data?.pages[0]?.data.length === 0 ? (
- <NoComments></NoComments>
- ) : (
- data?.pages.map((page) =>
- page.data.map((comment, index) =>
- page.data.length === index + 1 ? (
- <div ref={ref} key={index}>
+ >
+ {(status === 'loading' || isFetchingNextPage) && <CommentSkeleton />}
+ {status === 'success' &&
+ (data?.pages[0]?.data.length === 0 ? (
+ <NoComments />
+ ) : (
+ data?.pages.map((page) =>
+ page.data.map((comment, index) =>
+ page.data.length === index + 1 ? (
+ <div ref={ref} key={index}>
+ <Comment key={comment.id} comment={comment} />
+ </div>
+ ) : (
<Comment key={comment.id} comment={comment} />
- </div>
- ) : (
- <Comment key={comment.id} comment={comment} />
+ ),
),
- ),
- )
- ))}
- </div>
- <div className="m-2 mt-0 flex items-end justify-between gap-2 rounded-xl bg-background/90 bg-neutral-100 p-1 pr-2 backdrop-blur-sm dark:border-zinc-700 dark:bg-zinc-700/90">
- <Textarea
- value={text}
- onChange={(e) => {
- setText(e.target.value);
- }}
- onKeyDown={handleEnterKey}
- rows={2}
- className="min-h-0 resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0"
- placeholder="Enter your comment here."
- />
- <Button
- onClick={createChallengeComment}
- className="h-8 rounded-lg bg-emerald-600 px-3 py-2 hover:bg-emerald-500 dark:bg-emerald-400 dark:hover:bg-emerald-300"
- >
- Comment
- </Button>
+ )
+ ))}
+ </div>
+ <div className="relative m-2 mt-0 flex items-end justify-between rounded-xl rounded-br-lg bg-background/90 bg-neutral-100 backdrop-blur-sm dark:border-zinc-700 dark:bg-zinc-700/90">
+ <Textarea
+ value={text}
+ onChange={(e) => {
+ setText(e.target.value);
+ }}
+ onKeyDown={handleEnterKey}
+ rows={3}
+ className="min-h-0 resize-none border-0 px-3 py-2 focus-visible:ring-0 focus-visible:ring-offset-0"
+ placeholder="Enter your comment here."
+ />
+ <Code className="absolute bottom-0 left-1 h-7 w-7 cursor-pointer stroke-gray-500 p-2 duration-150 hover:stroke-gray-600 dark:stroke-zinc-400 dark:hover:stroke-zinc-300"></Code>
+ <Link2 className="absolute bottom-0 left-7 h-7 w-7 cursor-pointer stroke-gray-500 p-2 duration-150 hover:stroke-gray-600 dark:stroke-zinc-400 dark:hover:stroke-zinc-300"></Link2>
+ <div className="flex flex-col items-end justify-end gap-2 p-2">
+ <div
+ className={`text-sm ${
+ text.length > MAX_COMMENT_LENGTH
+ ? 'text-red-600 dark:text-red-400'
+ : text.length > MAX_COMMENT_LENGTH * 0.9
+ ? 'text-amber-600 dark:text-amber-400'
+ : 'text-neutral-500 dark:text-zinc-500'
+ }`}
+ >
+ {text.length}/{MAX_COMMENT_LENGTH}
+ </div>
+ {/* TODO: add disabled state with tooltip prompting to log in if user is logged out */}
+ <Button
+ disabled={text.length > MAX_COMMENT_LENGTH || text.length === 0 || isCommenting}
+ onClick={createChallengeComment}
+ className={`h-8 w-[5.5rem] rounded-lg rounded-br-sm
+ px-3 py-2 ${
+ text.length > MAX_COMMENT_LENGTH
+ ? 'bg-red-600 hover:bg-red-500 dark:bg-red-400 dark:hover:bg-red-300'
+ : 'bg-emerald-600 hover:bg-emerald-500 dark:bg-emerald-400 dark:hover:bg-emerald-300'
+ }`}
+ >
+ {isCommenting ? (
+ <Loader2 className="h-5 w-5 animate-spin" />
+ ) : text.length > MAX_COMMENT_LENGTH ? (
+ 'Too Long'
+ ) : (
+ 'Comment'
+ )}
+ </Button>
+ </div>
+ </div>
</div>
</div>
);
diff --git a/src/components/challenge/nocomments.tsx b/src/components/challenge/comments/nocomments.tsx
similarity index 100%
rename from src/components/challenge/nocomments.tsx
rename to src/components/challenge/comments/nocomments.tsx
diff --git a/src/components/challenge/description/index.tsx b/src/components/challenge/description/index.tsx
index 0604b002..0fdf7e82 100644
--- a/src/components/challenge/description/index.tsx
+++ b/src/components/challenge/description/index.tsx
@@ -132,7 +132,7 @@ export function Description({ challenge }: Props) {
}
}
return (
- <>
+ <div className="px-4 py-3">
<div className="flex items-baseline justify-between">
<TypographyH3 className="mb-2 flex items-center gap-2 font-medium">
{challenge.name}
@@ -352,6 +352,6 @@ export function Description({ challenge }: Props) {
<div className="prose-invert leading-8 prose-h3:text-xl">
<Markdown>{challenge.description}</Markdown>
</div>
- </>
+ </div>
);
}
diff --git a/src/components/challenge/solutions/index.tsx b/src/components/challenge/solutions/index.tsx
index 8169b1c6..85f47162 100644
--- a/src/components/challenge/solutions/index.tsx
+++ b/src/components/challenge/solutions/index.tsx
@@ -1,7 +1,5 @@
'use client';
-import { ArrowUp, MessageCircle, Plus } from 'lucide-react';
-
-import { Button } from '~/components/ui/button';
+import { ArrowUp, MessageCircle } from 'lucide-react';
import { useSession } from 'next-auth/react';
import Link from 'next/link';
@@ -9,6 +7,9 @@ import { useState } from 'react';
import type { ChallengeSolutionsRouteData } from '~/app/challenge/[id]/solutions/page';
import { getRelativeTime } from '~/utils/relativeTime';
import { SolutionEditor } from './solution-editor';
+import { UserBadge } from '~/components/ui/user-badge';
+import NoSolutions from './nosolutions';
+import SubmitSolution from './submit-solution';
interface Props {
challenge: ChallengeSolutionsRouteData;
@@ -27,24 +28,30 @@ export function Solutions({ challenge }: Props) {
{view === 'list' && (
<>
- <div className="sticky right-0 top-[41px] flex justify-end border-b border-zinc-300 bg-background/90 p-2 backdrop-blur-sm dark:border-zinc-700 dark:bg-muted/90">
- <Button
- className="h-8 rounded-lg bg-emerald-600 px-3 py-2 hover:bg-emerald-500 dark:bg-emerald-400 dark:hover:bg-emerald-300"
- onClick={() => setView('editor')}
- disabled={!loggedInUserHasSolution || !session?.data?.user}
- >
- <Plus className="mr-2 h-4 w-4" /> Solution
- </Button>
- </div>
- {challenge?.sharedSolution.map((solution) => (
- <SolutionRow
- key={solution.id}
- solution={solution}
- handleClick={() => {
- setView('details');
- }}
+ {challenge.sharedSolution.length !== 0 ? (
+ <>
+ {(loggedInUserHasSolution || !session?.data?.user) && (
+ <div className="sticky right-0 top-[41px] flex justify-end border-b border-zinc-300 bg-background/90 p-2 backdrop-blur-sm dark:border-zinc-700 dark:bg-muted/90">
+ <SubmitSolution setView={setView} />
+ </div>
+ )}
+ {challenge?.sharedSolution.map((solution) => (
+ <SolutionRow
+ key={solution.id}
+ solution={solution}
+ handleClick={() => {
+ setView('details');
+ }}
+ />
+ ))}
+ </>
+ ) : (
+ <NoSolutions
+ setView={setView}
+ loggedInUser={session?.data?.user ? true : false}
+ loggedInUserHasSolution={loggedInUserHasSolution > 0 ? true : false}
/>
- ))}
+ )}
</>
)}
@@ -60,23 +67,24 @@ function SolutionRow({
solution: ChallengeSolutionsRouteData['sharedSolution'][0];
}) {
return (
- <Link href={`/challenge/${solution.challengeId}/solutions/${solution.id}`}>
- <div className="group flex cursor-pointer flex-col gap-2 p-4 duration-300 hover:bg-neutral-100 dark:rounded-none dark:hover:bg-zinc-700/50">
- <div className="flex items-center justify-between">
- <h3 className="font-bold">{solution.title}</h3>
- <div className="text-sm text-neutral-500">{getRelativeTime(solution.createdAt)}</div>
- </div>
- <div className="flex gap-3 text-neutral-600 duration-300 dark:text-neutral-400">
- <div className="my-auto mr-auto max-w-fit rounded-full bg-neutral-100 px-2 py-1 text-xs font-bold text-neutral-400 dark:bg-zinc-700 dark:text-neutral-400">
- @&nbsp;{solution.user?.name}
- </div>
- <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">
- <MessageCircle className="h-4 w-4 stroke-1" /> {solution._count.solutionComment}
- </button>
- <button className="flex cursor-pointer items-center gap-2 rounded-full bg-emerald-600/10 px-2 py-1 text-sm 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">
- <ArrowUp className="h-4 w-4 stroke-1" /> {solution._count.vote}
- </button>
+ <Link
+ className="group 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="font-bold">{solution.title}</h3>
+ <div className="flex items-center gap-1 text-neutral-600 dark:text-neutral-400">
+ <UserBadge username={solution.user?.name ?? ''} />
+ <div className="mr-auto text-sm text-neutral-500">
+ {getRelativeTime(solution.createdAt)}
</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>
</div>
</Link>
);
diff --git a/src/components/challenge/solutions/nosolutions.tsx b/src/components/challenge/solutions/nosolutions.tsx
new file mode 100644
index 00000000..27698e9c
--- /dev/null
+++ b/src/components/challenge/solutions/nosolutions.tsx
@@ -0,0 +1,67 @@
+import SubmitSolution from './submit-solution';
+
+interface Props {
+ loggedInUser: boolean;
+ loggedInUserHasSolution: boolean;
+ setView: (view: 'editor' | 'list') => void;
+}
+
+const NoSolutions = ({ setView, loggedInUser, loggedInUserHasSolution }: Props) => {
+ return (
+ <div className="flex h-full items-center justify-center">
+ <p className="flex flex-col items-center gap-2 text-center text-neutral-500 dark:text-zinc-400">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ data-name="Layer 1"
+ className="mr-6 h-28 w-28"
+ viewBox="0 0 647.63626 632.17383"
+ >
+ <path
+ d="M687.3279,276.08691H512.81813a15.01828,15.01828,0,0,0-15,15v387.85l-2,.61005-42.81006,13.11a8.00676,8.00676,0,0,1-9.98974-5.31L315.678,271.39691a8.00313,8.00313,0,0,1,5.31006-9.99l65.97022-20.2,191.25-58.54,65.96972-20.2a7.98927,7.98927,0,0,1,9.99024,5.3l32.5498,106.32Z"
+ transform="translate(-276.18187 -133.91309)"
+ fill="#4444"
+ />
+ <path
+ d="M725.408,274.08691l-39.23-128.14a16.99368,16.99368,0,0,0-21.23-11.28l-92.75,28.39L380.95827,221.60693l-92.75,28.4a17.0152,17.0152,0,0,0-11.28028,21.23l134.08008,437.93a17.02661,17.02661,0,0,0,16.26026,12.03,16.78926,16.78926,0,0,0,4.96972-.75l63.58008-19.46,2-.62v-2.09l-2,.61-64.16992,19.65a15.01489,15.01489,0,0,1-18.73-9.95l-134.06983-437.94a14.97935,14.97935,0,0,1,9.94971-18.73l92.75-28.4,191.24024-58.54,92.75-28.4a15.15551,15.15551,0,0,1,4.40966-.66,15.01461,15.01461,0,0,1,14.32032,10.61l39.0498,127.56.62012,2h2.08008Z"
+ transform="translate(-276.18187 -133.91309)"
+ fill="#888a"
+ />
+ <path
+ d="M398.86279,261.73389a9.0157,9.0157,0,0,1-8.61133-6.3667l-12.88037-42.07178a8.99884,8.99884,0,0,1,5.9712-11.24023l175.939-53.86377a9.00867,9.00867,0,0,1,11.24072,5.9707l12.88037,42.07227a9.01029,9.01029,0,0,1-5.9707,11.24072L401.49219,261.33887A8.976,8.976,0,0,1,398.86279,261.73389Z"
+ transform="translate(-276.18187 -133.91309)"
+ fill="#888a"
+ />
+ <circle cx="190.15351" cy="24.95465" r="20" fill="#888a" />
+ <circle cx="190.15351" cy="24.95465" r="12.66462" fill="#444a" />
+ <path
+ d="M878.81836,716.08691h-338a8.50981,8.50981,0,0,1-8.5-8.5v-405a8.50951,8.50951,0,0,1,8.5-8.5h338a8.50982,8.50982,0,0,1,8.5,8.5v405A8.51013,8.51013,0,0,1,878.81836,716.08691Z"
+ transform="translate(-276.18187 -133.91309)"
+ fill="#4444"
+ />
+ <path
+ d="M723.31813,274.08691h-210.5a17.02411,17.02411,0,0,0-17,17v407.8l2-.61v-407.19a15.01828,15.01828,0,0,1,15-15H723.93825Zm183.5,0h-394a17.02411,17.02411,0,0,0-17,17v458a17.0241,17.0241,0,0,0,17,17h394a17.0241,17.0241,0,0,0,17-17v-458A17.02411,17.02411,0,0,0,906.81813,274.08691Zm15,475a15.01828,15.01828,0,0,1-15,15h-394a15.01828,15.01828,0,0,1-15-15v-458a15.01828,15.01828,0,0,1,15-15h394a15.01828,15.01828,0,0,1,15,15Z"
+ transform="translate(-276.18187 -133.91309)"
+ fill="#888a"
+ />
+ <path
+ d="M801.81836,318.08691h-184a9.01015,9.01015,0,0,1-9-9v-44a9.01016,9.01016,0,0,1,9-9h184a9.01016,9.01016,0,0,1,9,9v44A9.01015,9.01015,0,0,1,801.81836,318.08691Z"
+ transform="translate(-276.18187 -133.91309)"
+ fill="#888a"
+ />
+ <circle cx="433.63626" cy="105.17383" r="20" fill="#888a" />
+ <circle cx="433.63626" cy="105.17383" r="12.18187" fill="#444a" />
+ </svg>
+ No solutions yet, <br />
+ {loggedInUser && loggedInUserHasSolution ? (
+ <>
+ be the first to submit one! <SubmitSolution setView={setView} />
+ </>
+ ) : (
+ 'complete the challenge to submit one!'
+ )}
+ </p>
+ </div>
+ );
+};
+
+export default NoSolutions;
diff --git a/src/components/challenge/solutions/submit-solution.tsx b/src/components/challenge/solutions/submit-solution.tsx
new file mode 100644
index 00000000..9d018284
--- /dev/null
+++ b/src/components/challenge/solutions/submit-solution.tsx
@@ -0,0 +1,19 @@
+import { Plus } from 'lucide-react';
+import { Button } from '~/components/ui/button';
+
+interface Props {
+ setView: (view: 'editor' | 'list') => void;
+}
+
+const SubmitSolution = ({ setView }: Props) => {
+ return (
+ <Button
+ className="h-8 rounded-lg bg-emerald-600 px-3 py-2 hover:bg-emerald-500 dark:bg-emerald-400 dark:hover:bg-emerald-300"
+ onClick={() => setView('editor')}
+ >
+ <Plus className="mr-2 h-4 w-4" /> Solution
+ </Button>
+ );
+};
+
+export default SubmitSolution;
diff --git a/src/components/challenge/submissions/index.tsx b/src/components/challenge/submissions/index.tsx
index 3fa58392..4af410d1 100644
--- a/src/components/challenge/submissions/index.tsx
+++ b/src/components/challenge/submissions/index.tsx
@@ -7,6 +7,7 @@ import { getRelativeTime } from '~/utils/relativeTime';
import Link from 'next/link';
import { useMemo, useState } from 'react';
import type { ChallengeSubmissions } from '~/app/challenge/[id]/submissions/page';
+import NoSubmissions from './nosubmissions';
interface Props {
submissions: ChallengeSubmissions;
@@ -26,39 +27,43 @@ export function Submissions({ submissions }: Props) {
}, [selectedStatus, submissions]);
return (
<>
- <div className="sticky right-0 top-[41px] flex gap-2 border-b border-zinc-300 bg-background/90 p-2 backdrop-blur-sm dark:border-zinc-700 dark:bg-muted/90">
- <div
- className={`flex cursor-pointer gap-2 rounded-xl px-4 py-1 duration-300 ${
- selectedStatus === 'all'
- ? 'bg-blue-600 text-background dark:bg-blue-400'
- : 'bg-blue-600/10 text-blue-600 hover:bg-blue-600/30 dark:bg-blue-400/10 dark:text-blue-400 dark:hover:bg-blue-400/30'
- }
+ {submissions.length !== 0 ? (
+ <div className="sticky right-0 top-[41px] flex gap-2 border-b border-zinc-300 bg-background/90 p-2 px-4 backdrop-blur-sm dark:border-zinc-700 dark:bg-muted/90">
+ <div
+ className={`flex cursor-pointer gap-2 rounded-lg px-4 py-1 duration-300 ${
+ selectedStatus === 'all'
+ ? 'bg-blue-600 text-background dark:bg-blue-400'
+ : 'bg-blue-600/10 text-blue-600 hover:bg-blue-600/30 dark:bg-blue-400/10 dark:text-blue-400 dark:hover:bg-blue-400/30'
+ }
`}
- onClick={() => setSelectStatus('all')}
- >
- All
- </div>
- <div
- className={`flex cursor-pointer gap-2 rounded-xl px-4 py-1 duration-300 ${
- selectedStatus === 'accepted'
- ? 'bg-emerald-600 text-background dark:bg-emerald-400'
- : 'bg-emerald-600/10 text-emerald-600 hover:bg-emerald-600/30 dark:bg-emerald-400/10 dark:text-emerald-400 dark:hover:bg-emerald-400/30'
- }`}
- onClick={() => setSelectStatus('accepted')}
- >
- Accepted
- </div>
- <div
- className={`flex cursor-pointer gap-2 rounded-xl px-4 py-1 duration-300 ${
- selectedStatus === 'rejected'
- ? 'bg-rose-600 text-background dark:bg-rose-400'
- : 'bg-rose-600/10 text-rose-600 hover:bg-rose-600/30 dark:bg-rose-400/10 dark:text-rose-400 dark:hover:bg-rose-400/30'
- }`}
- onClick={() => setSelectStatus('rejected')}
- >
- Rejected
+ onClick={() => setSelectStatus('all')}
+ >
+ All
+ </div>
+ <div
+ className={`flex cursor-pointer gap-2 rounded-lg px-4 py-1 duration-300 ${
+ selectedStatus === 'accepted'
+ ? 'bg-emerald-600 text-background dark:bg-emerald-400'
+ : 'bg-emerald-600/10 text-emerald-600 hover:bg-emerald-600/30 dark:bg-emerald-400/10 dark:text-emerald-400 dark:hover:bg-emerald-400/30'
+ }`}
+ onClick={() => setSelectStatus('accepted')}
+ >
+ Accepted
+ </div>
+ <div
+ className={`flex cursor-pointer gap-2 rounded-lg px-4 py-1 duration-300 ${
+ selectedStatus === 'rejected'
+ ? 'bg-rose-600 text-background dark:bg-rose-400'
+ : 'bg-rose-600/10 text-rose-600 hover:bg-rose-600/30 dark:bg-rose-400/10 dark:text-rose-400 dark:hover:bg-rose-400/30'
+ }`}
+ onClick={() => setSelectStatus('rejected')}
+ >
+ Rejected
+ </div>
</div>
- </div>
+ ) : (
+ <NoSubmissions />
+ )}
<ul className="relative flex flex-col">
{filteredSubmissions.map((submission) => {
diff --git a/src/components/challenge/submissions/nosubmissions.tsx b/src/components/challenge/submissions/nosubmissions.tsx
new file mode 100644
index 00000000..4b90a93d
--- /dev/null
+++ b/src/components/challenge/submissions/nosubmissions.tsx
@@ -0,0 +1,53 @@
+const NoSubmissions = () => {
+ return (
+ <div className="flex h-full items-center justify-center">
+ <p className="flex flex-col items-center gap-2 text-center text-neutral-500 dark:text-zinc-400">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ data-name="Layer 1"
+ className="mr-6 h-28 w-28"
+ viewBox="0 0 647.63626 632.17383"
+ >
+ <path
+ d="M687.3279,276.08691H512.81813a15.01828,15.01828,0,0,0-15,15v387.85l-2,.61005-42.81006,13.11a8.00676,8.00676,0,0,1-9.98974-5.31L315.678,271.39691a8.00313,8.00313,0,0,1,5.31006-9.99l65.97022-20.2,191.25-58.54,65.96972-20.2a7.98927,7.98927,0,0,1,9.99024,5.3l32.5498,106.32Z"
+ transform="translate(-276.18187 -133.91309)"
+ fill="#4444"
+ />
+ <path
+ d="M725.408,274.08691l-39.23-128.14a16.99368,16.99368,0,0,0-21.23-11.28l-92.75,28.39L380.95827,221.60693l-92.75,28.4a17.0152,17.0152,0,0,0-11.28028,21.23l134.08008,437.93a17.02661,17.02661,0,0,0,16.26026,12.03,16.78926,16.78926,0,0,0,4.96972-.75l63.58008-19.46,2-.62v-2.09l-2,.61-64.16992,19.65a15.01489,15.01489,0,0,1-18.73-9.95l-134.06983-437.94a14.97935,14.97935,0,0,1,9.94971-18.73l92.75-28.4,191.24024-58.54,92.75-28.4a15.15551,15.15551,0,0,1,4.40966-.66,15.01461,15.01461,0,0,1,14.32032,10.61l39.0498,127.56.62012,2h2.08008Z"
+ transform="translate(-276.18187 -133.91309)"
+ fill="#888a"
+ />
+ <path
+ d="M398.86279,261.73389a9.0157,9.0157,0,0,1-8.61133-6.3667l-12.88037-42.07178a8.99884,8.99884,0,0,1,5.9712-11.24023l175.939-53.86377a9.00867,9.00867,0,0,1,11.24072,5.9707l12.88037,42.07227a9.01029,9.01029,0,0,1-5.9707,11.24072L401.49219,261.33887A8.976,8.976,0,0,1,398.86279,261.73389Z"
+ transform="translate(-276.18187 -133.91309)"
+ fill="#888a"
+ />
+ <circle cx="190.15351" cy="24.95465" r="20" fill="#888a" />
+ <circle cx="190.15351" cy="24.95465" r="12.66462" fill="#444a" />
+ <path
+ d="M878.81836,716.08691h-338a8.50981,8.50981,0,0,1-8.5-8.5v-405a8.50951,8.50951,0,0,1,8.5-8.5h338a8.50982,8.50982,0,0,1,8.5,8.5v405A8.51013,8.51013,0,0,1,878.81836,716.08691Z"
+ transform="translate(-276.18187 -133.91309)"
+ fill="#4444"
+ />
+ <path
+ d="M723.31813,274.08691h-210.5a17.02411,17.02411,0,0,0-17,17v407.8l2-.61v-407.19a15.01828,15.01828,0,0,1,15-15H723.93825Zm183.5,0h-394a17.02411,17.02411,0,0,0-17,17v458a17.0241,17.0241,0,0,0,17,17h394a17.0241,17.0241,0,0,0,17-17v-458A17.02411,17.02411,0,0,0,906.81813,274.08691Zm15,475a15.01828,15.01828,0,0,1-15,15h-394a15.01828,15.01828,0,0,1-15-15v-458a15.01828,15.01828,0,0,1,15-15h394a15.01828,15.01828,0,0,1,15,15Z"
+ transform="translate(-276.18187 -133.91309)"
+ fill="#888a"
+ />
+ <path
+ d="M801.81836,318.08691h-184a9.01015,9.01015,0,0,1-9-9v-44a9.01016,9.01016,0,0,1,9-9h184a9.01016,9.01016,0,0,1,9,9v44A9.01015,9.01015,0,0,1,801.81836,318.08691Z"
+ transform="translate(-276.18187 -133.91309)"
+ fill="#888a"
+ />
+ <circle cx="433.63626" cy="105.17383" r="20" fill="#888a" />
+ <circle cx="433.63626" cy="105.17383" r="12.18187" fill="#444a" />
+ </svg>
+ No submissions yet,
+ <br /> submit the challenge!
+ </p>
+ </div>
+ );
+};
+
+export default NoSubmissions;
diff --git a/src/components/create/explore-card-inputs.tsx b/src/components/create/explore-card-inputs.tsx
index 754ef786..6d4a84d6 100644
--- a/src/components/create/explore-card-inputs.tsx
+++ b/src/components/create/explore-card-inputs.tsx
@@ -52,7 +52,6 @@ const ExploreCardInputs = ({
${GRADIENTS_BY_DIFFICULTY[difficulty]}
`}
>
- {/* TODO: add background shapes grid pattern */}
<CardHeader className="relative grid items-start gap-4">
<div className="flex flex-col items-start">
<h1 className="text-sm text-black/50 dark:text-white/70">Challenge Difficulty Level:</h1>
diff --git a/src/components/explore/difficulty-badge.tsx b/src/components/explore/difficulty-badge.tsx
index e98f7abc..8a5deb3c 100644
--- a/src/components/explore/difficulty-badge.tsx
+++ b/src/components/explore/difficulty-badge.tsx
@@ -6,14 +6,20 @@ interface Props {
}
const COLORS_BY_DIFFICULTY = {
- BEGINNER: 'dark:bg-pink-300 bg-pink-500',
- EASY: 'dark:bg-green-300 bg-green-500',
- MEDIUM: 'dark:bg-yellow-300 bg-yellow-500',
- HARD: 'dark:bg-red-300 bg-red-500',
- EXTREME: 'dark:bg-orange-300 bg-orange-500',
+ BEGINNER: 'dark:bg-pink-300 bg-pink-600',
+ EASY: 'dark:bg-green-300 bg-green-600',
+ MEDIUM: 'dark:bg-yellow-300 bg-yellow-600',
+ HARD: 'dark:bg-red-300 bg-red-600',
+ EXTREME: 'dark:bg-orange-300 bg-orange-600',
};
// TODO: move this somewhere else
export function DifficultyBadge({ difficulty }: Props) {
- return <Badge className={`${COLORS_BY_DIFFICULTY[difficulty]}`}>{difficulty}</Badge>;
+ return (
+ <Badge
+ className={`duration-300 group-hover:bg-white group-hover:text-black dark:group-hover:bg-black/50 dark:group-hover:text-white ${COLORS_BY_DIFFICULTY[difficulty]}`}
+ >
+ {difficulty}
+ </Badge>
+ );
}
diff --git a/src/components/explore/explore-card.tsx b/src/components/explore/explore-card.tsx
index 3b7277d2..d8cc5300 100644
--- a/src/components/explore/explore-card.tsx
+++ b/src/components/explore/explore-card.tsx
@@ -48,13 +48,13 @@ const SHADOWS_BY_DIFFICULTY = {
const GRADIENTS_BY_DIFFICULTY = {
BEGINNER:
- 'bg-gradient-to-br hover:bg-[right_-2px_bottom] bg-[length:200%_200%] bg-left-top dark:from-pink-950 dark:via-pink-500 dark:to-pink-300 dark:via-30% from-pink-300 via-pink-500 via-30% to-pink-600',
- EASY: 'bg-gradient-to-br hover:bg-[right_-2px_bottom] bg-[length:200%_200%] bg-left-top dark:from-green-950 dark:via-green-500 dark:to-green-300 dark:via-30% from-green-300 via-green-500 via-30% to-green-600',
+ 'bg-gradient-to-br hover:bg-[right_-2px_bottom] bg-[length:200%_200%] bg-left-top dark:from-pink-950 dark:via-pink-500 dark:to-pink-300 dark:via-30% from-pink-400 via-pink-600 via-30% to-pink-600',
+ EASY: 'bg-gradient-to-br hover:bg-[right_-2px_bottom] bg-[length:200%_200%] bg-left-top dark:from-green-950 dark:via-green-500 dark:to-green-300 dark:via-30% from-green-400 via-green-600 via-30% to-green-600',
MEDIUM:
- 'bg-gradient-to-br hover:bg-[right_-2px_bottom] bg-[length:200%_200%] bg-left-top dark:from-yellow-950 dark:via-yellow-500 dark:to-yellow-300 dark:via-30% from-yellow-300 via-yellow-500 via-30% to-yellow-600',
- HARD: 'bg-gradient-to-br hover:bg-[right_-2px_bottom] bg-[length:200%_200%] bg-left-top dark:from-red-950 dark:via-red-500 dark:to-red-300 dark:via-30% from-red-300 via-red-500 via-30% to-red-600',
+ 'bg-gradient-to-br hover:bg-[right_-2px_bottom] bg-[length:200%_200%] bg-left-top dark:from-yellow-950 dark:via-yellow-500 dark:to-yellow-300 dark:via-30% from-yellow-400 via-yellow-600 via-30% to-yellow-600',
+ HARD: 'bg-gradient-to-br hover:bg-[right_-2px_bottom] bg-[length:200%_200%] bg-left-top dark:from-red-950 dark:via-red-500 dark:to-red-300 dark:via-30% from-red-400 via-red-600 via-30% to-red-600',
EXTREME:
- 'bg-gradient-to-br hover:bg-[right_-2px_bottom] bg-[length:200%_200%] bg-left-top dark:from-orange-950 dark:via-orange-500 dark:to-orange-300 dark:via-30% from-orange-300 via-orange-500 via-30% to-orange-600',
+ 'bg-gradient-to-br hover:bg-[right_-2px_bottom] bg-[length:200%_200%] bg-left-top dark:from-orange-950 dark:via-orange-500 dark:to-orange-300 dark:via-30% from-orange-400 via-orange-600 via-30% to-orange-600',
};
const COLORS_BY_DIFFICULTY = {
@@ -76,43 +76,43 @@ const ExploreCard = ({ challenge }: ExploreCardProps) => {
>
{challenge.difficulty === 'BEGINNER' && (
<>
- <Circle className="absolute -right-4 -top-8 h-24 w-24 stroke-1 text-white/30 duration-300 group-hover:h-20 group-hover:w-20"></Circle>
- <Circle className="absolute -right-4 -top-8 h-32 w-32 stroke-1 text-white/30 duration-500 group-hover:h-28 group-hover:w-28"></Circle>
+ <Circle className="absolute -right-4 -top-8 h-24 w-24 stroke-1 text-white/30 duration-300 group-hover:h-20 group-hover:w-20 dark:group-hover:text-black/30"></Circle>
+ <Circle className="absolute -right-4 -top-8 h-32 w-32 stroke-1 text-white/30 duration-500 group-hover:h-28 group-hover:w-28 dark:group-hover:text-black/30"></Circle>
</>
)}
{challenge.difficulty === 'EASY' && (
<>
- <Diamond className="absolute -right-5 -top-10 h-24 w-24 stroke-1 text-white/30 duration-300 group-hover:h-20 group-hover:w-20 group-hover:rotate-0"></Diamond>
- <Diamond className="absolute -right-5 -top-10 h-32 w-32 rotate-12 stroke-1 text-white/30 duration-500 group-hover:h-28 group-hover:w-28 group-hover:-rotate-12"></Diamond>
+ <Diamond className="absolute -right-5 -top-10 h-24 w-24 stroke-1 text-white/30 duration-300 group-hover:h-20 group-hover:w-20 group-hover:rotate-0 dark:group-hover:text-black/30"></Diamond>
+ <Diamond className="absolute -right-5 -top-10 h-32 w-32 rotate-12 stroke-1 text-white/30 duration-500 group-hover:h-28 group-hover:w-28 group-hover:-rotate-12 dark:group-hover:text-black/30"></Diamond>
</>
)}
{challenge.difficulty === 'MEDIUM' && (
<>
- <Triangle className="absolute -right-2 -top-4 h-20 w-20 rotate-[40deg] stroke-1 text-white/50 duration-300 group-hover:rotate-[0deg] group-hover:scale-50"></Triangle>
- <Triangle className="absolute -right-10 -top-12 h-36 w-36 rotate-45 stroke-1 text-white/50 duration-500 group-hover:h-32 group-hover:w-32 group-hover:rotate-[20deg]"></Triangle>
+ <Triangle className="absolute -right-4 -top-6 h-20 w-20 rotate-[40deg] stroke-2 text-white/50 duration-300 group-hover:rotate-[0deg] group-hover:scale-50 dark:group-hover:text-black/30"></Triangle>
+ <Triangle className="absolute -right-12 -top-14 h-36 w-36 rotate-45 stroke-1 text-white/50 duration-500 group-hover:h-32 group-hover:w-32 group-hover:rotate-[20deg] dark:group-hover:text-black/30"></Triangle>
</>
)}
{challenge.difficulty === 'HARD' && (
<>
- <Plus className="absolute -right-4 -top-8 h-24 w-24 stroke-1 text-white/30 duration-300 group-hover:scale-0"></Plus>
- <Plus className="absolute -right-4 -top-8 h-32 w-32 stroke-1 text-white/30 duration-200 group-hover:scale-[3]"></Plus>
+ <Plus className="absolute -right-4 -top-8 h-24 w-24 stroke-1 text-white/30 duration-300 group-hover:scale-0 dark:group-hover:text-black/30"></Plus>
+ <Plus className="absolute -right-4 -top-8 h-32 w-32 stroke-1 text-white/30 duration-500 group-hover:scale-[3] dark:group-hover:text-black/30"></Plus>
</>
)}
{challenge.difficulty === 'EXTREME' && (
<>
- <Sparkle className="absolute -right-4 -top-10 h-24 w-24 stroke-1 text-white/40 duration-500 group-hover:-translate-x-4 group-hover:translate-y-10 group-hover:-rotate-[125deg]"></Sparkle>
- <Sparkle className="absolute -right-12 -top-20 h-48 w-48 stroke-1 text-white/40 duration-300 group-hover:h-24 group-hover:w-24"></Sparkle>
+ <Sparkle className="absolute -right-4 -top-10 h-24 w-24 stroke-1 text-white/40 duration-500 group-hover:-translate-x-4 group-hover:translate-y-10 group-hover:-rotate-[125deg] dark:group-hover:text-black/30"></Sparkle>
+ <Sparkle className="absolute -right-12 -top-20 h-48 w-48 stroke-1 text-white/40 duration-300 group-hover:h-24 group-hover:w-24 dark:group-hover:text-black/30"></Sparkle>
</>
)}
<CardHeader className="relative grid items-start gap-4">
<div className="flex flex-col items-start gap-2">
- <DifficultyBadge difficulty={challenge.difficulty} />
<CardTitle
- className="pb-4 text-3xl text-white"
+ className="text-3xl text-white duration-300 dark:text-white dark:group-hover:text-black/50"
style={{ textShadow: '0 0 0.5rem #0003' }}
>
{challenge.name}
</CardTitle>
+ <DifficultyBadge difficulty={challenge.difficulty} />
</div>
</CardHeader>
<CardContent className="relative rounded-xl bg-background p-6 duration-300 group-hover:bg-card-hovered">
@@ -123,7 +123,7 @@ const ExploreCard = ({ challenge }: ExploreCardProps) => {
}`}
/>
</div>
- <CardDescription className="relative h-14 max-w-[75%] overflow-hidden pb-4">
+ <CardDescription className="relative h-16 max-w-[77%] overflow-hidden pb-4">
<div className="pointer-events-none absolute inset-0 h-full w-full shadow-[inset_0_-1.5rem_1rem_-0.5rem_hsl(var(--card))] duration-300 group-hover:shadow-[inset_0_-1.5rem_1rem_-0.5rem_hsl(var(--card-hovered))] group-focus:shadow-[inset_0_-1.5rem_1rem_-0.5rem_hsl(var(--card-hovered))]" />
<Markdown>{challenge?.shortDescription}</Markdown>
</CardDescription>
diff --git a/src/components/ui/action-menu.tsx b/src/components/ui/action-menu.tsx
index 8b237dce..451d7d25 100644
--- a/src/components/ui/action-menu.tsx
+++ b/src/components/ui/action-menu.tsx
@@ -31,14 +31,14 @@ export function ActionMenu(props: ActionMenuProps) {
<DropdownMenuTrigger asChild>
<AllIcons.MoreHorizontal className="cursor-pointer" size={16} />
</DropdownMenuTrigger>
- <DropdownMenuContent className="rounded-full">
+ <DropdownMenuContent align="end" className="rounded-xl rounded-tr-sm p-0 invert">
{props.items.map((item) => {
const Icon = (item.icon ? AllIcons[item.icon] : null) as OptionalIcon;
return (
<DropdownMenuItem
onClick={() => props.onChange(item)}
key={item.key}
- className="flex items-center gap-2 rounded-full"
+ className="flex items-center gap-2 py-2 pl-3 pr-0"
>
<div>{Icon ? <Icon size={16} /> : null}</div>
<div>{item.label}</div>
diff --git a/src/components/ui/navigation.tsx b/src/components/ui/navigation.tsx
index fb1ad15e..78c10d5c 100644
--- a/src/components/ui/navigation.tsx
+++ b/src/components/ui/navigation.tsx
@@ -69,22 +69,25 @@ export function Navigation() {
<User className="h-5 w-5" />
</button>
</DropdownMenuTrigger>
- <DropdownMenuContent className="mr-4 w-56 rounded-xl">
+ <DropdownMenuContent
+ align="end"
+ className="mt-[0.33rem] w-56 rounded-xl bg-white/50 backdrop-blur-sm dark:bg-neutral-950/50"
+ >
<Link className="block" href="/create">
- <DropdownMenuItem className="rounded-lg p-2 duration-300 focus:bg-accent focus:outline-none">
+ <DropdownMenuItem className="rounded-lg p-2 duration-300 focus:bg-accent focus:outline-none dark:hover:bg-neutral-700/50">
<Plus className="mr-2 h-4 w-4" />
<span>Create a Challange</span>
</DropdownMenuItem>
</Link>
<Link className="block" href={`/@${session.user.name}`}>
- <DropdownMenuItem className="rounded-lg p-2 duration-300 focus:bg-accent focus:outline-none">
+ <DropdownMenuItem className="rounded-lg p-2 duration-300 focus:bg-accent focus:outline-none dark:hover:bg-neutral-700/50">
<User className="mr-2 h-4 w-4" />
<span>Profile</span>
</DropdownMenuItem>
</Link>
{isAdminOrMod && (
<Link className="block" href="/admin">
- <DropdownMenuItem className="rounded-lg p-2 duration-300 focus:bg-accent focus:outline-none">
+ <DropdownMenuItem className="rounded-lg p-2 duration-300 focus:bg-accent focus:outline-none dark:hover:bg-neutral-700/50">
<Settings className="mr-2 h-4 w-4" />
<span>Admin</span>
</DropdownMenuItem>
@@ -93,7 +96,7 @@ export function Navigation() {
<DropdownMenuSeparator />
<Button
variant="ghost"
- className="h-8 w-full justify-start rounded-b-lg rounded-t-sm px-2 text-red-500 hover:bg-red-500/20 hover:text-red-500"
+ className="h-8 w-full justify-start rounded-b-lg rounded-t-sm bg-opacity-50 px-2 text-red-500 hover:bg-red-500/20 hover:text-red-500"
onClick={handleSignOut}
>
<span className="text-red-500">Log out</span>
diff --git a/src/components/ui/user-badge.tsx b/src/components/ui/user-badge.tsx
index 4fe290dc..525239e6 100644
--- a/src/components/ui/user-badge.tsx
+++ b/src/components/ui/user-badge.tsx
@@ -12,14 +12,18 @@ const UserBadge = (props: UserBadgeProps) => {
<TooltipTrigger asChild>
<Link href={`/@${props.username}`}>
<Button
- className="h-fit w-fit rounded-full bg-neutral-200 p-1 px-2 text-xs font-bold text-neutral-500 hover:bg-neutral-300 dark:bg-zinc-700 dark:text-neutral-400 dark:hover:bg-neutral-500"
+ 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-neutral-300 dark:text-neutral-400 dark:hover:bg-zinc-700 dark:hover:text-neutral-300"
size="sm"
>
- @ {props.username}
+ @{props.username}
</Button>
</Link>
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent
+ align="start"
+ avoidCollisions={false}
+ className="rounded-2xl rounded-bl-sm px-3 py-1 text-xs invert"
+ >
<span>Author</span>
</TooltipContent>
</Tooltip>