# Atomic Component Library - Quick Start
## ๐ Documentation Overview
This project now uses an **Atomic Design** component architecture. Here's how to navigate the documentation:
### Essential Reading (Start Here!)
1. **[ATOMIC_REFACTOR_SUMMARY.md](./ATOMIC_REFACTOR_SUMMARY.md)** - Overview of changes
- What changed and why
- Component inventory
- Benefits and usage patterns
- Next steps
2. **[ATOMIC_COMPONENTS.md](./ATOMIC_COMPONENTS.md)** - Complete guide
- Atomic design methodology explained
- Component hierarchy rules
- When to create each type
- Best practices and patterns
- Migration guide
3. **[ATOMIC_USAGE_EXAMPLES.md](./ATOMIC_USAGE_EXAMPLES.md)** - Practical examples
- 10+ real-world usage examples
- Code templates
- Testing patterns
- Quick start guide
4. **[COMPONENT_MAP.md](./COMPONENT_MAP.md)** - Visual reference
- Component composition diagrams
- Dependency maps
- Data flow examples
- Performance tips
## ๐ฏ Quick Reference
### Component Levels
| Level | Purpose | Example | Import From |
|-------|---------|---------|-------------|
| **Atom** | Single UI element | `AppLogo`, `StatusIcon` | `@/components/atoms` |
| **Molecule** | 2-5 atoms combined | `SaveIndicator`, `ToolbarButton` | `@/components/molecules` |
| **Organism** | Complex composition | `AppHeader`, `NavigationMenu` | `@/components/organisms` |
| **Feature** | Domain-specific | `CodeEditor`, `ModelDesigner` | `@/components/[Name]` |
### Directory Structure
```
src/components/
โโโ atoms/ # 7 building blocks
โโโ molecules/ # 10 simple combinations
โโโ organisms/ # 4 complex components
โโโ ui/ # shadcn base components
โโโ [features]/ # Feature components
```
## ๐ Usage Examples
### Using Atoms
```tsx
import { AppLogo, StatusIcon, ErrorBadge } from '@/components/atoms'
```
### Using Molecules
```tsx
import { SaveIndicator, ToolbarButton, EmptyState } from '@/components/molecules'
} label="Add" onClick={handleAdd} />
} title="No files" description="Get started" />
```
### Using Organisms
```tsx
import { AppHeader, PageHeader, NavigationMenu } from '@/components/organisms'
```
## ๐ Component Inventory
### Atoms (7)
- `AppLogo` - Application logo
- `TabIcon` - Icon with variants
- `StatusIcon` - Save/sync status
- `ErrorBadge` - Error counter
- `IconWrapper` - Icon container
- `LoadingSpinner` - Loading animation
- `EmptyStateIcon` - Empty state icon
### Molecules (10)
- `SaveIndicator` - Save status display
- `AppBranding` - Logo + title
- `PageHeaderContent` - Page title section
- `ToolbarButton` - Button with tooltip
- `NavigationItem` - Nav link
- `NavigationGroupHeader` - Group header
- `EmptyState` - Empty state view
- `LoadingState` - Loading view
- `StatCard` - Statistics card
- `LabelWithBadge` - Label + badge
### Organisms (4)
- `NavigationMenu` - Sidebar navigation
- `PageHeader` - Page header
- `ToolbarActions` - Action toolbar
- `AppHeader` - Application header
## ๐ ๏ธ Creating New Components
### 1. Determine Component Level
Ask yourself:
- Can it be broken down? โ Not an atom
- Does it combine atoms? โ At least a molecule
- Does it have complex state? โ Probably an organism
- Is it feature-specific? โ Feature component
### 2. Create the Component
```tsx
// src/components/atoms/MyAtom.tsx
interface MyAtomProps {
value: string
variant?: 'default' | 'primary'
}
export function MyAtom({ value, variant = 'default' }: MyAtomProps) {
return {value}
}
```
### 3. Update Index File
```tsx
// src/components/atoms/index.ts
export { MyAtom } from './MyAtom'
```
### 4. Use in Your Code
```tsx
import { MyAtom } from '@/components/atoms'
```
## โ
Best Practices
### DO:
- โ
Use atoms for single-purpose elements
- โ
Compose molecules from atoms
- โ
Build organisms from molecules/atoms
- โ
Keep feature logic in feature components
- โ
Export from index files
- โ
Use TypeScript types
- โ
Follow naming conventions
### DON'T:
- โ Import organisms in atoms
- โ Import molecules in atoms
- โ Duplicate atom functionality
- โ Mix business logic in atoms/molecules
- โ Skip TypeScript types
- โ Create "god components"
## ๐ Import Hierarchy
```
Feature Components
โ can import
Organisms
โ can import
Molecules
โ can import
Atoms
โ can import
shadcn UI
```
## ๐ง Common Patterns
### Pattern 1: Status Display
```tsx
const isRecent = Date.now() - lastSaved < 3000
```
### Pattern 2: Empty State
```tsx
}
title="No files yet"
description="Create your first file"
action={Create File }
/>
```
### Pattern 3: Loading State
```tsx
{isLoading ? (
) : (
)}
```
### Pattern 4: Stat Cards
```tsx
} label="Files" value={fileCount} />
} label="Models" value={modelCount} />
} label="Components" value={compCount} />
```
## ๐งช Testing
### Atoms (Unit Tests)
```tsx
describe('StatusIcon', () => {
it('shows CheckCircle when saved', () => {
render( )
expect(screen.getByTestId('check-circle')).toBeInTheDocument()
})
})
```
### Molecules (Integration Tests)
```tsx
describe('SaveIndicator', () => {
it('shows saved text when recent', () => {
render( )
expect(screen.getByText('Saved')).toBeInTheDocument()
})
})
```
### Organisms (E2E Tests)
```tsx
describe('NavigationMenu', () => {
it('navigates when item clicked', () => {
render( )
userEvent.click(screen.getByText('Code Editor'))
expect(onTabChange).toHaveBeenCalledWith('code')
})
})
```
## ๐จ Styling
All components use:
- **Tailwind** for utility classes
- **CSS variables** for theming
- **Responsive** design patterns
- **Accessible** markup
Example:
```tsx
{/* Responsive spacing and text sizing */}
```
## ๐ TypeScript
All components are fully typed:
```tsx
interface ComponentProps {
required: string
optional?: number
callback?: () => void
variant?: 'default' | 'primary'
}
export function Component({ required, optional = 0 }: ComponentProps) {
// Implementation
}
```
## ๐ฆ Next Steps
1. **Read the docs** - Start with ATOMIC_REFACTOR_SUMMARY.md
2. **Review examples** - Check ATOMIC_USAGE_EXAMPLES.md
3. **Study the maps** - See COMPONENT_MAP.md for visual guides
4. **Try it out** - Create a new molecule or atom
5. **Refactor** - Identify components to atomize
## ๐ก Tips
- Start with molecules for most use cases
- Extract atoms when you see duplication
- Build organisms for major UI sections
- Keep feature components for domain logic
- Use index files for clean imports
- Follow the existing patterns
## ๐ค Contributing
When adding new atomic components:
1. Choose the appropriate level
2. Create the component file
3. Add TypeScript types
4. Update the index.ts
5. Add to COMPONENT_MAP.md
6. Create usage examples
7. Write tests
## ๐ Need Help?
1. Check the documentation files
2. Look at existing component examples
3. Review the component map
4. Follow established patterns
5. Ask questions in code reviews
## ๐ Resources
- **Atomic Design**: https://atomicdesign.bradfrost.com/
- **Component-Driven**: https://www.componentdriven.org/
- **React Patterns**: https://reactpatterns.com/
---
**Remember**: The atomic structure makes components more reusable, testable, and maintainable. When in doubt, start small (atom/molecule) and grow as needed!