From 1d454d2fcb53900e9ce413e64eb760d5fa3c26eb Mon Sep 17 00:00:00 2001 From: Michele Date: Sat, 31 Jan 2026 05:05:44 +0100 Subject: [PATCH] feat(01-04): create Google Sign-In button component - Add cn() utility function for class name merging - Add Button component with default/outline/ghost variants - Add Card component with Header, Title, Description, Content, Footer - Add GoogleSignInButton with signInWithOAuth for Google provider - Italian text: 'Accedi con Google' - Redirects to /auth/callback after consent Co-Authored-By: Claude Opus 4.5 --- src/components/auth/google-button.tsx | 68 ++++++++++++++++++++++++++ src/components/ui/button.tsx | 37 ++++++++++++++ src/components/ui/card.tsx | 69 +++++++++++++++++++++++++++ src/lib/utils.ts | 6 +++ 4 files changed, 180 insertions(+) create mode 100644 src/components/auth/google-button.tsx create mode 100644 src/components/ui/button.tsx create mode 100644 src/components/ui/card.tsx create mode 100644 src/lib/utils.ts diff --git a/src/components/auth/google-button.tsx b/src/components/auth/google-button.tsx new file mode 100644 index 0000000..59c2e03 --- /dev/null +++ b/src/components/auth/google-button.tsx @@ -0,0 +1,68 @@ +'use client' + +import { createClient } from '@/lib/supabase/client' +import { Button } from '@/components/ui/button' +import { useState } from 'react' + +// Simple Google icon SVG +function GoogleIcon({ className }: { className?: string }) { + return ( + + + + + + + ) +} + +export function GoogleSignInButton() { + const [loading, setLoading] = useState(false) + const supabase = createClient() + + async function handleGoogleSignIn() { + setLoading(true) + + const { error } = await supabase.auth.signInWithOAuth({ + provider: 'google', + options: { + redirectTo: `${window.location.origin}/auth/callback`, + queryParams: { + access_type: 'offline', + prompt: 'consent', + }, + }, + }) + + if (error) { + console.error('Google sign-in error:', error) + setLoading(false) + } + // Note: No need to handle success - user is redirected to Google + } + + return ( + + ) +} diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx new file mode 100644 index 0000000..6b471cb --- /dev/null +++ b/src/components/ui/button.tsx @@ -0,0 +1,37 @@ +import { forwardRef, ButtonHTMLAttributes } from 'react' +import { cn } from '@/lib/utils' + +export interface ButtonProps extends ButtonHTMLAttributes { + variant?: 'default' | 'outline' | 'ghost' + size?: 'default' | 'sm' | 'lg' +} + +const Button = forwardRef( + ({ className, variant = 'default', size = 'default', ...props }, ref) => { + return ( +