Skip to content

Commit f1f4d50

Browse files
committed
fix quiz answer choice bg colors
1 parent cd54762 commit f1f4d50

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/components/Quiz/QuizWidget/QuizRadioGroup.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,18 @@ const CustomRadio = ({
118118
...radioProps
119119
}: CustomRadioProps) => {
120120
const INPUT_ID = `quiz-question-answer-${index}`
121-
const { getInputProps, getRadioProps, getLabelProps } = useRadio({
121+
const { state, getInputProps, getRadioProps, getLabelProps } = useRadio({
122122
...radioProps,
123123
id: INPUT_ID,
124124
})
125125

126+
const buttonBg = useMemo<string>(() => {
127+
if (!state.isChecked) return "body.inverted"
128+
if (!isAnswerVisible) return "primary.base"
129+
if (!isSelectedCorrect) return "error.base"
130+
return "success.base"
131+
}, [state.isChecked, isAnswerVisible, isSelectedCorrect])
132+
126133
const primaryBaseColor = useToken("colors", "primary.base")
127134

128135
const getAnswerColor = (): ChakraProps["bg"] =>
@@ -149,6 +156,7 @@ const CustomRadio = ({
149156
w="full"
150157
p="2"
151158
color="text"
159+
bg={buttonBg}
152160
borderRadius="base"
153161
_hover={{
154162
outline: isAnswerVisible ? "none" : `1px solid ${primaryBaseColor}`,

0 commit comments

Comments
 (0)