|
| 1 | +# @leanspec/ui-components |
| 2 | + |
| 3 | +Framework-agnostic, tree-shakeable UI components for LeanSpec. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +npm install @leanspec/ui-components |
| 9 | +# or |
| 10 | +pnpm add @leanspec/ui-components |
| 11 | +``` |
| 12 | + |
| 13 | +## Usage |
| 14 | + |
| 15 | +```tsx |
| 16 | +import { StatusBadge, PriorityBadge, SpecCard, EmptyState, SearchInput } from '@leanspec/ui-components'; |
| 17 | +import '@leanspec/ui-components/styles.css'; |
| 18 | + |
| 19 | +function MyComponent() { |
| 20 | + return ( |
| 21 | + <div> |
| 22 | + <SearchInput placeholder="Search specs..." onSearch={(q) => console.log(q)} /> |
| 23 | + <StatusBadge status="in-progress" /> |
| 24 | + <PriorityBadge priority="high" /> |
| 25 | + <SpecCard |
| 26 | + spec={{ |
| 27 | + specNumber: 185, |
| 28 | + specName: 'ui-components', |
| 29 | + title: 'UI Components', |
| 30 | + status: 'in-progress', |
| 31 | + priority: 'high', |
| 32 | + tags: ['ui', 'components'], |
| 33 | + updatedAt: new Date().toISOString(), |
| 34 | + }} |
| 35 | + /> |
| 36 | + </div> |
| 37 | + ); |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +## Components |
| 42 | + |
| 43 | +### Spec Components |
| 44 | + |
| 45 | +- `StatusBadge` - Display spec status with icon |
| 46 | +- `PriorityBadge` - Display spec priority with icon |
| 47 | +- `SpecCard` - Compact spec card for lists |
| 48 | +- `SpecMetadata` - Metadata display card with all spec details |
| 49 | +- `TagBadge` - Display a single tag |
| 50 | +- `TagList` - Display multiple tags with truncation |
| 51 | + |
| 52 | +### Project Components |
| 53 | + |
| 54 | +- `ProjectAvatar` - Avatar with initials and color from project name |
| 55 | +- `ProjectCard` - Project card with avatar, description, stats, and tags |
| 56 | + |
| 57 | +### Stats Components |
| 58 | + |
| 59 | +- `StatsCard` - Single stat card with icon and trend indicator |
| 60 | +- `StatsOverview` - Grid of stats cards for project overview |
| 61 | +- `ProgressBar` - Horizontal progress bar with variants |
| 62 | + |
| 63 | +### Search & Filter Components |
| 64 | + |
| 65 | +- `SearchInput` - Search input with keyboard shortcut hint |
| 66 | +- `FilterSelect` - Dropdown filter component |
| 67 | + |
| 68 | +### Navigation Components |
| 69 | + |
| 70 | +- `ThemeToggle` - Light/dark theme toggle button |
| 71 | +- `BackToTop` - Floating scroll-to-top button |
| 72 | + |
| 73 | +### UI Components |
| 74 | + |
| 75 | +- `Avatar` - Avatar with image and fallback |
| 76 | +- `Badge` - Base badge component with variants |
| 77 | +- `Button` - Button with variants (default, destructive, outline, secondary, ghost, link) |
| 78 | +- `Card` - Card container with header, content, footer |
| 79 | +- `Input` - Form input field |
| 80 | +- `Separator` - Horizontal or vertical divider |
| 81 | +- `Skeleton` - Loading placeholder |
| 82 | + |
| 83 | +### Layout Components |
| 84 | + |
| 85 | +- `EmptyState` - Empty state placeholder with icon, title, description, action |
| 86 | +- `SpecListSkeleton` - Loading skeleton for spec list |
| 87 | +- `SpecDetailSkeleton` - Loading skeleton for spec detail |
| 88 | +- `StatsCardSkeleton` - Loading skeleton for stats card |
| 89 | +- `KanbanBoardSkeleton` - Loading skeleton for kanban board |
| 90 | +- `ProjectCardSkeleton` - Loading skeleton for project card |
| 91 | +- `SidebarSkeleton` - Loading skeleton for sidebar |
| 92 | +- `ContentSkeleton` - Generic content skeleton |
| 93 | + |
| 94 | +## Hooks |
| 95 | + |
| 96 | +- `useLocalStorage` - Persist state in localStorage |
| 97 | +- `useDebounce` - Debounce a value |
| 98 | +- `useDebouncedCallback` - Debounce a callback function |
| 99 | +- `useTheme` - Theme state management with localStorage persistence |
| 100 | + |
| 101 | +## Utilities |
| 102 | + |
| 103 | +- `cn` - Merge Tailwind CSS classes |
| 104 | +- `formatDate` - Format date in readable format |
| 105 | +- `formatDateTime` - Format date with time |
| 106 | +- `formatRelativeTime` - Format relative time (e.g., "2 days ago") |
| 107 | +- `formatDuration` - Format duration between dates |
| 108 | +- `getColorFromString` - Generate consistent color from string |
| 109 | +- `getContrastColor` - Get contrasting text color for background |
| 110 | +- `getInitials` - Get initials from name string |
| 111 | +- `PROJECT_COLORS` - Predefined color palette |
| 112 | + |
| 113 | +## Types |
| 114 | + |
| 115 | +All spec-related TypeScript types are exported: |
| 116 | + |
| 117 | +- `Spec`, `LightweightSpec`, `SidebarSpec` |
| 118 | +- `SpecStatus`, `SpecPriority` |
| 119 | +- `StatsResult`, `DependencyGraph`, etc. |
| 120 | + |
| 121 | +## Development |
| 122 | + |
| 123 | +```bash |
| 124 | +# Install dependencies |
| 125 | +pnpm install |
| 126 | + |
| 127 | +# Build the library |
| 128 | +pnpm build |
| 129 | + |
| 130 | +# Run Storybook |
| 131 | +pnpm storybook |
| 132 | + |
| 133 | +# Run tests |
| 134 | +pnpm test |
| 135 | +``` |
| 136 | + |
| 137 | +## License |
| 138 | + |
| 139 | +MIT |
0 commit comments