Overview
The Crocante platform uses a well-structured component architecture built on Next.js, React, and TypeScript. Components are organized into three main categories:- Core Components: Foundational UI elements (buttons, inputs, modals, tables)
- Custom Components: Business-specific components (token selectors, dynamic avatars)
- Layout Components: Application structure components (shell, header, navigation)
Architecture Principles
Component Organization
Components are organized in a hierarchical structure:Type Safety
All components are built with TypeScript and use proper interface definitions:Design System
The platform uses a consistent design system with:- Tailwind CSS: Utility-first styling
- Custom Theme: Defined color palette and spacing
- Variant System: Consistent component variations
- Responsive Design: Mobile-first approach using
useIsMobilehook
Core Design Patterns
Variant-Based Styling
Components use variant props for consistent styling:Forwarding Refs
Components that need ref access useforwardRef:
Composition Over Configuration
Components favor composition patterns:Responsive Design
Mobile Detection
The platform uses theuseIsMobile hook for responsive behavior:
Adaptive Layouts
Components automatically adapt based on screen size:- Modal: Bottom sheet on mobile, centered dialog on desktop
- Table: Horizontal scrolling with navigation arrows on mobile
- Navigation: Collapsible sidebar on mobile
Accessibility
Components follow accessibility best practices:- ARIA Attributes: Proper
aria-label,aria-disabled,aria-busy - Keyboard Navigation: Full keyboard support
- Focus Management: Visible focus states
- Screen Reader Support: Semantic HTML and ARIA roles
Portal Rendering
Modals and overlays use React portals for proper z-index management:State Management
Components use local state with hooks for UI interactions:- useState: Local component state
- useCallback: Memoized callbacks
- useEffect: Side effects and lifecycle
- useRef: DOM references and mutable values
Performance Optimization
Lazy Loading
Heavy components are loaded on demand:Memoization
Callbacks are memoized to prevent unnecessary re-renders:Next Steps
UI Components
Explore core UI components
Custom Hooks
Learn about custom React hooks
Context Providers
Understand context providers
