Skip to content

Commit 7039220

Browse files
authored
Merge pull request #11212 from ashiskumar-1999/dev
fix: Implement DS styles and unify modals
2 parents bd0b88d + 181a754 commit 7039220

File tree

17 files changed

+289
-273
lines changed

17 files changed

+289
-273
lines changed

src/@chakra-ui/components/Modal.ts

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,57 +12,63 @@ const {
1212
defaultProps,
1313
} = modalDefaultTheme
1414

15-
const variantCode = definePartsStyle((props) => ({
16-
overlay: {
17-
bg: "rgba(0, 0, 0, 0.7)",
18-
},
19-
dialog: {
20-
maxW: "100vw",
21-
marginTop: "auto",
22-
marginBottom: 0,
23-
maxHeight: "50%",
24-
borderRadius: 0,
25-
},
26-
header: {
27-
bg: props.colorMode === "dark" ? "rgb(25, 25, 25)" : "rgb(247, 247, 247)",
28-
borderColor:
29-
props.colorMode == "dark" ? "rgb(242, 242, 242)" : "rgb(51, 51, 51)",
30-
borderTop: "1px solid",
31-
borderBottom: "1px solid",
32-
textTransform: "uppercase",
33-
fontWeight: "normal",
34-
fontSize: "md",
35-
fontFamily: "monospace",
36-
},
37-
closeButton: {
38-
padding: 0,
39-
width: "24px",
40-
height: "24px",
41-
borderRadius: 0,
42-
color: "rgb(178, 178, 178)",
43-
fontSize: "sm",
44-
margin: 0,
45-
top: 4,
46-
insetInlineEnd: 4,
47-
bottom: 4,
48-
},
49-
body: {
50-
padding: 0,
51-
},
52-
}))
53-
5415
export const Modal = defineMultiStyleConfig({
5516
baseStyle: definePartsStyle((props) =>
5617
defineMergeStyles(defaultBaseStyle?.(props), {
5718
dialog: {
58-
my: 0,
19+
bg: "background.base",
20+
gap: "4",
21+
padding: { base: "4", sm: "8" },
22+
borderRadius: "base",
23+
boxShadow: "none",
24+
},
25+
header: {
26+
flex: "1",
27+
padding: "0",
28+
fontWeight: "bold",
29+
fontSize: "2xl",
30+
me: "8",
31+
},
32+
closeButton: {
33+
position: "static",
34+
color: "body.base",
35+
bg: "background.base",
36+
},
37+
body: {
38+
padding: "0",
39+
fontWeight: "normal",
40+
fontSize: "md",
41+
},
42+
footer: {
43+
gap: "2",
44+
px: "0",
45+
pt: "8",
46+
pb: "0",
5947
},
6048
})
6149
),
62-
sizes: defaultSizes,
63-
variants: {
64-
code: variantCode,
50+
sizes: {
51+
...defaultSizes,
52+
full: definePartsStyle((props) => ({
53+
dialogContainer: {
54+
alignItems: { base: "flex-start", md: "center" },
55+
},
56+
dialog: {
57+
padding: { base: "4", sm: "8", md: "16" },
58+
my: { base: "4", md: props.isCentered ? "auto" : "4" },
59+
mx: "4",
60+
minH: {
61+
base: "calc(100vh - 2rem)",
62+
md: "min(100vh, 792px)",
63+
},
64+
maxW: {
65+
base: "calc(100vw - 2rem)",
66+
md: "min(100vw, 1000px)",
67+
},
68+
},
69+
})),
6570
},
71+
6672
defaultProps: {
6773
...defaultProps,
6874
variant: undefined,

src/components/CodeModal.tsx

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
ModalContent,
77
ModalHeader,
88
ModalOverlay,
9+
useColorModeValue,
910
} from "@chakra-ui/react"
1011

1112
type CodeModalProps = {
@@ -15,20 +16,58 @@ type CodeModalProps = {
1516
setIsOpen: (isOpen: boolean) => void
1617
}
1718

18-
const CodeModal = ({ children, isOpen, setIsOpen, title }: CodeModalProps) => (
19-
<Modal
20-
isOpen={isOpen}
21-
scrollBehavior="inside"
22-
variant="code"
23-
onClose={() => setIsOpen(false)}
24-
>
25-
<ModalOverlay />
26-
<ModalContent>
27-
<ModalHeader>{title}</ModalHeader>
28-
<ModalCloseButton />
29-
<ModalBody>{children}</ModalBody>
30-
</ModalContent>
31-
</Modal>
32-
)
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+
}
3372

3473
export default CodeModal

src/components/FeedbackWidget/index.tsx

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
AlertDialogOverlay,
1010
Box,
1111
Button,
12+
HStack,
1213
} from "@chakra-ui/react"
1314

1415
import FixedDot from "./FixedDot"
@@ -50,33 +51,26 @@ const FeedbackWidget = () => {
5051
m="auto"
5152
alignItems="flex-end"
5253
backgroundColor="transparent"
53-
boxShadow="tableItemBox"
5454
me={24}
5555
bottom={{ base: `${bottomOffset + 5}rem`, lg: 20 }}
5656
data-testid="feedback-widget-modal"
57+
padding={0}
5758
>
5859
<Box
59-
w="min(300px, calc(100% - 1rem))"
60+
w="min(320px, calc(100% - 1rem))"
6061
mx="2"
61-
bgColor="ednBackground"
62-
border="1px"
63-
borderColor="background.base"
62+
bg="background.base"
6463
borderRadius="base"
65-
py="4"
66-
px="2"
64+
padding={{ base: "4", sm: "8" }}
6765
>
68-
<AlertDialogCloseButton />
69-
70-
<AlertDialogHeader
71-
fontSize="xl"
72-
fontWeight="bold"
73-
lineHeight="6"
74-
textAlign="center"
75-
>
76-
{feedbackSubmitted
77-
? t("feedback-widget-thank-you-title")
78-
: t("feedback-widget-prompt")}
79-
</AlertDialogHeader>
66+
<HStack>
67+
<AlertDialogHeader fontSize="xl" fontWeight="bold" me="0">
68+
{feedbackSubmitted
69+
? t("feedback-widget-thank-you-title")
70+
: t("feedback-widget-prompt")}
71+
</AlertDialogHeader>
72+
<AlertDialogCloseButton alignSelf="start" />
73+
</HStack>
8074

8175
{/* Body: */}
8276
{feedbackSubmitted && (

src/components/FileContributors.tsx

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import {
44
Avatar,
55
Flex,
66
FlexProps,
7-
Heading,
87
ListItem,
9-
ModalBody,
10-
ModalHeader,
118
UnorderedList,
129
VStack,
1310
} from "@chakra-ui/react"
@@ -69,22 +66,18 @@ const FileContributors = ({
6966

7067
return (
7168
<>
72-
<Modal isOpen={isModalOpen} setIsOpen={setModalOpen}>
73-
<ModalHeader py={0}>
74-
<Heading m={0}>
75-
<Translation id="contributors" />
76-
</Heading>
77-
</ModalHeader>
78-
79-
<ModalBody>
80-
<Translation id="contributors-thanks" />
81-
82-
<ContributorList>
83-
{contributors.map((contributor) => (
84-
<Contributor contributor={contributor} key={contributor.login} />
85-
))}
86-
</ContributorList>
87-
</ModalBody>
69+
<Modal
70+
isOpen={isModalOpen}
71+
onClose={() => setModalOpen(false)}
72+
size={{ base: "full", md: "xl" }}
73+
title={<Translation id="contributors" />}
74+
>
75+
<Translation id="contributors-thanks" />
76+
<ContributorList>
77+
{contributors.map((contributor) => (
78+
<Contributor contributor={contributor} key={contributor.login} />
79+
))}
80+
</ContributorList>
8881
</Modal>
8982

9083
<Flex

src/components/Modal.tsx

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Meta, StoryObj } from "@storybook/react"
2+
3+
import ModalComponent from "."
4+
5+
const meta = {
6+
title: "Molecules/Overlay Content/Modal",
7+
component: ModalComponent,
8+
} satisfies Meta<typeof ModalComponent>
9+
10+
export default meta
11+
12+
type Story = StoryObj<typeof meta>
13+
14+
export const Modal: Story = {
15+
args: {
16+
isOpen: true,
17+
title: "Modal Title",
18+
children:
19+
"This is the base component to be used in the modal window. Please change the text to preview final content for ethereum.org",
20+
actionButtonLabel: "Save",
21+
},
22+
}
23+
24+
export const Full: Story = {
25+
args: {
26+
isOpen: true,
27+
title: "Modal Title",
28+
children:
29+
"This is the base component to be used in the modal window. Please change the text to preview final content for ethereum.org",
30+
actionButtonLabel: "Save",
31+
size: "full",
32+
},
33+
}

0 commit comments

Comments
 (0)