Skip to content

Commit cd54762

Browse files
committed
fix quiz title text color
1 parent fdca95f commit cd54762

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/components/Quiz/QuizWidget/QuizContent.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useCallback } from "react"
2-
import { Text, VStack } from "@chakra-ui/react"
2+
import { Text, type TextProps, VStack } from "@chakra-ui/react"
33

44
import { ChildOnlyProp } from "@/lib/types"
55

@@ -12,13 +12,20 @@ export const QuizContent = ({ children }: QuizContentProps) => {
1212

1313
const getTitleContent = useCallback((): string => {
1414
if (!answerStatus) return title
15-
16-
return answerStatus === 'correct' ? "Correct!" : "Incorrect"
15+
16+
return answerStatus === "correct" ? "Correct!" : "Incorrect"
1717
}, [answerStatus, title])
18-
18+
19+
const getTitleTextColor = (): TextProps["color"] => {
20+
if (!answerStatus) return "primary.hover"
21+
return answerStatus === "correct" ? "success.base" : "fail.base"
22+
}
23+
1924
return (
2025
<VStack spacing="4">
21-
<Text>{getTitleContent()}</Text>
26+
<Text fontWeight="bold" textAlign="center" color={getTitleTextColor()}>
27+
{getTitleContent()}
28+
</Text>
2229
{children}
2330
</VStack>
2431
)

0 commit comments

Comments
 (0)