Skip to content

Commit

Permalink
Moved start quiz button to startQuiz window to improve usability.
Browse files Browse the repository at this point in the history
  • Loading branch information
malikpiara committed May 6, 2024
1 parent 92442dd commit c912b8d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
11 changes: 9 additions & 2 deletions components/quiz/startScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Button from '../button';
import { Button } from '../ui/button';

interface StartScreenProps {
onStartQuiz: () => void;
Expand All @@ -15,7 +15,14 @@ export function StartScreen({ onStartQuiz }: StartScreenProps) {
Test your knowledge on this chapter and see how much you already know!
</p>
<div className='font-semibold text-orange-300'>10 questions</div>
<Button label='Start Quiz' onClick={onStartQuiz} />
<Button
size={'lg'}
className='w-fit transition-all self-center mt-5 font-stretch'
onClick={onStartQuiz}
>
Start Quiz
</Button>

{
// Temporary filler to make the text content be displayed a couple of pixels above.
<div className='h-40' />
Expand Down
56 changes: 56 additions & 0 deletions components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as React from 'react';
import { Slot } from '@radix-ui/react-slot';
import { cva, type VariantProps } from 'class-variance-authority';

import { cn } from '@/lib/utils';

const buttonVariants = cva(
'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
{
variants: {
variant: {
default: 'bg-white text-black hover:bg-white/90',
destructive:
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
outline:
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
secondary:
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline',
},
size: {
default: 'h-10 px-4 py-2',
sm: 'h-9 rounded-md px-3',
lg: 'h-11 rounded-md px-8',
icon: 'h-10 w-10',
},
},
defaultVariants: {
variant: 'default',
size: 'default',
},
}
);

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean;
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : 'button';
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
);
}
);
Button.displayName = 'Button';

export { Button, buttonVariants };
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-slot": "^1.0.2",
"@supabase/ssr": "^0.3.0",
"@supabase/supabase-js": "^2.43.1",
"class-variance-authority": "^0.7.0",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit c912b8d

@vercel
Copy link

@vercel vercel bot commented on c912b8d May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.