Skip to content

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

Explore tweaks (#247)

PickleNik921fcc761d1a
diff --git a/src/app/admin/report/[id]/actions.tsx b/src/app/admin/report/[id]/actions.tsx
index 4e17e2bc..cfb7087d 100644
--- a/src/app/admin/report/[id]/actions.tsx
+++ b/src/app/admin/report/[id]/actions.tsx
@@ -23,7 +23,6 @@ import { toast } from '~/components/ui/use-toast';
export default function ReportActions({
moderatorId,
- moderator,
challenge,
reportId,
}: {
diff --git a/src/app/admin/report/[id]/page.tsx b/src/app/admin/report/[id]/page.tsx
index dc9eaefd..47c14ac4 100644
--- a/src/app/admin/report/[id]/page.tsx
+++ b/src/app/admin/report/[id]/page.tsx
@@ -16,7 +16,7 @@ export interface Props {
};
}
-export default async function (props: Props) {
+const Report = async function (props: Props) {
const idNum = Number(props.params.id);
// Double check that we have a number, redirect out if we don't
if (isNaN(idNum)) {
@@ -123,3 +123,5 @@ export default async function (props: Props) {
</div>
);
}
+
+export default Report;
\ No newline at end of file
diff --git a/src/app/create/preview/page.tsx b/src/app/create/preview/page.tsx
index d647b034..1cecf3b6 100644
--- a/src/app/create/preview/page.tsx
+++ b/src/app/create/preview/page.tsx
@@ -10,10 +10,12 @@ import ExploreCard from '~/components/explore/explore-card';
import { Button } from '~/components/ui/button';
import { uploadChallenge } from '../create.action';
import { useState } from 'react';
+import { useSession } from 'next-auth/react';
export default function PreviewCreatedChallenge() {
const createChallengeStore = useCreateChallengeStore();
const router = useRouter();
+ const user = useSession();
const [isRedirecting, setIsRedirecting] = useState(false);
if (createChallengeStore.data === undefined) {
@@ -79,6 +81,8 @@ export default function PreviewCreatedChallenge() {
vote: 420,
comment: 0,
},
+ // @ts-ignore
+ user: user?.data?.user || { name: 'you' },
updatedAt: new Date(),
difficulty: createChallengeStore.data.difficulty,
}}
diff --git a/src/components/challenge/description/index.tsx b/src/components/challenge/description/index.tsx
index 0fdf7e82..e0900ac8 100644
--- a/src/components/challenge/description/index.tsx
+++ b/src/components/challenge/description/index.tsx
@@ -23,7 +23,7 @@ import {
} from '~/components/ui/dialog';
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '~/components/ui/tooltip';
import { TypographyH3 } from '~/components/ui/typography/h3';
-import { DifficultyBadge } from '~/components/explore/difficulty-badge';
+import { DifficultyBadge } from '~/components/ui/difficulty-badge';
import { ActionMenu } from '~/components/ui/action-menu';
import { Checkbox } from '~/components/ui/checkbox';
import { Form, FormField, FormItem } from '~/components/ui/form';
@@ -37,6 +37,7 @@ import { toast } from '~/components/ui/use-toast';
import { addOrRemoveBookmark } from '../bookmark.action';
import { incrementOrDecrementUpvote } from '../increment.action';
import { addChallengeReport } from '../report.action';
+import { getRelativeTime } from '~/utils/relativeTime';
interface Props {
challenge: ChallengeRouteData;
@@ -133,108 +134,12 @@ 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">
+ {/* NOTE: collapse this element */}
+ <div className="flex items-center gap-4">
+ <TypographyH3 className="mb-2 mr-auto max-w-[75%] items-center truncate text-2xl font-bold">
{challenge.name}
</TypographyH3>
- <Dialog>
- <DialogTrigger>
- <ActionMenu
- items={[
- {
- key: 'feedback',
- label: 'Feedback',
- icon: 'Flag',
- },
- ]}
- onChange={() => {
- // do nothing
- }}
- />
- </DialogTrigger>
-
- <DialogContent>
- <Form {...form}>
- <form onSubmit={form.handleSubmit(onSubmit)}>
- <DialogHeader>
- <DialogTitle>Feedback: {challenge.name}</DialogTitle>
- </DialogHeader>
-
- <div className="my-4 flex flex-col gap-4">
- <TypographyLarge>Issues Encountered</TypographyLarge>
- <FormField
- name="examples"
- render={({ field }) => (
- <FormItem>
- <div className="flex items-center gap-4">
- <Checkbox
- id="examples"
- checked={field.value as boolean}
- onChange={field.onChange}
- onCheckedChange={field.onChange}
- />
- <label htmlFor="examples">
- Description or examples are unclear or incorrect
- </label>
- </div>
- </FormItem>
- )}
- />
- <FormField
- name="derogatory"
- render={({ field }) => (
- <FormItem>
- <div className="flex items-center gap-4">
- <Checkbox
- id="derogatory"
- checked={field.value as boolean}
- onCheckedChange={field.onChange}
- />
- <label htmlFor="derogatory">Racist or other derogatory statement</label>
- </div>
- </FormItem>
- )}
- />
- <FormField
- name="other"
- render={({ field }) => (
- <FormItem>
- <div className="flex items-center gap-4">
- <Checkbox
- id="other"
- checked={field.value as boolean}
- onCheckedChange={field.onChange}
- />
- <label htmlFor="other">Other</label>
- </div>
- </FormItem>
- )}
- />
- <FormField
- name="comments"
- render={({ field }) => (
- <FormItem>
- <TypographyLarge>Comments</TypographyLarge>
- <Textarea value={field.value as string} onChange={field.onChange} />
- </FormItem>
- )}
- />
- </div>
- <DialogFooter>
- <DialogPrimitive.Close asChild>
- <Button type="submit">Report</Button>
- </DialogPrimitive.Close>
- </DialogFooter>
- </form>
- </Form>
- </DialogContent>
- </Dialog>
- </div>
-
- <div className="mb-6 flex items-center gap-2">
- <UserBadge username={challenge.user.name} />
- <DifficultyBadge difficulty={challenge.difficulty} />
-
+ {/* TODO: split this mess into components, make buttons have bigger horizontal padding and decrease the gap value on container above */}
<TooltipProvider>
<Tooltip delayDuration={0.05} open={session?.data?.user?.id ? false : undefined}>
<TooltipTrigger asChild>
@@ -262,13 +167,12 @@ export function Description({ challenge }: Props) {
}}
>
<BookmarkIcon
- size={20}
className={clsx(
{
'fill-blue-500 stroke-blue-500': hasBookmarked,
- 'stroke-gray-500': !hasBookmarked,
+ 'stroke-zinc-500': !hasBookmarked,
},
- 'hover:stroke-gray-400',
+ 'h-4 w-4 hover:stroke-zinc-400',
)}
/>
</Button>
@@ -281,7 +185,7 @@ export function Description({ challenge }: Props) {
</TooltipProvider>
<Dialog>
<DialogTrigger>
- <Share size={20} className="stroke-gray-500 hover:stroke-gray-400" />
+ <Share className="h-4 w-4 stroke-zinc-500 hover:stroke-zinc-400" />
</DialogTrigger>
<DialogContent className="w-[200px]">
<DialogHeader>
@@ -296,7 +200,7 @@ export function Description({ challenge }: Props) {
<TooltipTrigger asChild>
<span>
<Button
- className="group -ml-1 w-14 gap-2 rounded-lg p-1"
+ className="group gap-2 rounded-xl px-2 py-1"
variant="ghost"
disabled={!session?.data?.user?.id}
onClick={() => {
@@ -320,14 +224,13 @@ export function Description({ challenge }: Props) {
}}
>
<ThumbsUp
- size={20}
className={clsx(
{
- 'fill-emerald-600 stroke-emerald-600 group-hover:stroke-emerald-500 dark:fill-emerald-400 dark:stroke-emerald-400':
+ 'fill-emerald-600 stroke-emerald-600 group-hover:stroke-emerald-400 dark:fill-emerald-400 dark:stroke-emerald-400':
hasVoted,
- 'stroke-zinc-500': !hasVoted,
+ 'stroke-zinc-500 group-hover:stroke-zinc-400': !hasVoted,
},
- 'duration-300 group-hover:stroke-zinc-400',
+ 'h-4 w-4 duration-200 group-hover:scale-105 group-active:scale-95 group-active:duration-75',
)}
/>
<span
@@ -336,7 +239,7 @@ export function Description({ challenge }: Props) {
'text-emerald-600 dark:text-emerald-400': hasVoted,
'text-zinc-500 group-hover:text-zinc-400': !hasVoted,
},
- 'self-end text-lg duration-300',
+ 'my-auto w-4 self-end duration-300',
)}
>
{votes}
@@ -348,6 +251,106 @@ export function Description({ challenge }: Props) {
<p>Login to Upvote</p>
</TooltipContent>
</Tooltip>
+ <Dialog>
+ <DialogTrigger>
+ <ActionMenu
+ items={[
+ {
+ key: 'feedback',
+ label: 'Feedback',
+ icon: 'Flag',
+ },
+ ]}
+ onChange={() => {
+ // do nothing
+ }}
+ />
+ </DialogTrigger>
+
+ <DialogContent>
+ <Form {...form}>
+ <form onSubmit={form.handleSubmit(onSubmit)}>
+ <DialogHeader>
+ <DialogTitle>Feedback: {challenge.name}</DialogTitle>
+ </DialogHeader>
+
+ <div className="my-4 flex flex-col gap-4">
+ <TypographyLarge>Issues Encountered</TypographyLarge>
+ <FormField
+ name="examples"
+ render={({ field }) => (
+ <FormItem>
+ <div className="flex items-center gap-4">
+ <Checkbox
+ id="examples"
+ checked={field.value as boolean}
+ onChange={field.onChange}
+ onCheckedChange={field.onChange}
+ />
+ <label htmlFor="examples">
+ Description or examples are unclear or incorrect
+ </label>
+ </div>
+ </FormItem>
+ )}
+ />
+ <FormField
+ name="derogatory"
+ render={({ field }) => (
+ <FormItem>
+ <div className="flex items-center gap-4">
+ <Checkbox
+ id="derogatory"
+ checked={field.value as boolean}
+ onCheckedChange={field.onChange}
+ />
+ <label htmlFor="derogatory">Racist or other derogatory statement</label>
+ </div>
+ </FormItem>
+ )}
+ />
+ <FormField
+ name="other"
+ render={({ field }) => (
+ <FormItem>
+ <div className="flex items-center gap-4">
+ <Checkbox
+ id="other"
+ checked={field.value as boolean}
+ onCheckedChange={field.onChange}
+ />
+ <label htmlFor="other">Other</label>
+ </div>
+ </FormItem>
+ )}
+ />
+ <FormField
+ name="comments"
+ render={({ field }) => (
+ <FormItem>
+ <TypographyLarge>Comments</TypographyLarge>
+ <Textarea value={field.value as string} onChange={field.onChange} />
+ </FormItem>
+ )}
+ />
+ </div>
+ <DialogFooter>
+ <DialogPrimitive.Close asChild>
+ <Button type="submit">Report</Button>
+ </DialogPrimitive.Close>
+ </DialogFooter>
+ </form>
+ </Form>
+ </DialogContent>
+ </Dialog>
+ </div>
+
+ <div className="mb-6 flex items-center gap-4">
+ <DifficultyBadge difficulty={challenge.difficulty} />
+ <UserBadge username={challenge.user.name} />
+ <span className="-ml-1 text-xs text-muted-foreground">
+ {getRelativeTime(challenge.updatedAt)}
+ </span>
</div>
<div className="prose-invert leading-8 prose-h3:text-xl">
<Markdown>{challenge.description}</Markdown>
diff --git a/src/components/create/explore-card-inputs.tsx b/src/components/create/explore-card-inputs.tsx
index 6d4a84d6..ec2bc715 100644
--- a/src/components/create/explore-card-inputs.tsx
+++ b/src/components/create/explore-card-inputs.tsx
@@ -3,7 +3,7 @@
import { ThumbsUp, PlayCircle, Bookmark } from 'lucide-react';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card';
-import { DifficultyBadge } from '../explore/difficulty-badge';
+
import { Markdown } from '../ui/markdown';
import { getRelativeTime } from '~/utils/relativeTime';
@@ -13,6 +13,7 @@ import { Label } from '~/components/ui/label';
import { type Difficulty } from '@prisma/client';
import { useState } from 'react';
+import { DifficultyBadge } from '../ui/difficulty-badge';
// NOTE: this does not have hover: effects from explore-card
const GRADIENTS_BY_DIFFICULTY = {
@@ -48,7 +49,7 @@ const ExploreCardInputs = ({
return (
<Card
- className={`group overflow-hidden duration-300
+ className={`overflow-hidden duration-300
${GRADIENTS_BY_DIFFICULTY[difficulty]}
`}
>
diff --git a/src/components/explore/difficulty-badge.tsx b/src/components/explore/difficulty-badge.tsx
deleted file mode 100644
index 8a5deb3c..00000000
--- a/src/components/explore/difficulty-badge.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import { type Difficulty } from '@prisma/client';
-import { Badge } from '../ui/badge';
-
-interface Props {
- difficulty: Difficulty;
-}
-
-const COLORS_BY_DIFFICULTY = {
- 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={`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 d8cc5300..d00fa2ae 100644
--- a/src/components/explore/explore-card.tsx
+++ b/src/components/explore/explore-card.tsx
@@ -1,27 +1,18 @@
'use client';
-import {
- Calendar,
- Circle,
- Diamond,
- MessageCircle,
- PlayCircle,
- Plus,
- Sparkle,
- ThumbsUp,
- Triangle,
-} from 'lucide-react';
+import { Circle, Diamond, MessageCircle, Plus, Sparkle, ThumbsUp, Triangle } from 'lucide-react';
import { getRelativeTime } from '~/utils/relativeTime';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card';
import { Markdown } from '../ui/markdown';
import { type ExploreChallengeData } from './';
-import { DifficultyBadge } from './difficulty-badge';
+import { DifficultyBadge } from '../ui/difficulty-badge';
+import { UserBadge } from '../ui/user-badge';
interface ExploreCardProps {
challenge: Pick<
ExploreChallengeData[0],
- 'difficulty' | 'name' | 'shortDescription' | '_count' | 'updatedAt'
+ 'difficulty' | 'name' | 'shortDescription' | 'user' | '_count' | 'updatedAt'
>;
}
@@ -57,18 +48,10 @@ const GRADIENTS_BY_DIFFICULTY = {
'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 = {
- BEGINNER: 'dark:group-hover:text-pink-300 group-hover:text-pink-600',
- EASY: 'dark:group-hover:text-green-300 group-hover:text-green-600',
- MEDIUM: 'dark:group-hover:text-yellow-300 group-hover:text-yellow-600',
- HARD: 'dark:group-hover:text-red-300 group-hover:text-red-600',
- EXTREME: 'dark:group-hover:text-orange-300 group-hover:text-orange-600',
-};
-
const ExploreCard = ({ challenge }: ExploreCardProps) => {
return (
<Card
- className={`group relative overflow-hidden duration-300
+ className={`group relative overflow-hidden duration-500
${GRADIENTS_BY_DIFFICULTY[challenge.difficulty]}
${SHADOWS_BY_DIFFICULTY[challenge.difficulty]}
${BORDERS_BY_DIFFICULTY[challenge.difficulty]}
@@ -88,8 +71,8 @@ const ExploreCard = ({ challenge }: ExploreCardProps) => {
)}
{challenge.difficulty === 'MEDIUM' && (
<>
- <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>
+ <Triangle className="absolute -right-4 -top-6 h-20 w-20 rotate-[40deg] stroke-2 text-white/50 duration-200 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-300 group-hover:h-32 group-hover:w-32 group-hover:rotate-[20deg] dark:group-hover:text-black/30"></Triangle>
</>
)}
{challenge.difficulty === 'HARD' && (
@@ -104,45 +87,32 @@ const ExploreCard = ({ challenge }: ExploreCardProps) => {
<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">
- <CardTitle
- 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>
+ <CardHeader className="relative flex flex-col items-start gap-1">
+ <CardTitle className="max-w-[75%] truncate text-2xl text-white duration-300 dark:text-white dark:group-hover:text-black/70">
+ {challenge.name}
+ </CardTitle>
+ <div className="flex items-center gap-4 text-center text-white duration-300 dark:group-hover:text-black">
<DifficultyBadge difficulty={challenge.difficulty} />
+ {/* NOTE: Tailwind is a programming language */}
+ <div className="dark duration-300 dark:group-hover:invert">
+ <UserBadge username={challenge.user.name} />
+ </div>
+ <div className="-ml-2 text-xs">{getRelativeTime(challenge.updatedAt)}</div>
</div>
</CardHeader>
- <CardContent className="relative rounded-xl bg-background p-6 duration-300 group-hover:bg-card-hovered">
- <div className="absolute right-8 top-1 flex h-20 w-20 -translate-y-1/2 items-center justify-center rounded-full bg-background duration-300 group-hover:bg-card-hovered">
- <PlayCircle
- className={`mt-1 h-12 w-12 stroke-1 duration-300 group-hover:scale-110 ${
- COLORS_BY_DIFFICULTY[challenge.difficulty]
- }`}
- />
- </div>
- <CardDescription className="relative h-16 max-w-[77%] overflow-hidden pb-4">
+ <CardContent className="relative flex justify-between gap-2 rounded-xl bg-background p-6 pb-0 duration-300 group-hover:bg-card-hovered">
+ <CardDescription className="relative h-20 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>
-
- <div className="text-muted-foreground">
- <div className="flex items-center justify-between">
- <div className="flex items-center gap-6 text-center">
- <div className="flex items-center gap-2">
- <MessageCircle size={18} />
- {challenge._count.comment}
- </div>
- <div className="flex items-center gap-2">
- <ThumbsUp size={18} />
- <span>{challenge._count.vote}</span>
- </div>
- </div>
- <div className="flex items-center gap-2 text-sm">
- <Calendar size={18} /> {getRelativeTime(challenge.updatedAt)}
- </div>
+ <div className="flex flex-col items-end justify-end gap-3 pb-6 pl-6 text-muted-foreground">
+ <div className="flex items-center gap-2 text-sm">
+ {challenge._count.comment}
+ <MessageCircle size={18} />
+ </div>
+ <div className="flex items-center gap-2 text-sm">
+ {challenge._count.vote}
+ <ThumbsUp size={18} />
</div>
</div>
</CardContent>
diff --git a/src/components/explore/index.tsx b/src/components/explore/index.tsx
index 6d6afe12..0ba4c6a3 100644
--- a/src/components/explore/index.tsx
+++ b/src/components/explore/index.tsx
@@ -8,11 +8,12 @@ export const dynamic = 'force-dynamic';
export async function Explore() {
return (
- <div className="container flex h-full flex-col">
- <p className="max-w-[66ch] bg-transparent pt-5 text-lg leading-10 text-neutral-600 dark:text-neutral-400">
- <span className="text-xl font-bold text-[#3178c6]">Explore</span> the challenges. Embrace
- the opportunity to grow, learn, and showcase your programming abilities. We hope you find
- the <span className="font-semibold text-neutral-200">perfect</span> challenge!
+ <div className="container flex h-full flex-col items-center">
+ <p className="max-w-[66ch] px-4 pt-5 text-lg leading-10 text-neutral-600 dark:text-neutral-400 md:text-center">
+ <span className="text-xl font-bold text-[#3178c6] dark:text-[#4e99ea]">Explore</span> the
+ challenges. Embrace the opportunity to grow, learn, and showcase your programming abilities.
+ We hope you find the <span className="font-semibold dark:text-neutral-200">perfect</span>{' '}
+ challenge!
</p>
<Suspense fallback={<ExploreSectionSkeleton />}>
@@ -31,6 +32,7 @@ export async function Explore() {
}
export type ExploreChallengeData = Awaited<ReturnType<typeof getEasyChallenges>>;
+// TODO: this is trash
async function getEasyChallenges() {
return prisma.challenge.findMany({
where: {
@@ -41,6 +43,7 @@ async function getEasyChallenges() {
_count: {
select: { vote: true, comment: true },
},
+ user: true,
},
take: 6,
});
@@ -56,6 +59,7 @@ async function getMediumChallenges() {
_count: {
select: { vote: true, comment: true },
},
+ user: true,
},
take: 6,
});
@@ -71,6 +75,7 @@ async function getHardChallenges() {
_count: {
select: { vote: true, comment: true },
},
+ user: true,
},
take: 6,
});
diff --git a/src/components/explore/section.tsx b/src/components/explore/section.tsx
index da713612..49d7666e 100644
--- a/src/components/explore/section.tsx
+++ b/src/components/explore/section.tsx
@@ -5,6 +5,7 @@ import Card from './explore-card';
import type { ExploreChallengeData } from '.';
import type { Difficulty } from '@prisma/client';
import { Button } from '../ui/button';
+import { ChevronRight } from 'lucide-react';
interface Props {
title: string;
@@ -19,16 +20,30 @@ const difficultyToNumber: Record<Difficulty, number> = {
EXTREME: 4,
};
+const COLORS_BY_DIFFICULTY = {
+ BEGINNER: 'dark:text-pink-400 text-pink-600',
+ EASY: 'dark:text-green-400 text-green-600',
+ MEDIUM: 'dark:text-yellow-400 text-yellow-600',
+ HARD: 'dark:text-red-400 text-red-600',
+ EXTREME: 'dark:text-orange-400 text-orange-600',
+};
+
export async function ExploreSection({ title, fetcher }: Props) {
const challenges = await fetcher();
return (
<section className="py-5">
<div className="flex items-center justify-between">
- <h2 className="my-4 text-3xl font-semibold tracking-tight text-black text-transparent dark:text-white md:text-4xl lg:my-6">
+ <div className="hidden w-[117px] md:block"></div>
+ <h2
+ className={`my-4 pl-4 text-xl font-semibold tracking-tight md:pl-0 md:text-2xl lg:my-6 ${
+ COLORS_BY_DIFFICULTY[challenges[0]?.difficulty || 'BEGINNER']
+ }`}
+ >
{title}
</h2>
- <Button variant="ghost" className="rounded-md p-2">
+ <Button variant="ghost" className="group items-center rounded-full px-4 py-2">
view more
+ <ChevronRight className="h-4 w-4 duration-300 group-hover:translate-x-2" />
</Button>
</div>
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
diff --git a/src/components/ui/action-menu.tsx b/src/components/ui/action-menu.tsx
index 451d7d25..6c1fa336 100644
--- a/src/components/ui/action-menu.tsx
+++ b/src/components/ui/action-menu.tsx
@@ -29,9 +29,9 @@ export function ActionMenu(props: ActionMenuProps) {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <AllIcons.MoreHorizontal className="cursor-pointer" size={16} />
+ <AllIcons.MoreHorizontal className="cursor-pointer text-neutral-500" size={16} />
</DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="rounded-xl rounded-tr-sm p-0 invert">
+ <DropdownMenuContent align="end" className="mt-2 rounded-xl rounded-tr-sm p-0 invert">
{props.items.map((item) => {
const Icon = (item.icon ? AllIcons[item.icon] : null) as OptionalIcon;
return (
diff --git a/src/components/ui/difficulty-badge.tsx b/src/components/ui/difficulty-badge.tsx
new file mode 100644
index 00000000..a8612c73
--- /dev/null
+++ b/src/components/ui/difficulty-badge.tsx
@@ -0,0 +1,26 @@
+import { type Difficulty } from '@prisma/client';
+import { Badge } from './badge';
+
+interface Props {
+ difficulty: Difficulty;
+}
+
+const COLORS_BY_DIFFICULTY = {
+ BEGINNER: 'dark:bg-pink-300 bg-pink-600 dark:group-hover:text-pink-300 group-hover:text-pink-600',
+ EASY: 'dark:bg-green-300 bg-green-600 dark:group-hover:text-green-300 group-hover:text-green-600',
+ MEDIUM:
+ 'dark:bg-yellow-300 bg-yellow-600 dark:group-hover:text-yellow-300 group-hover:text-yellow-600',
+ HARD: 'dark:bg-red-300 bg-red-600 dark:group-hover:text-red-300 group-hover:text-red-600',
+ EXTREME:
+ 'dark:bg-orange-300 bg-orange-600 dark:group-hover:text-orange-300 group-hover:text-orange-600',
+};
+
+export function DifficultyBadge({ difficulty }: Props) {
+ return (
+ <Badge
+ className={`duration-300 group-hover:bg-white dark:group-hover:bg-black/70 ${COLORS_BY_DIFFICULTY[difficulty]}`}
+ >
+ {difficulty}
+ </Badge>
+ );
+}
diff --git a/src/components/ui/user-badge.tsx b/src/components/ui/user-badge.tsx
index 525239e6..a0410d07 100644
--- a/src/components/ui/user-badge.tsx
+++ b/src/components/ui/user-badge.tsx
@@ -12,7 +12,7 @@ const UserBadge = (props: UserBadgeProps) => {
<TooltipTrigger asChild>
<Link href={`/@${props.username}`}>
<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-neutral-300 dark:text-neutral-400 dark:hover:bg-zinc-700 dark:hover:text-neutral-300"
+ 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"
>
@{props.username}
diff --git a/src/utils/relativeTime.ts b/src/utils/relativeTime.ts
index 109ebda3..52528b8d 100644
--- a/src/utils/relativeTime.ts
+++ b/src/utils/relativeTime.ts
@@ -5,4 +5,4 @@ export const getRelativeTime = (date: Date | string) => {
return formatDistanceToNow(date, {
addSuffix: true,
});
-};
+};
\ No newline at end of file