Skip to content

Commit db9fd7f

Browse files
committed
adjust modal component and theme
1 parent e2daa67 commit db9fd7f

File tree

5 files changed

+25
-42
lines changed

5 files changed

+25
-42
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,19 @@ const {
1515
export const Modal = defineMultiStyleConfig({
1616
baseStyle: definePartsStyle((props) =>
1717
defineMergeStyles(defaultBaseStyle?.(props), {
18-
overlay: {
19-
bg: "gray.500",
20-
},
2118
dialog: {
2219
bg: "background.base",
2320
gap: "4",
2421
padding: "8",
25-
maxW: "464px",
26-
borderRadius: "md",
22+
borderRadius: "base",
2723
boxShadow: "none",
2824
},
2925
header: {
30-
padding: 0,
26+
padding: "0",
3127
fontWeight: "bold",
3228
fontSize: "2xl",
29+
minHeight: "6",
30+
me: "8",
3331
},
3432
closeButton: {
3533
boxSize: "8",
@@ -38,15 +36,15 @@ export const Modal = defineMultiStyleConfig({
3836
insetInlineEnd: "8",
3937
},
4038
body: {
41-
padding: 0,
39+
padding: "0",
4240
fontWeight: "normal",
4341
fontSize: "md",
4442
},
4543
footer: {
46-
gap: "8px",
47-
px: 0,
48-
pt: 8,
49-
pb: 0,
44+
gap: "2",
45+
px: "0",
46+
pt: "8",
47+
pb: "0",
5048
},
5149
})
5250
),

src/components/Modal/index.tsx

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,32 @@ import {
55
ModalBody,
66
ModalCloseButton,
77
ModalContent,
8-
type ModalContentProps,
8+
ModalContentProps,
99
ModalFooter,
1010
ModalHeader,
1111
ModalOverlay,
1212
type ModalProps as ChakraModalProps,
1313
} from "@chakra-ui/react"
1414

15-
export type ModalProps = ModalContentProps &
16-
Pick<ChakraModalProps, "size"> & {
17-
children?: React.ReactNode
18-
title?: string
19-
actionButtonLabel?: string
20-
isOpen: boolean
21-
setIsOpen: (isOpen: boolean) => void
22-
}
15+
export type ModalProps = ChakraModalProps & {
16+
children?: React.ReactNode
17+
title?: string
18+
actionButtonLabel?: string
19+
contentProps?: ModalContentProps
20+
}
2321

2422
const Modal = ({
2523
children,
2624
title,
2725
actionButtonLabel,
28-
isOpen,
29-
setIsOpen,
26+
contentProps,
3027
...restProps
3128
}: ModalProps) => {
3229
return (
33-
<ChakraModal
34-
isOpen={isOpen}
35-
onClose={() => setIsOpen(false)}
36-
isCentered
37-
/* size={size ?? "xl"} */
38-
scrollBehavior="inside"
39-
>
40-
<ModalOverlay bgColor="blackAlpha.700" />
30+
<ChakraModal isCentered scrollBehavior="inside" {...restProps}>
31+
<ModalOverlay />
4132

42-
<ModalContent
43-
p={8}
44-
shadow="md"
45-
border="1px"
46-
borderColor="border"
47-
borderRadius="md"
48-
{...restProps}
49-
>
33+
<ModalContent {...contentProps}>
5034
<ModalHeader>{title}</ModalHeader>
5135
<ModalCloseButton />
5236
<ModalBody>{children}</ModalBody>

src/components/Quiz/QuizWidget/QuizRadioGroup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ const CustomRadio = ({
124124
})
125125

126126
const buttonBg = useMemo<string>(() => {
127-
if (!state.isChecked) return "body.inverted"
127+
if (!state.isChecked) return "background.highlight"
128128
if (!isAnswerVisible) return "primary.base"
129129
if (!isSelectedCorrect) return "error.base"
130130
return "success.base"

src/components/Quiz/QuizWidget/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const QuizWidget = ({
103103

104104
const getMainContainerBg = (): StackProps["bg"] => {
105105
if (!answerStatus) {
106-
return "neutral"
106+
return "background.base"
107107
}
108108

109109
if (answerStatus === "correct") {

src/components/Quiz/QuizzesModal.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const QuizzesModal = ({
2020
}: QuizzesModalProps) => {
2121
const getStatusColor = (): ModalContentProps["bg"] => {
2222
if (quizStatus === "neutral") {
23-
return "neutral"
23+
return "background.base"
2424
}
2525
if (quizStatus === "success") {
2626
return "success.neutral"
@@ -31,8 +31,9 @@ const QuizzesModal = ({
3131
return (
3232
<Modal
3333
isOpen={isQuizModalOpen}
34-
setIsOpen={onQuizModalClose}
34+
onClose={onQuizModalClose}
3535
size={{ base: "full", md: "xl" }}
36+
contentProps={{ bg: getStatusColor() }}
3637
{...props}
3738
>
3839
<Center m={0} bg={getStatusColor()} py="16">

0 commit comments

Comments
 (0)