Skip to content

Commit 6b896b4

Browse files
committed
Revert "deprecate: unused CodeModal"
This reverts commit 73ccfe5.
1 parent cf8a1c0 commit 6b896b4

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

src/components/CodeModal.tsx

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import type { ReactNode } from "react"
2+
import {
3+
Modal,
4+
ModalBody,
5+
ModalCloseButton,
6+
ModalContent,
7+
ModalHeader,
8+
ModalOverlay,
9+
useColorModeValue,
10+
} from "@chakra-ui/react"
11+
12+
type CodeModalProps = {
13+
title: string
14+
children: ReactNode
15+
isOpen: boolean
16+
setIsOpen: (isOpen: boolean) => void
17+
}
18+
19+
const CodeModal = ({ children, isOpen, setIsOpen, title }: CodeModalProps) => {
20+
const bgColor = useColorModeValue("rgb(247, 247, 247)", "rgb(25, 25, 25)")
21+
const borderColor = useColorModeValue("rgb(51, 51, 51)", "rgb(242, 242, 242)")
22+
23+
return (
24+
<Modal
25+
isOpen={isOpen}
26+
scrollBehavior="inside"
27+
onClose={() => setIsOpen(false)}
28+
>
29+
<ModalOverlay />
30+
<ModalContent
31+
maxW="100vw"
32+
marginTop="auto"
33+
marginBottom="0"
34+
maxHeight="50%"
35+
borderRadius="0"
36+
p={{ base: "0", md: "0" }}
37+
gap="0"
38+
>
39+
<ModalHeader
40+
bg={bgColor}
41+
borderColor={borderColor}
42+
borderTop="1px solid"
43+
borderBottom="1px solid"
44+
textTransform="uppercase"
45+
fontWeight="normal"
46+
fontSize="md"
47+
fontFamily="monospace"
48+
px="6"
49+
py="4"
50+
me="0"
51+
>
52+
{title}
53+
</ModalHeader>
54+
<ModalCloseButton
55+
position="absolute"
56+
padding="0"
57+
width="24px"
58+
height="24px"
59+
borderRadius="0"
60+
color="rgb(178, 178, 178)"
61+
fontSize="sm"
62+
margin="0"
63+
top="4"
64+
insetInlineEnd="4"
65+
bottom="4"
66+
/>
67+
<ModalBody p="0">{children}</ModalBody>
68+
</ModalContent>
69+
</Modal>
70+
)
71+
}
72+
73+
export default CodeModal

0 commit comments

Comments
 (0)