Skip to content

Commit b24e8ae

Browse files
committed
feat: clean up video course cards
1 parent c3f2e1b commit b24e8ae

File tree

4 files changed

+45
-48
lines changed

4 files changed

+45
-48
lines changed
Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
import { Image } from "@/components/Image"
2-
import Link from "@/components/ui/Link"
2+
import { Card } from "@/components/ui/card"
33
import { Tag } from "@/components/ui/tag"
44

55
import { cn } from "@/lib/utils/cn"
66

77
import type { VideoCourse } from "../types"
88

9-
type BuildCardProps = {
9+
type VideoCourseCardProps = {
1010
course: VideoCourse
1111
className?: string
1212
}
1313

14-
const VideoCourseCard = ({ course, className }: BuildCardProps) => (
15-
<Link
14+
const VideoCourseCard = ({ course, className }: VideoCourseCardProps) => (
15+
<Card
1616
href={course.href}
17-
className={cn(
18-
"group flex h-full w-fit flex-col gap-4 rounded-4xl no-underline",
19-
className
20-
)}
21-
hideArrow
17+
className={cn("group h-full w-fit rounded-4xl no-underline", className)}
2218
>
2319
<div className="h-fit w-full overflow-hidden rounded-2xl">
2420
<Image
@@ -32,16 +28,17 @@ const VideoCourseCard = ({ course, className }: BuildCardProps) => (
3228
<Tag
3329
status="warning"
3430
size="small"
35-
className="mb-0 rounded-[4px] px-1 py-px font-bold normal-case"
31+
className="mb-2 mt-4 rounded-[4px] px-1 py-0 font-bold normal-case"
3632
>
33+
{/* // TODO: Extract intl */}
3734
{Math.round(course.hours)}-hour course
3835
</Tag>
39-
<h3 className="groupfont-bold text-lg text-body group-hover:underline">
36+
<h3 className="text-lg font-bold text-body group-hover:underline">
4037
{course.title}
4138
</h3>
4239
<p className="mb-4 text-sm text-body-medium">{course.description}</p>
4340
</div>
44-
</Link>
41+
</Card>
4542
)
4643

4744
export default VideoCourseCard

app/[locale]/developers/_components/VideoCourseSwiper/index.tsx

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,21 @@ import { Swiper, SwiperSlide } from "@/components/ui/swiper"
55
import type { VideoCourse } from "../../types"
66
import VideoCourseCard from "../VideoCourseCard"
77

8-
import { useBreakpointValue } from "@/hooks/useBreakpointValue"
9-
108
type VideoCourseSwiperProps = {
119
courses: VideoCourse[]
1210
}
1311

14-
const VideoCourseSwiper = ({ courses }: VideoCourseSwiperProps) => {
15-
const slidesPerView = useBreakpointValue({
16-
base: 1.25,
17-
sm: 1.6,
18-
md: 2.7,
19-
lg: 4.4,
20-
xl: 5,
21-
})
22-
const spaceBetween = useBreakpointValue({
23-
base: 16,
24-
sm: 12,
25-
md: 16,
26-
lg: 24,
27-
xl: 32,
28-
})
29-
30-
return (
31-
<Swiper spaceBetween={spaceBetween} slidesPerView={slidesPerView}>
32-
{courses.map((course, idx) => (
33-
<SwiperSlide
34-
key={idx}
35-
className="max-xl:first:ms-8 max-xl:[&:last-child_div]:pe-16"
36-
>
37-
<VideoCourseCard course={course} />
38-
</SwiperSlide>
39-
))}
40-
</Swiper>
41-
)
42-
}
12+
const VideoCourseSwiper = ({ courses }: VideoCourseSwiperProps) => (
13+
<Swiper spaceBetween={16} slidesPerView={1.25}>
14+
{courses.map((course, idx) => (
15+
<SwiperSlide
16+
key={idx}
17+
className="max-xl://[&:last-child_div]:pe-16 max-2xl:first:ms-8 max-2xl:last:pe-16"
18+
>
19+
<VideoCourseCard course={course} />
20+
</SwiperSlide>
21+
))}
22+
</Swiper>
23+
)
4324

4425
export default VideoCourseSwiper
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { SkeletonCardGrid } from "@/components/ui/skeleton"
22

3-
const Loading = () => <SkeletonCardGrid />
3+
const Loading = () => (
4+
<div className="px-8">
5+
<SkeletonCardGrid />
6+
</div>
7+
)
48

59
export default Loading

app/[locale]/developers/page.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ const RightColumn = (props: ChildOnlyProp) => (
4545
<div className="mb-6 me-0 w-full flex-1 basis-1/3" {...props} />
4646
)
4747

48+
const Scroller = ({
49+
className,
50+
...props
51+
}: React.HTMLAttributes<HTMLDivElement>) => {
52+
return (
53+
<div
54+
className={cn(
55+
"relative flex w-screen gap-6 overflow-x-auto pb-2 max-2xl:-mx-8 max-2xl:px-8 max-sm:hidden lg:gap-8 2xl:w-full",
56+
className
57+
)}
58+
{...props}
59+
/>
60+
)
61+
}
62+
4863
const DevelopersPage = async ({
4964
params,
5065
}: {
@@ -243,20 +258,20 @@ const DevelopersPage = async ({
243258
</Card>
244259
</Section>
245260

246-
<Section id="courses" className="space-y-4 py-10 md:py-12">
261+
<Section id="courses" className="space-y-4 py-6">
247262
<h2>{t("page-developers-video-courses-title")}</h2>
248263
<p>{t("page-developers-video-courses-desc")}</p>
249264

250265
{/* DESKTOP */}
251-
<div className="flex w-screen gap-6 overflow-x-auto max-2xl:-mx-8 max-2xl:pe-8 max-sm:hidden lg:gap-8 2xl:w-full">
266+
<Scroller>
252267
{courses.map((course, idx) => (
253268
<VideoCourseCard
254269
key={idx}
255270
course={course}
256-
className="w-[20%] min-w-[240px] max-w-[271px] max-2xl:first:ms-8"
271+
className="w-[20%] max-w-[271px] flex-1 max-2xl:min-w-[20rem] xl:w-full"
257272
/>
258273
))}
259-
</div>
274+
</Scroller>
260275

261276
{/* MOBILE */}
262277
<div className="w-screen max-xl:-ms-8 sm:hidden xl:w-full">

0 commit comments

Comments
 (0)