Skip to content

Commit 47bb5d7

Browse files
authored
Merge pull request #14102 from atharv-av/dev
migrated trilemma modal to shadcn ui sheet component
2 parents 6b91d23 + 7f0fbf5 commit 47bb5d7

File tree

2 files changed

+41
-53
lines changed

2 files changed

+41
-53
lines changed

src/components/Trilemma/index.tsx

Lines changed: 38 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
import { useTranslation } from "next-i18next"
2-
import {
3-
Drawer,
4-
DrawerCloseButton,
5-
DrawerContent,
6-
DrawerOverlay,
7-
Flex,
8-
Heading,
9-
Hide,
10-
Stack,
11-
Text,
12-
} from "@chakra-ui/react"
132

143
import Card from "@/components/Card"
4+
import { Flex, Stack, VStack } from "@/components/ui/flex"
5+
import { Sheet, SheetClose, SheetContent } from "@/components/ui/sheet"
156

167
import { TriangleSVG, TriangleSVGProps } from "./Triangle"
178
import { useTrilemma } from "./useTrilemma"
@@ -33,50 +24,45 @@ const Trilemma = () => {
3324
}
3425

3526
return (
36-
<Flex
37-
alignItems="center"
38-
flexDirection={{ base: "column", lg: "row" }}
39-
justifyContent="space-between"
40-
columnGap="12"
41-
rowGap="8"
42-
>
43-
<Stack
44-
spacing="8"
45-
mt={{ base: "16", md: "20" }}
46-
mb={{ lg: "20" }}
47-
ms={{ md: "12" }}
48-
me={{ md: "12", lg: 0 }}
49-
flex={{
50-
lg: "0 1 500px",
51-
}}
52-
>
53-
<Heading fontSize="2rem">
54-
{t("page-roadmap-vision-trilemma-h2")}
55-
</Heading>
56-
<Flex flexDir="column" gap="6">
57-
<Text>{t("page-roadmap-vision-trilemma-p")}</Text>
58-
<Text>{t("page-roadmap-vision-trilemma-p-1")}</Text>
59-
<Text>{t("page-roadmap-vision-trilemma-p-2")}</Text>
60-
<Text fontWeight={600} hideFrom="lg">
27+
<Flex className="flex-col items-center justify-between space-y-8 lg:flex-row lg:space-x-12 lg:space-y-0">
28+
<Stack className="mt-16 space-y-8 md:mx-12 md:mt-20 lg:mb-20 lg:mr-0 lg:flex-[0_1_500px]">
29+
<h2>{t("page-roadmap-vision-trilemma-h2")}</h2>
30+
<VStack className="space-y-6">
31+
<p>{t("page-roadmap-vision-trilemma-p")}</p>
32+
<p>{t("page-roadmap-vision-trilemma-p-1")}</p>
33+
<p>{t("page-roadmap-vision-trilemma-p-2")}</p>
34+
<p className="font-semibold lg:hidden">
6135
{t("page-roadmap-vision-trilemma-modal-tip")}:
62-
</Text>
63-
</Flex>
36+
</p>
37+
</VStack>
6438
<Card {...cardDetail} minH="300px" hideBelow="lg" mt="6" />
6539
</Stack>
66-
<Hide above="lg">
67-
<Drawer
68-
isOpen={mobileModalOpen}
69-
onClose={handleModalClose}
70-
placement="bottom"
71-
>
72-
<DrawerOverlay background="rgba(0,0,0,0.3)" />
73-
<DrawerContent borderTopRadius="2xl" background="background.base">
74-
<Card {...cardDetail} background="none" border="none" my="8" />
75-
<DrawerCloseButton top="6" insetInlineEnd="6" />
76-
</DrawerContent>
77-
</Drawer>
78-
</Hide>
79-
<TriangleSVG {...triangleSVGProps} />
40+
<Sheet open={mobileModalOpen} onOpenChange={handleModalClose}>
41+
<SheetContent side="bottom" className="rounded-t-[16px]">
42+
<Card {...cardDetail} background="none" border="none" my="8" />
43+
<SheetClose className="absolute right-3 top-5">
44+
<span className="sr-only">Close</span>
45+
<svg
46+
xmlns="http://www.w3.org/2000/svg"
47+
width="20"
48+
height="20"
49+
viewBox="0 0 24 24"
50+
fill="none"
51+
stroke="currentColor"
52+
strokeWidth="2"
53+
strokeLinecap="round"
54+
strokeLinejoin="round"
55+
>
56+
<line x1="18" y1="6" x2="6" y2="18"></line>
57+
<line x1="6" y1="6" x2="18" y2="18"></line>
58+
</svg>
59+
</SheetClose>
60+
</SheetContent>
61+
</Sheet>
62+
63+
<div>
64+
<TriangleSVG {...triangleSVGProps} />
65+
</div>
8066
</Flex>
8167
)
8268
}

src/components/Trilemma/useTrilemma.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useState } from "react"
22
import { useTranslation } from "next-i18next"
33

4+
import { isMobile } from "@/lib/utils/isMobile"
5+
46
import { CardProps } from "../Card"
57

68
/**
@@ -101,7 +103,7 @@ export const useTrilemma = () => {
101103
isSecure,
102104
isScalable,
103105
},
104-
mobileModalOpen: state.mobileModalOpen,
106+
mobileModalOpen: state.mobileModalOpen && isMobile(),
105107
handleClick,
106108
handleModalClose,
107109
cardDetail: {

0 commit comments

Comments
 (0)