|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Faency is a React component library and design system for Traefik Labs, built with React, TypeScript, Stitches CSS-in-JS, and Radix UI Primitives. It provides accessible, themed components with light/dark mode support. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Core Development |
| 12 | + |
| 13 | +- `yarn install` - Install dependencies |
| 14 | +- `yarn patch-package` - Apply necessary patches to Stitches after installation |
| 15 | +- `yarn storybook` - Start Storybook development server at http://localhost:6006 |
| 16 | +- `yarn build` - Build the library for production |
| 17 | +- `yarn lint` - Lint TypeScript/React files in components directory |
| 18 | +- `yarn lint:fix` - Auto-fix linting issues |
| 19 | +- `yarn test` - Run Jest tests in watch mode |
| 20 | +- `yarn test:ci` - Run tests in CI mode (silent, non-watch) |
| 21 | + |
| 22 | +### Release |
| 23 | + |
| 24 | +- `yarn release` - Build and publish using semantic-release |
| 25 | + |
| 26 | +## Architecture |
| 27 | + |
| 28 | +### Styling System |
| 29 | + |
| 30 | +- **Stitches CSS-in-JS**: Core styling system with design tokens and utilities |
| 31 | +- **Design Tokens**: Defined in `stitches.config.ts` with semantic color system |
| 32 | +- **Theme Support**: Light/dark themes with customizable primary colors |
| 33 | +- **Component Themes**: Each component has its own theme file (e.g., `Button.themes.ts`) |
| 34 | + |
| 35 | +### Component Structure |
| 36 | + |
| 37 | +Components follow a consistent pattern: |
| 38 | + |
| 39 | +- `ComponentName.tsx` - Main component implementation |
| 40 | +- `ComponentName.stories.tsx` - Storybook stories |
| 41 | +- `ComponentName.test.tsx` - Jest tests (where applicable) |
| 42 | +- `ComponentName.themes.ts` - Theme definitions for light/dark modes |
| 43 | +- `index.ts` - Exports |
| 44 | + |
| 45 | +### Key Files |
| 46 | + |
| 47 | +- `stitches.config.ts` - Stitches configuration with design tokens, utilities, and theme setup |
| 48 | +- `colors/` - Color palette definitions (light/dark variants) |
| 49 | +- `index.ts` - Main library exports |
| 50 | +- `components/FaencyProvider.tsx` - Root provider component |
| 51 | + |
| 52 | +### Colors and Theming |
| 53 | + |
| 54 | +- Primary colors: `neon`, `blue`, `orange`, `red`, `green`, `deepBlue`, `grayBlue` |
| 55 | +- Dynamic theme generation based on primary color selection |
| 56 | +- Component themes support both light and dark variants |
| 57 | +- Colors are defined in `/colors/` with systematic naming |
| 58 | + |
| 59 | +### Component Dependencies |
| 60 | + |
| 61 | +- Built on Radix UI Primitives for accessibility |
| 62 | +- Uses Stitches for styling with CSS-in-JS |
| 63 | +- React 18+ and TypeScript 5+ required |
| 64 | + |
| 65 | +## Development Workflow |
| 66 | + |
| 67 | +### Code Style |
| 68 | + |
| 69 | +- **No Unnecessary Comments**: Do not add obvious or redundant comments. Code should be self-explanatory through clear naming and structure. Only add comments when explaining complex logic, non-obvious decisions, or documenting public APIs. |
| 70 | +- **No Unnecessary Emojis**: OK for console warnings/errors, but avoid in code comments or commit messages. |
| 71 | + |
| 72 | +### Adding New Components |
| 73 | + |
| 74 | +1. Create component directory in `/components/` |
| 75 | +2. Implement main component with Stitches styling |
| 76 | +3. Create theme file with `getLight()` and `getDark()` functions |
| 77 | +4. Add Storybook stories with all variants |
| 78 | +5. Write Jest tests for critical functionality |
| 79 | +6. Export from main `index.ts` |
| 80 | + |
| 81 | +### Working with Themes |
| 82 | + |
| 83 | +- Theme objects must have `getLight(primaryColor)` and `getDark(primaryColor)` methods |
| 84 | +- Register new themes in `stitches.config.ts` in both light and dark theme functions |
| 85 | +- Use semantic color tokens for consistency |
| 86 | + |
| 87 | +### Testing Strategy |
| 88 | + |
| 89 | +- Jest with React Testing Library setup |
| 90 | +- jsdom environment for DOM testing |
| 91 | +- Focus on accessibility and component behavior |
| 92 | +- Run tests before submitting changes |
| 93 | + |
| 94 | +## Important Notes |
| 95 | + |
| 96 | +- **Patch Required**: Run `yarn patch-package` after installing dependencies to fix Stitches TypeScript 5 compatibility |
| 97 | +- **Node Version**: Requires Node.js 20+ |
| 98 | +- **Conventional Commits**: Follow conventional commit format for semantic releases |
| 99 | +- **Accessibility**: All components must be accessible and support keyboard navigation |
| 100 | +- **Storybook**: Every component requires comprehensive stories showing all variants |
0 commit comments