Skip to content

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

Animation fixes (#272)

PickleNikf869bec9fdae
diff --git a/src/components/challenge/challenge-layout.tsx b/src/components/challenge/challenge-layout.tsx
index db3f3122..adb836ad 100644
--- a/src/components/challenge/challenge-layout.tsx
+++ b/src/components/challenge/challenge-layout.tsx
@@ -176,7 +176,7 @@ export function ChallengeLayout({ left, right, skeleton = false }: ChallengeLayo
<div
ref={leftSide}
className={clsx(
- 'min-h-[42px] w-full overflow-hidden rounded-l-2xl rounded-r-xl border border-zinc-300 bg-white dark:border-zinc-700 dark:bg-zinc-800 lg:min-w-[500px]',
+ 'min-h-[318px] w-full overflow-hidden rounded-l-2xl rounded-r-xl border border-zinc-300 bg-white dark:border-zinc-700 dark:bg-zinc-800 lg:min-w-[500px]',
skeleton && 'animate-pulse',
)}
>
diff --git a/src/components/challenge/comments/comment.tsx b/src/components/challenge/comments/comment.tsx
index 978d6e2f..1f23972f 100644
--- a/src/components/challenge/comments/comment.tsx
+++ b/src/components/challenge/comments/comment.tsx
@@ -10,7 +10,6 @@ import { useSession } from 'next-auth/react';
import { toast } from '~/components/ui/use-toast';
import ReportDialog from '~/components/report';
-
interface CommentProps {
comment: ChallengeRouteData['comment'][number];
}
@@ -67,12 +66,14 @@ const Comment = ({ comment }: CommentProps) => {
return (
<div className="flex flex-col gap-1 p-3 pt-2">
- <div className="flex justify-between pr-[0.4rem]">
+ <div className="flex items-start 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>
+ <span className="mr-2 whitespace-nowrap text-sm text-neutral-500">
+ {getRelativeTime(comment.createdAt)}
+ </span>
</TooltipTrigger>
<TooltipContent align="start" className="rounded-xl">
<span className="text-white-500 text-xs">{comment.createdAt.toLocaleString()}</span>
@@ -80,12 +81,12 @@ const Comment = ({ comment }: CommentProps) => {
</Tooltip>
</div>
- <div className="flex items-center gap-2">
+ <div className="flex flex-wrap items-center justify-end gap-2">
<div
onClick={() => {
copyPathNotifyUser();
}}
- className="gap-1 cursor-pointer duration-200 flex items-center hover:underline text-neutral-500 hover:text-neutral-400"
+ className="flex cursor-pointer items-center gap-1 text-neutral-500 duration-200 hover:text-neutral-400 hover:underline"
>
<Share className="h-3 w-3" />
<small className="font-md text-sm leading-none">Share</small>
@@ -102,10 +103,7 @@ const Comment = ({ comment }: CommentProps) => {
Delete
</button>
) : (
- <ReportDialog
- reportType="COMMENT"
- commentId={comment.id}
- >
+ <ReportDialog reportType="COMMENT" commentId={comment.id}>
<button
onClick={() => {
setDialogOpen(true);
@@ -116,7 +114,6 @@ const Comment = ({ comment }: CommentProps) => {
</button>
</ReportDialog>
)}
-
</div>
</div>
<p className="w-full break-words pl-[1px] text-sm">
diff --git a/src/components/challenge/comments/index.tsx b/src/components/challenge/comments/index.tsx
index e0c6023f..124019b9 100644
--- a/src/components/challenge/comments/index.tsx
+++ b/src/components/challenge/comments/index.tsx
@@ -88,9 +88,9 @@ const Comments = ({ challengeId, commentCount }: Props) => {
return (
<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]',
+ 'sticky bottom-0 overflow-hidden border-t 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,
+ 'lg:border-t-none': showComments,
},
)}
>
@@ -110,11 +110,14 @@ const Comments = ({ challengeId, commentCount }: Props) => {
></ChevronDown>
</button>
<div
- className={clsx('custom-scrollable-element 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,
- })}
+ className={clsx(
+ 'custom-scrollable-element flex flex-col-reverse overscroll-contain duration-300',
+ {
+ 'h-36 pb-2 lg:h-[calc(100vh_-_247px)]': showComments,
+ 'h-0 overflow-y-hidden': !showComments,
+ 'overflow-y-auto': showComments && data?.pages[0]?.data.length !== 0,
+ },
+ )}
>
{(status === 'loading' || isFetchingNextPage) && <CommentSkeleton />}
{status === 'success' &&
diff --git a/src/components/explore/explore-card.tsx b/src/components/explore/explore-card.tsx
index f7327fd9..5962a1ee 100644
--- a/src/components/explore/explore-card.tsx
+++ b/src/components/explore/explore-card.tsx
@@ -1,4 +1,3 @@
-
import { Circle, Diamond, MessageCircle, Plus, Sparkle, ThumbsUp, Triangle } from 'lucide-react';
import { getRelativeTime } from '~/utils/relativeTime';
@@ -57,19 +56,19 @@ 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 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>
+ <Circle className="absolute -right-4 -top-8 h-24 w-24 origin-top-right stroke-1 text-white/30 duration-300 group-hover:scale-90 dark:group-hover:text-black/30"></Circle>
+ <Circle className="absolute -right-4 -top-8 h-32 w-32 origin-top-right stroke-1 text-white/30 duration-500 group-hover:scale-90 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 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>
+ <Diamond className="absolute -right-5 -top-10 h-24 w-24 origin-top-right stroke-1 text-white/30 duration-300 group-hover:scale-90 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-300 group-hover:-translate-y-2 group-hover:translate-x-2 group-hover:-rotate-12 group-hover:scale-90 dark:group-hover:text-black/30"></Diamond>
</>
)}
{challenge.difficulty === 'MEDIUM' && (
<>
- <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-4 -top-6 h-20 w-20 rotate-[40deg] stroke-2 text-white/50 duration-200 group-hover:rotate-0 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>
</>
)}
@@ -82,10 +81,10 @@ const ExploreCard = ({ challenge }: ExploreCardProps) => {
{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] 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>
+ <Sparkle className="absolute -right-12 -top-20 h-48 w-48 origin-top-right stroke-1 text-white/40 duration-300 group-hover:scale-50 dark:group-hover:text-black/30"></Sparkle>
</>
)}
- <CardHeader className="relative flex flex-col py-5 items-start gap-1">
+ <CardHeader className="relative flex flex-col items-start gap-1 py-5">
<CardTitle className="max-w-[75%] truncate text-2xl text-white duration-300 dark:text-white dark:group-hover:text-black/70">
{challenge.name}
</CardTitle>
@@ -103,10 +102,12 @@ const ExploreCard = ({ challenge }: ExploreCardProps) => {
</CardHeader>
<CardContent className="relative flex flex-col justify-between gap-2 rounded-xl bg-background p-6 pb-0 duration-300 group-hover:bg-card-hovered">
<div className="flex items-center gap-2">
- <Button size="sm" 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" >
- @{challenge.user.name}
- </Button>
- <div className="text-sm text-muted-foreground">{getRelativeTime(challenge.updatedAt)}</div>
+ <div className="-ml-[0.33rem] flex h-auto w-fit items-center whitespace-nowrap rounded-full bg-transparent py-1 pl-[0.33rem] pr-2 text-xs font-bold text-neutral-700 duration-300 hover:bg-black/10 dark:text-white dark:hover:bg-white/20">
+ @{challenge.user.name}
+ </div>
+ <div className="whitespace-nowrap text-sm text-muted-foreground">
+ {getRelativeTime(challenge.updatedAt)}
+ </div>
</div>
<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))]" />
diff --git a/src/components/explore/index.tsx b/src/components/explore/index.tsx
index fe62f002..29851510 100644
--- a/src/components/explore/index.tsx
+++ b/src/components/explore/index.tsx
@@ -15,7 +15,6 @@ export async function Explore() {
We hope you find the <span className="font-semibold dark:text-neutral-200">perfect</span>{' '}
challenge!
</p>
-
<Suspense fallback={<ExploreSectionSkeleton />}>
<ExploreSection title="Great for Beginners" fetcher={getEasyChallenges} />
</Suspense>
diff --git a/src/components/explore/section-skeleton.tsx b/src/components/explore/section-skeleton.tsx
index e1fc149b..296e3050 100644
--- a/src/components/explore/section-skeleton.tsx
+++ b/src/components/explore/section-skeleton.tsx
@@ -3,9 +3,11 @@ import { ExploreCardSkeleton } from './explore-card-skeleton';
export function ExploreSectionSkeleton() {
return (
- <div className="container p-5 ">
- <div className="flex items-center justify-center">
+ <div className="w-full py-5">
+ <div className="flex items-center justify-between">
+ <div className="ml-4 w-16"></div>
<Skeleton className="my-4 h-10 w-1/3 rounded-lg bg-zinc-300 dark:bg-zinc-700" />
+ <Skeleton className="my-4 mr-4 h-4 w-16 rounded-lg bg-zinc-300 dark:bg-zinc-700" />
</div>
<div className="grid w-full gap-4 sm:grid-cols-2 lg:grid-cols-3">
<ExploreCardSkeleton />
diff --git a/src/components/landing/community.tsx b/src/components/landing/community.tsx
index 61cb4240..4e2612f8 100644
--- a/src/components/landing/community.tsx
+++ b/src/components/landing/community.tsx
@@ -28,7 +28,7 @@ const Community = async function () {
const avatars = await getOcto();
return (
- <section className="container flex min-h-[80lvh] flex-col justify-center lg:flex-row lg:items-center">
+ <section className="container flex min-h-[80lvh] flex-col justify-center lg:flex-row lg:items-center">
<div className="flex flex-1 flex-col items-center pb-36 lg:items-start lg:pb-0">
<h2 className="mb-2 text-center text-4xl font-bold lg:text-left">Built by the community</h2>
<span className="text-neutral-400 dark:text-neutral-600">
diff --git a/src/components/landing/hero.tsx b/src/components/landing/hero.tsx
index c938786c..e211aa61 100644
--- a/src/components/landing/hero.tsx
+++ b/src/components/landing/hero.tsx
@@ -40,7 +40,7 @@ const Hero = () => (
</filter>
<rect width="100%" height="100%" filter="url(#noise)"></rect>
</svg> */}
- <div className="container mb-[56px] grid min-h-[calc(100lvh_-_112px)] items-center justify-center lg:grid-cols-2">
+ <div className="container mb-[56px] grid min-h-[calc(100lvh_-_112px)] items-center justify-center lg:grid-cols-2">
<div className="flex w-full flex-col items-center justify-center gap-10 lg:items-start">
<div className="relative flex w-full items-center justify-center gap-4 lg:justify-start">
<div className="absolute left-1/2 top-1/2 -z-10 hidden h-56 w-56 -translate-x-[15%] -translate-y-[50%] rounded-full bg-slate-400/10 blur-3xl dark:block"></div>
@@ -58,11 +58,11 @@ const Hero = () => (
skills trough interactive coding challenges, discussions, and knowledge sharing
</p>
<div className="flex gap-3">
- <Button className="group relative flex items-center gap-2 overflow-hidden rounded-xl px-4 py-2 font-bold duration-500 dark:hover:text-white">
- <div className="absolute h-44 w-44 -translate-x-full rounded-full bg-[#3178C6] duration-500 group-hover:translate-x-0" />
- <Link className="z-10" href="/explore">
- Explore challenges
- </Link>
+ <Button
+ className="relative flex items-center gap-2 overflow-hidden rounded-xl px-4 py-2 font-bold"
+ asChild
+ >
+ <Link href="/explore">Explore challenges</Link>
</Button>
<Button
className="flex items-center gap-2 rounded-xl border-2 px-4 py-2 dark:text-white"
@@ -84,7 +84,7 @@ const Hero = () => (
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ duration: 0.6, delay: 0.3 }}
- className="moving-grid-background absolute h-full w-[200%]"
+ className="moving-grid-background absolute h-[200%] w-full"
/>
<div className="absolute h-full w-full rounded-full shadow-[inset_0_0_5rem_3rem] shadow-background" />
</div>
diff --git a/src/styles/globals.css b/src/styles/globals.css
index 7d356c00..e9e209ac 100644
--- a/src/styles/globals.css
+++ b/src/styles/globals.css
@@ -154,18 +154,19 @@ main {
}
.moving-grid-background {
+ will-change: transform;
background-size: 2.5rem 2.5rem;
background-image: linear-gradient(to right, #8882 1px, transparent 1px),
linear-gradient(to bottom, #8882 1px, transparent 1px);
- animation: movingbackground 30s linear infinite !important;
+ animation: movingbackground 90s linear infinite !important;
}
@keyframes movingbackground {
0% {
- translate: 0 0;
+ transform: translate(0, 0);
}
100% {
- translate: -50% 0;
+ transform: translate(0, -50%);
}
}