Complete stabilization pass bringing all 3 stacks to green: Frontend (apps/web/): - Fix TypeScript nullability in useSeason.ts, useTimeOfDay.ts hooks - Disable no-undef in ESLint config (TypeScript handles it; JSX misidentified) - Rename 306 story imports from @storybook/react to @storybook/react-vite - Fix conditional hook call in useMediaQuery.ts useIsTablet - Move useQuery to top of LoginPage.tsx component - Remove useless try/catch in GearFormModal.tsx - Fix stale closure in ResetPasswordPage.tsx handleChange - Make Storybook decorators (withRouter, withQueryClient, withToast, withAudio) no-ops since global StorybookDecorator already provides these — prevents nested Router / duplicate provider crashes in vitest-browser - Fix nested MemoryRouter in 3 page stories (TrackDetail, PlaylistDetail, UserProfile) - Update i18n initialization in test setup (await init before changeLanguage) - Update ~30 test assertions from English to French to match i18n translations - Update test assertions to match SUMI V3 design changes (shadow vs border) - Fix remaining story type errors (PlayerError, PlaylistBatchActions, TrackFilters, VirtualizedChatMessages) Backend (veza-backend-api/): - Fix response_test.go RespondWithAppError signature (2 args, not 3) - Fix TestErrorContractAuthEndpoints expected error codes (ErrCodeUnauthorized vs ErrCodeInvalidCredentials) - Fix TestTrackHandler_GetTrackLikes_Success missing auth middleware setup - Fix TestPlaybackAnalyticsService_GetTrackStats k-anonymity threshold (needs 5 unique users, not 1) - Replace NOW() PostgreSQL function with time.Now() parameter in marketplace service for SQLite test compatibility - Add missing AutoMigrate entries in marketplace_test.go (ProductImage, ProductPreview, ProductLicense, ProductReview) Results: - Frontend TypeCheck: 617 errors -> 0 errors - Frontend ESLint: 349 errors -> 0 errors - Frontend Vitest: 196 failing tests -> 1 skipped (3396/3397 passing) - Backend go vet: 1 error -> 0 errors - Backend tests: 5 failing -> all 13 packages passing - Rust: 150/150 tests passing (unchanged) - Storybook audit: 0 errors across 1244 stories Triage report: docs/TRIAGE_REPORT.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
141 lines
5 KiB
TypeScript
141 lines
5 KiB
TypeScript
import * as React from 'react';
|
|
import { Slot } from '@radix-ui/react-slot';
|
|
import { type VariantProps, cva } from 'class-variance-authority';
|
|
import { Loader2 } from 'lucide-react';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
/**
|
|
* Button variant styles using class-variance-authority
|
|
* SUMI Design System: semantic tokens, rounded-full, duration-normal
|
|
*/
|
|
const buttonVariants = cva(
|
|
'inline-flex items-center justify-center whitespace-nowrap rounded-full text-sm font-sans font-medium tracking-tight transition-[color,box-shadow,border-color,background-color] duration-[var(--sumi-duration-normal)] ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:shadow-[var(--sumi-shadow-glow)] disabled:pointer-events-none disabled:opacity-50 gap-2',
|
|
{
|
|
variants: {
|
|
variant: {
|
|
/** Primary action button - main CTAs, submit */
|
|
default:
|
|
'bg-primary text-primary-foreground hover:bg-primary/90 border border-transparent font-semibold',
|
|
/** Primary alias for Design System compatibility */
|
|
primary:
|
|
'bg-primary text-primary-foreground hover:bg-primary/90 border border-transparent font-semibold',
|
|
/** Destructive actions - delete, remove, clear */
|
|
destructive:
|
|
'bg-destructive/10 text-destructive hover:bg-destructive/20 border border-destructive/30 hover:border-destructive/50',
|
|
/** Outlined - secondary actions, cancel */
|
|
outline:
|
|
'bg-transparent text-foreground hover:bg-muted/50 shadow-[0_0_0_1px_var(--border)]',
|
|
/** Secondary - less prominent actions */
|
|
secondary:
|
|
'bg-muted/30 text-foreground hover:bg-muted/50',
|
|
/** Ghost - icon buttons, menu items */
|
|
ghost: 'text-muted-foreground hover:text-foreground hover:bg-muted/50',
|
|
/** Link - styled as inline link */
|
|
link: 'text-primary underline-offset-4 hover:underline',
|
|
/** Glass - frosted glass effect for overlays, player bar, floating actions */
|
|
glass:
|
|
'bg-[var(--sumi-glass-bg)] text-foreground backdrop-blur-[var(--sumi-glass-blur)] shadow-[0_0_0_1px_var(--sumi-glass-border)] hover:bg-white/15 font-medium',
|
|
},
|
|
size: {
|
|
/** Default size - standard buttons */
|
|
default: 'h-10 px-4 py-2',
|
|
/** Small size - compact buttons, inline actions */
|
|
sm: 'h-9 rounded-full px-4 text-xs',
|
|
/** Large size - prominent CTAs */
|
|
lg: 'h-12 rounded-full px-8 text-base',
|
|
/** Icon size - icon-only buttons (square, full radius) */
|
|
icon: 'h-10 w-10 rounded-full',
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: 'default',
|
|
size: 'default',
|
|
},
|
|
},
|
|
);
|
|
|
|
/**
|
|
* Button component props
|
|
*
|
|
* Extends standard HTML button attributes with design system variants and sizes.
|
|
*
|
|
* @example
|
|
* ```tsx
|
|
* <Button variant="default" size="lg" onClick={handleSave}>
|
|
* Save Changes
|
|
* </Button>
|
|
* ```
|
|
*
|
|
* @example
|
|
* ```tsx
|
|
* <Button variant="ghost" size="icon" onClick={handleEdit}>
|
|
* <Edit className="w-4 h-4" />
|
|
* </Button>
|
|
* ```
|
|
*/
|
|
export interface ButtonProps
|
|
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
VariantProps<typeof buttonVariants> {
|
|
/** Use asChild to compose with other components (e.g., Link from react-router) */
|
|
asChild?: boolean;
|
|
/** Optional icon to display before the label */
|
|
icon?: React.ReactNode;
|
|
/** Show a loading spinner and disable the button */
|
|
loading?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Button - Design system button component
|
|
*
|
|
* A versatile button component with multiple variants and sizes following the SUMI design system.
|
|
*
|
|
* @example
|
|
* ```tsx
|
|
* // Primary action
|
|
* <Button variant="default" onClick={handleSave}>Save</Button>
|
|
*
|
|
* // Destructive action
|
|
* <Button variant="destructive" onClick={handleDelete}>Delete</Button>
|
|
*
|
|
* // Secondary action
|
|
* <Button variant="outline" onClick={handleCancel}>Cancel</Button>
|
|
*
|
|
* // Icon button
|
|
* <Button variant="ghost" size="icon">
|
|
* <Edit className="w-4 h-4" />
|
|
* </Button>
|
|
* ```
|
|
*/
|
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
({ className, variant, size, asChild = false, icon, loading = false, children, disabled, ...props }, ref) => {
|
|
const Comp = asChild ? Slot : 'button';
|
|
const isDisabled = disabled || loading;
|
|
return (
|
|
<Comp
|
|
className={cn(buttonVariants({ variant, size, className }), loading && 'opacity-70')}
|
|
ref={ref}
|
|
disabled={isDisabled}
|
|
{...props}
|
|
>
|
|
{asChild ? (
|
|
children
|
|
) : (
|
|
<>
|
|
{loading && (
|
|
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
)}
|
|
{!loading && icon && (
|
|
<span className="flex items-center justify-center pointer-events-none" aria-hidden="true">
|
|
{icon}
|
|
</span>
|
|
)}
|
|
{children}
|
|
</>
|
|
)}
|
|
</Comp>
|
|
);
|
|
},
|
|
);
|
|
Button.displayName = 'Button';
|
|
|
|
export { Button, buttonVariants };
|