Skip to content

Commit 2a0fbfe

Browse files
committed
feat: convert Slider usage to Swiper
1 parent 265d9d2 commit 2a0fbfe

File tree

1 file changed

+60
-48
lines changed

1 file changed

+60
-48
lines changed

src/pages/what-is-ethereum.tsx

Lines changed: 60 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import { TwImage } from "@/components/Image"
2929
import MainArticle from "@/components/MainArticle"
3030
import PageMetadata from "@/components/PageMetadata"
3131
import { StandaloneQuizWidget } from "@/components/Quiz/QuizWidget"
32-
import Slider, { EmblaSlide } from "@/components/Slider"
3332
import StatErrorMessage from "@/components/StatErrorMessage"
33+
import Swiper from "@/components/Swiper"
3434
import Tabs from "@/components/Tabs"
3535
import Tooltip from "@/components/Tooltip"
3636
import Translation from "@/components/Translation"
@@ -114,8 +114,11 @@ const Section = ({ className, ...rest }: HTMLAttributes<HTMLDivElement>) => (
114114
<section className={cn("w-full px-8 py-12", className)} {...rest} />
115115
)
116116

117-
export const Width60 = (props: ChildOnlyProp) => (
118-
<div className="w-full flex-[3]" {...props} />
117+
export const Width60 = ({
118+
className,
119+
children,
120+
}: React.HTMLAttributes<HTMLDivElement>) => (
121+
<div className={cn("w-full flex-[3]", className)}>{children}</div>
119122
)
120123

121124
export const Width40 = (props: ChildOnlyProp) => (
@@ -164,6 +167,12 @@ const Image400 = ({ src }: Pick<ImageProps, "src">) => (
164167
<TwImage src={src} alt="" width={400} />
165168
)
166169

170+
const Slide = ({ children }: ChildOnlyProp) => (
171+
<div className="[&_h2,&_h3]:mt-0 relative min-w-full">
172+
<Stack className="space-x-8 space-y-8">{children}</Stack>
173+
</div>
174+
)
175+
167176
const cachedFetchTxCount = runOnlyOnce(fetchGrowThePie)
168177

169178
type Props = BasePageProps & {
@@ -393,57 +402,60 @@ const WhatIsEthereumPage = ({
393402

394403
<Section>
395404
<TwoColumnContent>
396-
<Width60>
405+
<Width60 className="lg:max-w-[60%]">
397406
<H2>
398407
{t("page-what-is-ethereum-why-would-i-use-ethereum-title")}
399408
</H2>
400-
<Stack className="gap-6">
409+
<Stack className="max-w-full gap-6">
401410
<p>{t("page-what-is-ethereum-why-would-i-use-ethereum-1")}</p>
402411
<p>{t("page-what-is-ethereum-why-would-i-use-ethereum-2")}</p>
403412

404-
<Slider
405-
onSlideChange={(index) => {
406-
trackCustomEvent({
407-
eventCategory: `What is Ethereum - Slider`,
408-
eventAction: `Clicked`,
409-
eventName: slides[index].eventName,
410-
})
411-
}}
412-
>
413-
<EmblaSlide>
414-
<H3>{t("page-what-is-ethereum-slide-1-title")}</H3>
415-
<Stack className="mb-4 gap-6">
416-
<p>
417-
<Translation id="page-what-is-ethereum:page-what-is-ethereum-slide-1-desc-1" />
418-
</p>
419-
<p>{t("page-what-is-ethereum-slide-1-desc-2")}</p>
420-
</Stack>
421-
</EmblaSlide>
422-
<EmblaSlide>
423-
<H3>{t("page-what-is-ethereum-slide-2-title")}</H3>
424-
<Stack className="mb-4 gap-6">
425-
<p>{t("page-what-is-ethereum-slide-2-desc-1")}</p>
426-
<p>
427-
<Translation id="page-what-is-ethereum:page-what-is-ethereum-slide-2-desc-2" />
428-
</p>
429-
</Stack>
430-
</EmblaSlide>
431-
<EmblaSlide>
432-
<H3>{t("page-what-is-ethereum-slide-3-title")}</H3>
433-
<Stack className="mb-4 gap-6">
434-
<p>
435-
<Translation id="page-what-is-ethereum:page-what-is-ethereum-slide-3-desc-1" />
436-
</p>
437-
</Stack>
438-
</EmblaSlide>
439-
<EmblaSlide>
440-
<H3>{t("page-what-is-ethereum-slide-4-title")}</H3>
441-
<Stack className="mb-4 gap-6">
442-
<p>{t("page-what-is-ethereum-slide-4-desc-1")}</p>
443-
<p>{t("page-what-is-ethereum-slide-4-desc-2")}</p>
444-
</Stack>
445-
</EmblaSlide>
446-
</Slider>
413+
<div className="max-w-full">
414+
<Swiper
415+
containerClassName="p-8 border rounded"
416+
onSlideChange={({ activeIndex }) => {
417+
trackCustomEvent({
418+
eventCategory: `What is Ethereum - Slider`,
419+
eventAction: `Clicked`,
420+
eventName: slides[activeIndex].eventName,
421+
})
422+
}}
423+
>
424+
<Slide>
425+
<H3>{t("page-what-is-ethereum-slide-1-title")}</H3>
426+
<Stack className="mb-4 gap-6">
427+
<p>
428+
<Translation id="page-what-is-ethereum:page-what-is-ethereum-slide-1-desc-1" />
429+
</p>
430+
<p>{t("page-what-is-ethereum-slide-1-desc-2")}</p>
431+
</Stack>
432+
</Slide>
433+
<Slide>
434+
<H3>{t("page-what-is-ethereum-slide-2-title")}</H3>
435+
<Stack className="mb-4 gap-6">
436+
<p>{t("page-what-is-ethereum-slide-2-desc-1")}</p>
437+
<p>
438+
<Translation id="page-what-is-ethereum:page-what-is-ethereum-slide-2-desc-2" />
439+
</p>
440+
</Stack>
441+
</Slide>
442+
<Slide>
443+
<H3>{t("page-what-is-ethereum-slide-3-title")}</H3>
444+
<Stack className="mb-4 gap-6">
445+
<p>
446+
<Translation id="page-what-is-ethereum:page-what-is-ethereum-slide-3-desc-1" />
447+
</p>
448+
</Stack>
449+
</Slide>
450+
<Slide>
451+
<H3>{t("page-what-is-ethereum-slide-4-title")}</H3>
452+
<Stack className="mb-4 gap-6">
453+
<p>{t("page-what-is-ethereum-slide-4-desc-1")}</p>
454+
<p>{t("page-what-is-ethereum-slide-4-desc-2")}</p>
455+
</Stack>
456+
</Slide>
457+
</Swiper>
458+
</div>
447459
</Stack>
448460
</Width60>
449461
<Width40>

0 commit comments

Comments
 (0)