Skip to content

Commit 01f36c4

Browse files
Merge pull request #65 from Ditectrev/feature/explanationsUI
feat: improve explanations UI
2 parents e8c1d7a + ec80742 commit 01f36c4

File tree

4 files changed

+581
-12
lines changed

4 files changed

+581
-12
lines changed

components/Button.tsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import React from "react";
44
const button = cva("button", {
55
variants: {
66
intent: {
7-
primary: ["bg-blue-600/50", "border-blue-600", "hover:bg-blue-600/60", "focus:ring-blue-800", "border-blue-600"],
7+
primary: [
8+
"bg-blue-600/50",
9+
"border-blue-600",
10+
"hover:bg-blue-600/60",
11+
"focus:ring-blue-800",
12+
"border-blue-600",
13+
],
814
secondary: [
915
"bg-emerald-600/50",
1016
"border-emerald-600",
@@ -19,22 +25,38 @@ const button = cva("button", {
1925
medium: ["font-medium", "py-2.5", "px-5", "sm:text-sm", "text-xs"],
2026
small: ["font-small", "py-2", "px-2"],
2127
},
28+
variant: {
29+
filled: [],
30+
outlined: ["bg-transparent", "hover:bg-opacity-10"],
31+
},
2232
compoundVariants: {
2333
intent: ["primary", "secondary"],
2434
size: "medium",
2535
},
2636
defaultVariants: {
2737
intent: "primary",
2838
size: "medium",
39+
variant: "filled",
2940
},
3041
},
3142
});
3243

33-
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof button> {}
44+
export interface ButtonProps
45+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
46+
VariantProps<typeof button> {}
3447

35-
export const Button: React.FC<ButtonProps> = ({ intent, size, ...props }) => (
48+
export const Button: React.FC<ButtonProps> = ({
49+
intent,
50+
size,
51+
variant,
52+
...props
53+
}) => (
3654
<button
37-
className={`${button({ intent, size })} text-white rounded-lg focus:outline-none focus:ring-1 border mb-2 sm:mb-0`}
55+
className={`${button({
56+
intent,
57+
size,
58+
variant,
59+
})} text-white rounded-lg focus:outline-none focus:ring-1 border mb-2 sm:mb-0`}
3860
{...props}
3961
/>
4062
);

components/QuizForm.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import SelectionInput from "./SelectionInput";
66
import { Button } from "./Button";
77
import NumberInputComponent from "./NumberInputComponent";
88
import LoadingIndicator from "./LoadingIndicator";
9+
import { SiHelpdesk } from "react-icons/si";
910

1011
const QuizForm: FC<Props> = ({
1112
isLoading,
@@ -284,7 +285,19 @@ const QuizForm: FC<Props> = ({
284285
))}
285286
</ul>
286287
{explanation && (
287-
<p className="text-white md:px-12 mb-16 select-none">{explanation}</p>
288+
<div className="md:px-12 mb-16">
289+
<div className="bg-slate-800 border border-slate-600 rounded-lg p-6 shadow-lg">
290+
<div className="flex items-center gap-3 mb-4">
291+
<div className="rounded-full flex items-center justify-center">
292+
<SiHelpdesk className="w-5 h-5 text-white" />
293+
</div>
294+
<h3 className="text-lg font-semibold text-white">Explanation</h3>
295+
</div>
296+
<div className="text-slate-200 leading-relaxed whitespace-pre-line">
297+
{explanation}
298+
</div>
299+
</div>
300+
</div>
288301
)}
289302
<div className="flex justify-center flex-col sm:flex-row">
290303
<Button
@@ -300,6 +313,7 @@ const QuizForm: FC<Props> = ({
300313
type="button"
301314
intent="secondary"
302315
size="medium"
316+
variant="outlined"
303317
disabled={isThinking}
304318
onClick={() => {
305319
setShowCorrectAnswer(true);

0 commit comments

Comments
 (0)