Skip to content

Commit 4e89a0d

Browse files
committed
feat: re-implement desktop code example modal
1 parent 9750bdf commit 4e89a0d

File tree

1 file changed

+22
-38
lines changed

1 file changed

+22
-38
lines changed

src/pages/index.tsx

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {
1313

1414
import SvgButtonLink from "@/components/Buttons/SvgButtonLink"
1515
import { ChevronNext } from "@/components/Chevron"
16+
import CodeModal from "@/components/CodeModal"
1617
import HomeHero from "@/components/Hero/HomeHero"
1718
import BentoCard from "@/components/Homepage/BentoCard"
1819
import { useHome } from "@/components/Homepage/useHome"
@@ -24,7 +25,7 @@ import MainArticle from "@/components/MainArticle"
2425
import PageMetadata from "@/components/PageMetadata"
2526
import Swiper from "@/components/Swiper"
2627
import { TranslatathonBanner } from "@/components/Translatathon/TranslatathonBanner"
27-
import { Button, ButtonLink } from "@/components/ui/buttons/Button"
28+
import { ButtonLink } from "@/components/ui/buttons/Button"
2829
import {
2930
Card,
3031
CardBanner,
@@ -355,44 +356,8 @@ const HomePage = ({
355356

356357
{/* Builders - Blockchain's biggest builder community */}
357358
<Section id="builders" variant="responsiveFlex">
358-
<SectionBanner
359-
className={cn(
360-
"relative transition-[max-width] duration-500 ease-linear md:max-w-96 lg:max-w-128",
361-
isModalOpen && "duration-300 md:max-w-[50%] lg:max-w-[50%]"
362-
)}
363-
>
359+
<SectionBanner className="relative">
364360
<TwImage src={BuildersImage} alt="" />
365-
366-
{isModalOpen && (
367-
<div className="absolute inset-0.5 my-auto h-fit max-h-[75%] overflow-y-auto rounded-4xl bg-background-highlight pb-0.5 transition-all max-md:hidden">
368-
<div
369-
className="sticky top-0 z-10 bg-background-highlight py-1"
370-
style={{
371-
mask: "linear-gradient(to bottom, white 90%, transparent)",
372-
}}
373-
>
374-
<Button
375-
onClick={() => setModalOpen(false)}
376-
className="me-4 ms-auto block"
377-
variant="ghost"
378-
>
379-
{t("close")}
380-
</Button>
381-
</div>
382-
<div className="z-0 max-h-[calc(100%_-_128px)] overflow-auto">
383-
<Suspense fallback={<SkeletonLines noOfLines={32} />}>
384-
<Codeblock
385-
codeLanguage={codeExamples[activeCode].codeLanguage}
386-
allowCollapse={false}
387-
fromHomepage
388-
className="[&>div]:mb-0 [&>div]:max-h-[calc(100%_-_128px)] [&>div]:rounded-[calc(theme('borderRadius.4xl')_-_2px)] [&>div]:p-2 [&_*]:!text-sm [&_pre]:py-2"
389-
>
390-
{codeExamples[activeCode].code}
391-
</Codeblock>
392-
</Suspense>
393-
</div>
394-
</div>
395-
)}
396361
</SectionBanner>
397362

398363
<SectionContent>
@@ -473,6 +438,25 @@ const HomePage = ({
473438
)}
474439
</Accordion>
475440
</WindowBox>
441+
{isModalOpen && (
442+
// TODO: Migrate CodeModal, CodeBlock from Chakra-UI to tailwind/shad-cn
443+
<CodeModal
444+
isOpen={isModalOpen}
445+
setIsOpen={setModalOpen}
446+
title={codeExamples[activeCode].title}
447+
>
448+
<Suspense fallback={<SkeletonLines noOfLines={16} />}>
449+
<Codeblock
450+
codeLanguage={codeExamples[activeCode].codeLanguage}
451+
allowCollapse={false}
452+
className="[&_pre]:p-6"
453+
fromHomepage
454+
>
455+
{codeExamples[activeCode].code}
456+
</Codeblock>
457+
</Suspense>
458+
</CodeModal>
459+
)}
476460
</div>
477461
</SectionContent>
478462
</Section>

0 commit comments

Comments
 (0)