|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## About Octuple |
| 6 | + |
| 7 | +Octuple is Eightfold's React Design System Component Library. It's a comprehensive collection of reusable React components, utilities, and hooks built with TypeScript and SCSS modules. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Primary Development Commands |
| 12 | +- `yarn storybook` - Run Storybook development server on port 2022 |
| 13 | +- `yarn build` - Build the library for production (runs lint + rollup build) |
| 14 | +- `yarn test` - Run Jest unit tests with coverage |
| 15 | +- `yarn lint` - Run ESLint on all JS/JSX/TS/TSX files |
| 16 | +- `yarn typecheck` - Run TypeScript type checking without emitting files |
| 17 | + |
| 18 | +### Testing Commands |
| 19 | +- `yarn test:update` - Update Jest snapshots |
| 20 | +- Run single test: `jest path/to/test.test.tsx` |
| 21 | + |
| 22 | +### Build Commands |
| 23 | +- `yarn build-storybook` - Build Storybook for deployment |
| 24 | +- `yarn build:webpack` - Alternative webpack-based build (runs lint + webpack) |
| 25 | + |
| 26 | +### Release Commands |
| 27 | +- `yarn release` - Standard version release (skips tests) |
| 28 | +- `yarn release:minor` - Minor version release |
| 29 | +- `yarn release:patch` - Patch version release |
| 30 | +- `yarn release:major` - Major version release |
| 31 | + |
| 32 | +## Code Architecture |
| 33 | + |
| 34 | +### Component Structure |
| 35 | +Components follow a strict modular structure in `src/components/`: |
| 36 | +- Each component has its own directory with TypeScript files, SCSS modules, Storybook stories, and Jest tests |
| 37 | +- Main export file: `src/octuple.ts` - exports all public components and utilities |
| 38 | +- Locale exports: `src/locale.ts` - internationalization utilities |
| 39 | + |
| 40 | +### Key Directories |
| 41 | +- `src/components/` - All React components organized by component name |
| 42 | +- `src/hooks/` - Custom React hooks (useBoolean, useGestures, useMatchMedia, etc.) |
| 43 | +- `src/shared/` - Shared utilities and common components (FocusTrap, ResizeObserver, utilities) |
| 44 | +- `src/styles/` - Global SCSS styles and variables |
| 45 | +- `src/tests/` - Test utilities and setup files |
| 46 | + |
| 47 | +### Component Patterns |
| 48 | +Components follow consistent patterns: |
| 49 | +- TypeScript interfaces defined in `ComponentName.types.ts` |
| 50 | +- SCSS modules using kebab-case class names (referenced as camelCase in JS) |
| 51 | +- Exported through barrel exports in `index.ts` files |
| 52 | +- Use `mergeClasses` utility for conditional class name handling |
| 53 | +- Support for themes via ConfigProvider context |
| 54 | + |
| 55 | +### Build System |
| 56 | +- **Rollup** for library bundling (primary build system) |
| 57 | +- **Webpack** alternative build available |
| 58 | +- **SCSS modules** with camelCase conversion |
| 59 | +- **TypeScript** compilation with strict type checking |
| 60 | +- **PostCSS** for CSS processing and minification |
| 61 | +- Outputs both ESM (.mjs) and CommonJS (.js) formats |
| 62 | + |
| 63 | +### Testing Approach |
| 64 | +- **Jest** with React Testing Library |
| 65 | +- **Enzyme** with React 17 adapter |
| 66 | +- **Snapshot testing** for component rendering |
| 67 | +- **MatchMedia mock** for responsive testing |
| 68 | +- **ResizeObserver** polyfill for tests |
| 69 | +- Coverage collection configured |
| 70 | + |
| 71 | +### Component Guidelines |
| 72 | +Follow the established patterns in `src/components/COMPONENTS.md`: |
| 73 | +- Use functional components with TypeScript |
| 74 | +- Define props interfaces with JSDoc comments |
| 75 | +- Use SCSS modules for styling |
| 76 | +- Include Storybook stories for documentation |
| 77 | +- Write comprehensive Jest tests with snapshots |
| 78 | +- Export all public APIs through barrel exports |
| 79 | + |
| 80 | +### Storybook |
| 81 | +- Development server runs on port 2022 |
| 82 | +- Stories follow the pattern `ComponentName.stories.tsx` |
| 83 | +- Used for component documentation and visual testing |
| 84 | + |
| 85 | +### Key Dependencies |
| 86 | +- React 17+ (peer dependency) |
| 87 | +- TypeScript for type safety |
| 88 | +- SCSS for styling with CSS modules |
| 89 | +- Storybook for component documentation |
| 90 | +- Jest + React Testing Library for testing |
| 91 | +- Various UI utility libraries (@floating-ui/react, react-spring, etc.) |
| 92 | + |
| 93 | +### Conventional Commits |
| 94 | +Commit messages must follow the Conventional Commits specification: |
| 95 | +- Format: `<type>[optional scope]: <description>` |
| 96 | +- Types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test |
| 97 | +- Subject line max 100 characters |
| 98 | +- Combined body and footer max 100 characters |
0 commit comments