Connect, collaborate, and grow with a community of TypeScript developers
explore card redesign & other fixes (#157)
PickleNik14a6d3a0d3b8
diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsxindex b7b0f47d..bb6791e5 100644--- a/src/app/admin/page.tsx+++ b/src/app/admin/page.tsx@@ -20,11 +20,7 @@ async function Admin() {{isModOrAdmin ? (<View />) : (- <div- className="flex min-h-[calc(100dvh-112px)] w-full flex-col items-center justify-center space-y-2"- // TODO: i bet there is a css/tw way to do this, @Nikita can fix in 2ms- style={{ minHeight: 'calc(100dvh - 112px)' }}- >+ <div className="flex min-h-[calc(100dvh-112px)] w-full flex-col items-center justify-center space-y-2"><Lock className="h-8 w-8" /><span className="max-w-[40ch] text-center text-black/50 dark:text-white/50">You do not have permissions to access the page.diff --git a/src/app/create/page.tsx b/src/app/create/page.tsxindex a674dbb8..2f1ccd15 100644--- a/src/app/create/page.tsx+++ b/src/app/create/page.tsx@@ -1,7 +1,6 @@'use client';import { ChallengeLayout } from '~/components/challenge/challenge-layout';-import { Textarea } from '~/components/ui/textarea';import { CodePanel } from '~/components/challenge/editor';import { useState } from 'react';import { Checkbox } from '~/components/ui/checkbox';@@ -9,18 +8,12 @@ import { Label } from '~/components/ui/label';import { Markdown } from '~/components/ui/markdown';import { useCreateChallengeStore } from './create-challenge-store';import { Tabs, TabsContent, TabsList, TabsTrigger } from '~/components/ui/tabs';-import { Input } from '~/components/ui/input';import { useToast } from '~/components/ui/use-toast';import { ToastAction } from '@radix-ui/react-toast';import { useRouter } from 'next/navigation';-import {- Select,- SelectContent,- SelectItem,- SelectTrigger,- SelectValue,-} from '../../components/ui/select';+import { type Difficulty } from '@prisma/client';+import ExploreCardInputs from '../../components/create/explore-card-inputs';import { useTheme } from 'next-themes';@@ -30,12 +23,10 @@ export default function CreateChallenge() {const createChallengeStore = useCreateChallengeStore();const [isPreviewing, setIsPreviewing] = useState({description: false,- shortDescription: false,- name: false,});const [description, setDescription] = useState(createChallengeStore.data?.description ?? '');- const [difficulty, setDifficulty] = useState<Difficulty | undefined>(- createChallengeStore.data?.difficulty,+ const [difficulty, setDifficulty] = useState<Difficulty | 'BEGINNER'>(+ createChallengeStore.data?.difficulty || 'BEGINNER',);const [shortDescription, setShortDescription] = useState(createChallengeStore.data?.shortDescription ?? '',@@ -105,13 +96,13 @@ export default function CreateChallenge() {<TabsList className="sticky top-0 z-10 grid h-auto w-full grid-cols-2 rounded-none border-b border-zinc-300 bg-background/90 backdrop-blur-sm dark:border-zinc-700 dark:bg-muted/90"><TabsTriggervalue="short-description"- className="rounded-md rounded-tr-lg duration-300 data-[state=active]:bg-neutral-200 dark:data-[state=active]:bg-neutral-700"+ className="rounded-md rounded-tl-xl duration-300 data-[state=active]:bg-neutral-200 dark:data-[state=active]:bg-neutral-700">Short Description</TabsTrigger><TabsTriggervalue="long-description"- className="rounded-md rounded-tl-lg duration-300 data-[state=active]:bg-neutral-200 dark:data-[state=active]:bg-neutral-700"+ className="rounded-md rounded-tr-lg duration-300 data-[state=active]:bg-neutral-200 dark:data-[state=active]:bg-neutral-700">Long Description</TabsTrigger>@@ -120,75 +111,14 @@ export default function CreateChallenge() {value="short-description"className="mt-0 flex flex-1 flex-col p-4 dark:bg-muted [&[hidden]]:hidden">- <div className="mb-1 mt-3 flex items-center justify-between pr-1">- <h1>Name:</h1>-- <Label- htmlFor="previewTitle"- className="flex cursor-pointer items-center gap-2 text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"- >- Preview:- <Checkbox- id="previewTitle"- className="border-zinc-500"- checked={isPreviewing.name}- onCheckedChange={(checked) =>- setIsPreviewing((rest) => ({ ...rest, name: checked === true }))- }- />- </Label>- </div>- {isPreviewing.name ? (- <h2 className="px-3 py-2">{name}</h2>- ) : (- <Input- className="resize-none border-zinc-300 bg-zinc-100 dark:border-zinc-700 dark:bg-zinc-900"- value={name}- onChange={(ev) => setName(ev.currentTarget.value)}- />- )}-- <h1 className="mb-1 mt-3">Name:</h1>- <Select onValueChange={(value: Difficulty) => setDifficulty(value)} value={difficulty}>- <SelectTrigger className="border-zinc-300 bg-zinc-100 dark:border-zinc-700 dark:bg-zinc-900">- <SelectValue placeholder="Select a Difficulty" />- </SelectTrigger>- <SelectContent className="border-zinc-300 bg-zinc-100 dark:border-zinc-700 dark:bg-zinc-900">- <SelectItem value="BEGINNER">BEGINNER</SelectItem>- <SelectItem value="EASY">EASY</SelectItem>- <SelectItem value="MEDIUM">MEDIUM</SelectItem>- <SelectItem value="HARD">HARD</SelectItem>- <SelectItem value="EXTREME">EXTREME</SelectItem>- </SelectContent>- </Select>- <div className="mb-1 mt-3 flex items-center justify-between pr-1">- <h1>Short Description:</h1>- <Label- htmlFor="preview"- className="flex cursor-pointer items-center gap-2 text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"- >- Preview:- <Checkbox- id="preview"- className="border-zinc-500"- checked={isPreviewing.shortDescription}- onCheckedChange={(checked) =>- setIsPreviewing((rest) => ({ ...rest, shortDescription: checked === true }))- }- />- </Label>- </div>- {isPreviewing.shortDescription ? (- <div className="prose-invert flex-1 px-3 py-2 text-sm">- <Markdown>{shortDescription}</Markdown>- </div>- ) : (- <Textarea- className="flex-1 resize-none border-zinc-300 bg-zinc-100 dark:border-zinc-700 dark:bg-zinc-900"- value={shortDescription}- onChange={(ev) => setShortDescription(ev.currentTarget.value)}- />- )}+ <ExploreCardInputs+ name={name}+ setName={setName}+ difficulty={difficulty}+ setDifficulty={setDifficulty}+ shortDescription={shortDescription}+ setShortDescription={setShortDescription}+ /></TabsContent><TabsContentvalue="long-description"diff --git a/src/app/create/preview/page.tsx b/src/app/create/preview/page.tsxindex 47a487ff..0baf7859 100644--- a/src/app/create/preview/page.tsx+++ b/src/app/create/preview/page.tsx@@ -6,7 +6,7 @@ import { useRouter } from 'next/navigation';import { CodePanel } from '~/components/challenge/editor';import { Tabs, TabsContent, TabsList, TabsTrigger } from '~/components/ui/tabs';import { Markdown } from '../../../components/ui/markdown';-import { ExploreCard } from '../../../components/explore/explore-card';+import ExploreCard from '../../../components/explore/explore-card';import { Button } from '../../../components/ui/button';export default function PreviewCreatedChallenge() {@@ -30,21 +30,21 @@ export default function PreviewCreatedChallenge() {<ChallengeLayoutleft={<Tabs- defaultValue="description"+ defaultValue="card"className="flex h-full w-full flex-col border-zinc-300 dark:border-zinc-700"><TabsList className="sticky top-0 z-10 grid h-auto w-full grid-cols-2 rounded-none border-b border-zinc-300 bg-background/90 backdrop-blur-sm dark:border-zinc-700 dark:bg-muted/90"><TabsTrigger- value="description"- className="rounded-md rounded-tr-lg duration-300 data-[state=active]:bg-neutral-200 dark:data-[state=active]:bg-neutral-700"+ value="card"+ className="rounded-md rounded-tl-xl duration-300 data-[state=active]:bg-neutral-200 dark:data-[state=active]:bg-neutral-700">- Description+ Card</TabsTrigger><TabsTrigger- value="card"- className="rounded-md rounded-tl-lg duration-300 data-[state=active]:bg-neutral-200 dark:data-[state=active]:bg-neutral-700"+ value="description"+ className="rounded-md rounded-tr-lg duration-300 data-[state=active]:bg-neutral-200 dark:data-[state=active]:bg-neutral-700">- Card+ Description</TabsTrigger></TabsList><TabsContent@@ -57,9 +57,8 @@ export default function PreviewCreatedChallenge() {</TabsContent><TabsContentvalue="card"- className="mt-0 flex flex-1 flex-col gap-3 p-4 dark:bg-muted [&[hidden]]:hidden"+ className="mt-0 flex flex-1 flex-col gap-3 p-4 dark:bg-background [&[hidden]]:hidden">- <h1>Card Preview</h1><ExploreCardchallenge={{...createChallengeStore.data,@@ -69,7 +68,7 @@ export default function PreviewCreatedChallenge() {comment: 0,},updatedAt: new Date(),- difficulty: 'BEGINNER',+ difficulty: createChallengeStore.data.difficulty,}}/></TabsContent>diff --git a/src/app/page.tsx b/src/app/page.tsxindex 835bdfb1..bf7d88c7 100644--- a/src/app/page.tsx+++ b/src/app/page.tsx@@ -12,10 +12,7 @@ export default function Index() {/><link rel="icon" href="/favicon.svg" type="image/svg+xml" /></Head>- <div- className="relative mb-[56px] flex flex-col items-center justify-center gap-4 overflow-x-hidden overflow-y-visible px-4"- style={{ minHeight: 'calc(100dvh - 112px)' }}- >+ <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">diff --git a/src/components/challenge/left-panel.tsx b/src/components/challenge/left-panel.tsxindex 427ac2d8..d7261555 100644--- a/src/components/challenge/left-panel.tsx+++ b/src/components/challenge/left-panel.tsx@@ -45,14 +45,7 @@ export function LeftPanel({ challenge, selectedTab }: Props) {<Description challenge={challenge}></Description></div>- <div- className="sticky bottom-0 overflow-hidden rounded-xl border border-zinc-300 border-b-background bg-background/90 backdrop-blur-sm duration-300 dark:border-zinc-700 dark:border-b-muted dark:bg-muted/90"- style={{- marginLeft: '-1px',- marginRight: '-1px',- boxShadow: '0px 0px 3rem -0.25rem #0004',- }}- >+ <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 challenge={challenge} /></div></div>diff --git a/src/components/create/explore-card-inputs.tsx b/src/components/create/explore-card-inputs.tsxnew file mode 100644index 00000000..09be5ee1--- /dev/null+++ b/src/components/create/explore-card-inputs.tsx@@ -0,0 +1,142 @@+'use client';+// TODO: unify this with the explore card into single component (maybe? idk how that'd work, too many changes)+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';++import { Select, SelectContent, SelectItem, SelectTrigger } from '../../components/ui/select';+import { Checkbox } from '~/components/ui/checkbox';+import { Label } from '~/components/ui/label';++import { type Difficulty } from '@prisma/client';+import { useState } from 'react';++// NOTE: this does not have hover: effects from explore-card+const GRADIENTS_BY_DIFFICULTY = {+ BEGINNER:+ 'bg-gradient-to-br bg-[length:200%_200%] bg-left-top dark:from-pink-950 dark:via-pink-500 dark:to-pink-300 dark:via-30% via-30% via-pink-500 from-pink-300 to-pink-600',+ EASY: 'bg-gradient-to-br bg-[length:200%_200%] bg-left-top dark:from-green-950 dark:via-green-500 dark:to-green-300 dark:via-30% via-30% via-green-500 from-green-300 to-green-600',+ MEDIUM:+ 'bg-gradient-to-br bg-[length:200%_200%] bg-left-top dark:from-yellow-950 dark:via-yellow-500 dark:to-yellow-300 dark:via-30% via-30% via-yellow-500 from-yellow-300 to-yellow-600',+ HARD: 'bg-gradient-to-br bg-[length:200%_200%] bg-left-top dark:from-red-950 dark:via-red-500 dark:to-red-300 dark:via-30% via-30% via-red-500 from-red-300 to-red-600',+ EXTREME:+ 'bg-gradient-to-br bg-[length:200%_200%] bg-left-top dark:from-orange-950 dark:via-orange-500 dark:to-orange-300 dark:via-30% via-30% via-orange-500 from-orange-300 to-orange-600',+};++interface Props {+ name: string;+ setName: (name: string) => void;+ difficulty: Difficulty | 'BEGINNER';+ setDifficulty: (difficulty: Difficulty | 'BEGINNER') => void;+ shortDescription: string;+ setShortDescription: (shortDescription: string) => void;+}+const ExploreCardInputs = ({+ name,+ setName,+ difficulty,+ setDifficulty,+ shortDescription,+ setShortDescription,+}: Props) => {+ const [isPreviewing, setIsPreviewing] = useState({+ shortDescription: false,+ });++ return (+ <Card+ className={`group overflow-hidden duration-300+ ${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-white/70">Challenge Difficulty Level:</h1>+ <Select onValueChange={(value: Difficulty) => setDifficulty(value)} value={difficulty}>+ <SelectTrigger className="h-8 max-w-fit border-0 p-0 focus:ring-0 focus:ring-offset-0 focus-visible:border-0 focus-visible:ring-0 focus-visible:ring-offset-0">+ <DifficultyBadge difficulty={difficulty || 'BEGINNER'} />+ </SelectTrigger>+ <SelectContent className="border-zinc-300 bg-zinc-100 dark:border-zinc-700 dark:bg-zinc-900">+ <SelectItem value="BEGINNER">BEGINNER</SelectItem>+ <SelectItem value="EASY">EASY</SelectItem>+ <SelectItem value="MEDIUM">MEDIUM</SelectItem>+ <SelectItem value="HARD">HARD</SelectItem>+ <SelectItem value="EXTREME">EXTREME</SelectItem>+ </SelectContent>+ </Select>+ <h1 className="pt-3 text-sm text-white/70">Challenge Title:</h1>+ <CardTitle className="pb-4 pt-0 text-4xl text-white">+ <input+ className="bg-transparent placeholder-white/70 focus:outline-none"+ style={{ textShadow: '0 0 0.5rem #0003' }}+ value={name}+ placeholder="Enter Challenge Title"+ onChange={(ev) => setName(ev.currentTarget.value)}+ />+ </CardTitle>+ </div>+ </CardHeader>+ <CardContent className="relative rounded-xl bg-background p-6 duration-300 group-hover:bg-card-hovered">+ <div className="absolute right-7 top-1 flex h-12 w-12 -translate-y-1/2 items-center justify-center rounded-full bg-background duration-300 group-hover:bg-card-hovered">+ <PlayCircle />+ </div>++ <div className="mb-1 flex items-center justify-between pr-1">+ <h1 className="text-sm text-white/70">Short Description:</h1>++ <Label+ htmlFor="preview"+ className="flex cursor-pointer items-center gap-2 text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"+ >+ Preview:+ <Checkbox+ id="preview"+ className="border-zinc-500"+ checked={isPreviewing.shortDescription}+ onCheckedChange={(checked) =>+ setIsPreviewing((rest) => ({ ...rest, shortDescription: checked === true }))+ }+ />+ </Label>+ </div>+ <CardDescription className="relative h-14 max-w-[75%] 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))]" />+ {isPreviewing.shortDescription ? (+ <Markdown>{shortDescription}</Markdown>+ ) : (+ <textarea+ className="w-full resize-none bg-transparent text-white placeholder-white/70 focus:outline-none"+ value={shortDescription}+ placeholder="Enter Short Description"+ onChange={(ev) => setShortDescription(ev.currentTarget.value)}+ />+ )}+ </CardDescription>+ <div className="flex items-end justify-between gap-8 pt-2 text-sm text-muted-foreground">+ <div className="flex flex-col items-center">+ <h1 className="text-4xl font-bold text-black dark:text-white">0</h1>+ <span>Comments</span>+ </div>+ <div className="mr-auto flex flex-col items-center">+ <h1 className="text-4xl font-bold text-black dark:text-white">0</h1>+ <span>Solutions</span>+ </div>+ <div className="flex flex-col items-end gap-4">+ <div className="flex items-center justify-center gap-2 text-center">+ <Bookmark size={20} className="mr-2" />+ <ThumbsUp size={20} />+ <span>69</span>+ </div>+ {getRelativeTime(new Date())}+ </div>+ </div>+ </CardContent>+ </Card>+ );+};++export default ExploreCardInputs;diff --git a/src/components/explore/explore-card.tsx b/src/components/explore/explore-card.tsxindex 11a79429..c88cf4c7 100644--- a/src/components/explore/explore-card.tsx+++ b/src/components/explore/explore-card.tsx@@ -1,16 +1,16 @@'use client';-import { ThumbsUp } from 'lucide-react';+import { ThumbsUp, PlayCircle, Bookmark } from 'lucide-react';import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card';import { DifficultyBadge } from './difficulty-badge';import { Markdown } from '../ui/markdown';import { getRelativeTime } from '~/utils/relativeTime';-import { type ExploreChallengeData } from '.';+import { type ExploreChallengeData } from './';interface Props {challenge: Pick<- ExploreChallengeData[number],+ Awaited<ExploreChallengeData>[0],'difficulty' | 'name' | 'shortDescription' | '_count' | 'updatedAt'>;}@@ -28,45 +28,79 @@ const BORDERS_BY_DIFFICULTY = {const SHADOWS_BY_DIFFICULTY = {BEGINNER:- 'hover:shadow-[0_0_1rem_-0.5rem_#f9a8d4,inset_0_0_1rem_-0.5rem_#f9a8d4] group-focus:shadow-[0_0_1rem_-0.5rem_#f9a8d4,inset_0_0_1rem_-0.5rem_#f9a8d4]',- EASY: 'hover:shadow-[0_0_1rem_-0.5rem_#86efac,inset_0_0_1rem_-0.5rem_#86efac] group-focus:shadow-[0_0_1rem_-0.5rem_#86efac,inset_0_0_1rem_-0.5rem_#86efac]',+ 'hover:shadow-[0_0_1rem_-0.15rem_#f9a8d4] group-focus:shadow-[0_0_1rem_-0.15rem_#f9a8d4]',+ EASY: 'hover:shadow-[0_0_1rem_-0.15rem_#86efac] group-focus:shadow-[0_0_1rem_-0.15rem_#86efac]',+ MEDIUM: 'hover:shadow-[0_0_1rem_-0.15rem_#fde047] group-focus:shadow-[0_0_1rem_-0.15rem_#fde047]',+ HARD: 'hover:shadow-[0_0_1rem_-0.15rem_#fca5a5] group-focus:shadow-[0_0_1rem_-0.15rem_#fca5a5]',+ EXTREME:+ 'hover:shadow-[0_0_1rem_-0.15rem_#fdba74] group-focus:shadow-[0_0_1rem_-0.15rem_#fdba74]',+};++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',MEDIUM:- 'hover:shadow-[0_0_1rem_-0.5rem_#fde047,inset_0_0_1rem_-0.5rem_#fde047] group-focus:shadow-[0_0_1rem_-0.5rem_#fde047,inset_0_0_1rem_-0.5rem_#fde047]',- HARD: 'hover:shadow-[0_0_1rem_-0.5rem_#fca5a5,inset_0_0_1rem_-0.5rem_#fca5a5] group-focus:shadow-[0_0_1rem_-0.5rem_#fca5a5,inset_0_0_1rem_-0.5rem_#fca5a5]',+ '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',EXTREME:- 'hover:shadow-[0_0_1rem_-0.5rem_#fdba74,inset_0_0_1rem_-0.5rem_#fdba74] group-focus:shadow-[0_0_1rem_-0.5rem_#fdba74,inset_0_0_1rem_-0.5rem_#fdba74]',+ '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',};-export function ExploreCard({ challenge }: Props) {+const ExploreCard = ({ challenge }: Props) => {return (<Card- className={`group duration-300 hover:bg-card-hovered group-focus:bg-card-hovered ${- SHADOWS_BY_DIFFICULTY[challenge.difficulty]- } ${BORDERS_BY_DIFFICULTY[challenge.difficulty]}`}+ className={`group overflow-hidden duration-300+ ${GRADIENTS_BY_DIFFICULTY[challenge.difficulty]}+ ${SHADOWS_BY_DIFFICULTY[challenge.difficulty]}+ ${BORDERS_BY_DIFFICULTY[challenge.difficulty]}+ `}>- <CardHeader className="grid items-start gap-4 space-y-0">- <div className="space-y-1">- <CardTitle className="pb-4">{challenge.name}</CardTitle>- <CardDescription className="relative h-48 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>+ {/* TODO: add background shapes grid pattern */}+ <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-4xl text-white"+ style={{ textShadow: '0 0 0.5rem #0003' }}+ >+ {challenge.name}+ </CardTitle></div></CardHeader>- <CardContent>- <div className="flex justify-between text-sm text-muted-foreground">- <div className="flex">- <div className="flex items-center">- <DifficultyBadge difficulty={challenge.difficulty} />- </div>- <div className="ml-4 flex items-center justify-center text-center">- <ThumbsUp size={20} className="mr-2" />+ <CardContent className="relative rounded-xl bg-background p-6 duration-300 group-hover:bg-card-hovered">+ <div className="absolute right-7 top-1 flex h-12 w-12 -translate-y-1/2 items-center justify-center rounded-full bg-background duration-300 group-hover:bg-card-hovered">+ <PlayCircle />+ </div>+ <CardDescription className="relative h-14 max-w-[75%] 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="flex items-end justify-between gap-8 pt-2 text-sm text-muted-foreground">+ <div className="flex flex-col items-center">+ <h1 className="text-4xl font-bold text-black dark:text-white">+ {challenge._count.comment}+ </h1>+ <span>Comments</span>+ </div>+ <div className="mr-auto flex flex-col items-center">+ <h1 className="text-4xl font-bold text-black dark:text-white">+ {challenge._count.solution}+ </h1>+ <span>Solutions</span>+ </div>+ <div className="flex flex-col items-end gap-4">+ <div className="flex items-center justify-center gap-2 text-center">+ <Bookmark size={20} className="mr-2" />+ <ThumbsUp size={20} /><span>{challenge._count.vote}</span></div>+ {getRelativeTime(challenge.updatedAt)}</div>- <div>{getRelativeTime(challenge.updatedAt)}</div></div></CardContent></Card>);-}+};++export default ExploreCard;diff --git a/src/components/explore/section.tsx b/src/components/explore/section.tsxindex ae96d199..7a6d14e1 100644--- a/src/components/explore/section.tsx+++ b/src/components/explore/section.tsx@@ -1,6 +1,8 @@import type { ExploreChallengeData } from '.';-import Card from '~/components/card';import type { Difficulty } from '@prisma/client';+import Link from 'next/link';+import Card from './explore-card';+// import Card2 from '~/components/card';interface Props {data: ExploreChallengeData;@@ -17,7 +19,7 @@ const difficultyToNumber: Record<Difficulty, number> = {export function ExploreSection({ data }: Props) {const challenges = data;return (- <div className="grid gap-4 @container/explore-section sm:grid-cols-2 lg:grid-cols-3">+ <div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">{challenges.sort((a, b) =>difficultyToNumber[a.difficulty] !== difficultyToNumber[b.difficulty]@@ -25,14 +27,21 @@ export function ExploreSection({ data }: Props) {: a.name.localeCompare(b.name),).map((challenge) => (- <Card- key={`challenge-${challenge.id}`}- title={challenge.name}- variant={challenge.difficulty}- content="what"- challenge={challenge}- />+ <Link+ className="group focus:outline-none"+ href={`/challenge/${challenge.id}`}+ key={challenge.id}+ >+ <Card key={`challenge-${challenge.id}`} challenge={challenge} />+ </Link>))}+ {/* <Card2+ key={`challenge-${challenge.id}`}+ title={challenge.name}+ variant={challenge.difficulty}+ content="what"+ challenge={challenge}+ /> */}</div>);}