# UI Primitives Documentation A comprehensive guide to the Black Canyon Tickets component library featuring production-ready UI primitives with WCAG AA accessibility compliance. ## Design System Foundation ### Design Tokens Integration All components use CSS custom properties from our design token system: ```css /* Automatically available in all components */ --color-primary-50 through --color-primary-950 --color-surface-primary, --color-surface-secondary --color-text-primary, --color-text-secondary --font-size-xs through --font-size-4xl --spacing-1 through --spacing-20 --border-radius-sm through --border-radius-2xl ``` ### Theme Support Every component automatically supports light and dark themes without additional configuration. ## Core UI Primitives ### Button Component Production-ready button with multiple variants, sizes, and states. #### Props Interface ```typescript interface ButtonProps extends React.ButtonHTMLAttributes { variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger'; size?: 'sm' | 'md' | 'lg' | 'xl'; loading?: boolean; leftIcon?: React.ReactNode; rightIcon?: React.ReactNode; fullWidth?: boolean; } ``` #### Usage Examples ```tsx import { Button } from '@/components/ui/Button'; import { PlusIcon, ArrowRightIcon } from 'lucide-react'; // Basic variants // Sizes // With icons // Loading state // Full width ``` #### Accessibility Features - **Keyboard Navigation**: Full keyboard support with Enter/Space activation - **Focus Management**: Visible focus indicators with proper contrast - **Screen Reader**: Proper button semantics and loading state announcements - **Touch Targets**: Minimum 44px touch target size on mobile --- ### Input Component Comprehensive form input with validation, labels, and help text. #### Props Interface ```typescript interface InputProps extends React.InputHTMLAttributes { label?: string; helperText?: string; error?: string; leftIcon?: React.ReactNode; rightIcon?: React.ReactNode; variant?: 'default' | 'filled'; } ``` #### Usage Examples ```tsx import { Input } from '@/components/ui/Input'; import { MailIcon, EyeIcon, EyeOffIcon } from 'lucide-react'; // Basic input with label // With helper text // With error state // With icons } placeholder="Search by name or venue" /> // Filled variant ``` #### Validation Integration ```tsx // With React Hook Form import { useForm } from 'react-hook-form'; const { register, formState: { errors } } = useForm(); ``` #### Accessibility Features - **Label Association**: Proper label-input association with unique IDs - **Error Announcement**: Screen reader announcements for validation errors - **Required Indicators**: Visual and semantic required field indicators - **Keyboard Navigation**: Full keyboard support with Tab navigation --- ### Select Component Accessible dropdown selection with search and custom styling. #### Props Interface ```typescript interface SelectOption { value: string; label: string; disabled?: boolean; } interface SelectProps { options: SelectOption[]; value?: string; defaultValue?: string; placeholder?: string; label?: string; error?: string; disabled?: boolean; required?: boolean; onChange?: (value: string) => void; } ``` #### Usage Examples ```tsx import { Select } from '@/components/ui/Select'; const ticketTypes = [ { value: 'general', label: 'General Admission' }, { value: 'vip', label: 'VIP Access' }, { value: 'student', label: 'Student Discount' } ]; // Basic select // Disabled option const venues = [ { value: 'main', label: 'Main Hall' }, { value: 'ballroom', label: 'Grand Ballroom' }, { value: 'outdoor', label: 'Outdoor Stage', disabled: true } ]; ``` #### Accessibility Features - **Keyboard Navigation**: Arrow keys, Enter, Escape, Tab support - **Screen Reader**: Proper combobox semantics with expanded/collapsed states - **Focus Management**: Visible focus indicators for options - **ARIA Labels**: Comprehensive ARIA labeling for complex interactions --- ### Card Component Flexible container component with multiple variants and compositional API. #### Props Interface ```typescript interface CardProps extends React.HTMLAttributes { variant?: 'default' | 'outlined' | 'elevated'; padding?: 'none' | 'sm' | 'md' | 'lg'; } ``` #### Usage Examples ```tsx import { Card } from '@/components/ui/Card'; // Basic card

Event Details

Join us for an unforgettable evening

// Card variants

Premium Event

Available

Exclusive access to premium seating

// Elevated card for important content ``` #### Compositional API ```tsx // Using sub-components for structured layout

Order Summary

Total $149.00
``` --- ### Alert Component Status messages and notifications with multiple severity levels. #### Props Interface ```typescript interface AlertProps { variant?: 'info' | 'success' | 'warning' | 'error'; title?: string; children: React.ReactNode; icon?: React.ReactNode; dismissible?: boolean; onDismiss?: () => void; } ``` #### Usage Examples ```tsx import { Alert } from '@/components/ui/Alert'; import { CheckCircleIcon, AlertTriangleIcon } from 'lucide-react'; // Success alert Your tickets have been purchased successfully. Check your email for confirmation. // Warning alert Only 3 tickets remaining for this event. // Error alert with custom icon } dismissible onDismiss={hideAlert} > Payment processing failed. Please try again or contact support. // Info alert without title Event details have been updated. Refresh to see changes. ``` #### Accessibility Features - **ARIA Roles**: Proper alert/alertdialog roles for screen readers - **Color Independence**: Icons and text convey meaning beyond color - **Focus Management**: Dismissible alerts receive appropriate focus - **Live Regions**: Dynamic alerts announced to screen readers --- ### Badge Component Small status indicators and labels with semantic meaning. #### Props Interface ```typescript interface BadgeProps extends React.HTMLAttributes { variant?: 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'error'; size?: 'sm' | 'md' | 'lg'; pill?: boolean; } ``` #### Usage Examples ```tsx import { Badge } from '@/components/ui/Badge'; // Status badges Available Limited Sold Out // Different sizes New Featured Premium // Pill style VIP Access // In context with event cards

Concert Night

Available
``` ## Component Composition Patterns ### Form Composition ```tsx import { Card, Input, Select, Button, Alert } from '@/components/ui'; function EventForm() { return (

Create New Event

{error && ( {error} )}
); } ``` ### Status Display Pattern ```tsx import { Badge, Alert, Button } from '@/components/ui'; function TicketStatus({ ticket }) { const getStatusBadge = (status) => { const variants = { available: 'success', limited: 'warning', sold_out: 'error' }; return ( {status.replace('_', ' ').toUpperCase()} ); }; return (

{ticket.name}

{getStatusBadge(ticket.status)}
{ticket.status === 'limited' && ( Only {ticket.remaining} tickets left )}
); } ``` ## Design Token Usage ### Color System ```tsx // Using semantic color tokens
Content with theme-aware colors
// Status colors // Uses --color-success-* tokens // Uses --color-error-* tokens ``` ### Typography Scale ```tsx // Using typography tokens

Main Heading

// --font-size-4xl

Section Heading

// --font-size-2xl

Body text

// --font-size-base Helper text // --font-size-sm ``` ### Spacing System ```tsx // Using spacing tokens
// --spacing-4, --spacing-2, --spacing-6 // --spacing-8 (internal)
// --spacing-3 ``` ## Testing Components All UI primitives include comprehensive test coverage: ```typescript // Example test for Button component test('Button renders with correct variant styles', async ({ page }) => { await page.goto('/ui-showcase'); // Test primary variant const primaryButton = page.getByTestId('button-primary'); await expect(primaryButton).toHaveClass(/bg-primary/); // Test accessibility await expect(primaryButton).toBeEnabled(); await primaryButton.focus(); await expect(primaryButton).toBeFocused(); // Test keyboard interaction await primaryButton.press('Enter'); await expect(page.getByText('Button clicked')).toBeVisible(); }); ``` ## Accessibility Compliance ### WCAG AA Standards All components meet WCAG AA requirements: - **Color Contrast**: 4.5:1 minimum ratio for normal text, 3:1 for large text - **Keyboard Navigation**: Full keyboard support for all interactive elements - **Screen Reader Support**: Proper semantic HTML and ARIA labels - **Focus Management**: Visible focus indicators with sufficient contrast ### Testing Tools ```bash # Run accessibility tests npm run test:a11y # Generate accessibility report npm run a11y:report # Visual contrast validation npm run test:contrast ``` ## Performance Considerations ### Bundle Size Optimization - **Tree Shaking**: Import only the components you need - **CSS Custom Properties**: Reduced CSS bundle size with design tokens - **Minimal Dependencies**: Core components have zero external dependencies ```tsx // Efficient imports import { Button, Input } from '@/components/ui'; // Tree-shaken // Avoid importing entire library import * as UI from '@/components/ui'; // Not recommended ``` ### Runtime Performance - **Memoization**: Components use React.memo where appropriate - **Event Handling**: Optimized event listeners with proper cleanup - **Re-render Optimization**: Props designed to minimize unnecessary re-renders --- **Component library built with CrispyGoat quality standards - accessible, performant, and developer-friendly.**