Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions web/components/ui/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import React from 'react';
import { THEMES } from '../../constants';
import { useTheme } from '../../contexts/ThemeContext';
import { Spinner } from './Spinner';

interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: 'primary' | 'secondary' | 'danger' | 'ghost';
size?: 'sm' | 'md' | 'lg';
isLoading?: boolean;
}

export const Button: React.FC<ButtonProps> = ({
children,
variant = 'primary',
size = 'md',
className = '',
isLoading = false,
...props
}) => {
const { style } = useTheme();
Expand Down Expand Up @@ -47,8 +50,10 @@ export const Button: React.FC<ButtonProps> = ({
return (
<button
className={`${baseStyles} ${sizeStyles[size]} ${themeStyles} ${className}`}
disabled={isLoading || props.disabled}
{...props}
>
{isLoading && <Spinner className="mr-1" />}
{children}
</button>
);
Expand Down
19 changes: 19 additions & 0 deletions web/components/ui/Spinner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { Loader2 } from 'lucide-react';

interface SpinnerProps {
className?: string;
size?: number;
ariaLabel?: string;
}

export const Spinner: React.FC<SpinnerProps> = ({ className = '', size = 18, ariaLabel = "Loading" }) => {
return (
<Loader2
className={`animate-spin ${className}`}
size={size}
aria-label={ariaLabel}
role="status"
/>
);
};
11 changes: 4 additions & 7 deletions web/pages/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ArrowRight, CreditCard, Sparkles } from 'lucide-react';
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { Button } from '../components/ui/Button';
import { Spinner } from '../components/ui/Spinner';
import { Input } from '../components/ui/Input';
import { THEMES } from '../constants';
import { useAuth } from '../contexts/AuthContext';
Expand Down Expand Up @@ -170,11 +171,7 @@ export const Auth = () => {
}`}
>
{googleLoading ? (
<div
className="w-5 h-5 border-2 border-black/20 border-t-black rounded-full animate-spin"
role="status"
aria-label="Signing in with Google"
/>
<Spinner size={20} ariaLabel="Signing in with Google" />
) : (
<svg className="w-5 h-5" viewBox="0 0 24 24" role="img" aria-labelledby="google-logo-title">
<title id="google-logo-title">Google logo</title>
Expand Down Expand Up @@ -251,8 +248,8 @@ export const Auth = () => {
</motion.div>
)}

<Button type="submit" disabled={loading} className={`w-full py-4 text-lg ${isNeo ? 'rounded-none' : ''}`}>
{loading ? 'Processing...' : isLogin ? 'Log In' : 'Create Account'} <ArrowRight size={20} />
<Button type="submit" isLoading={loading} className={`w-full py-4 text-lg ${isNeo ? 'rounded-none' : ''}`}>
{isLogin ? 'Log In' : 'Create Account'} {!loading && <ArrowRight size={20} />}
</Button>
</form>

Expand Down
Loading