|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +**Ion** is the official Angular-based Design System for **Brisanet**, published as `@brisanet/ion` on npm. It is an Angular CLI library workspace (`projectType: "library"`). |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +# Development |
| 13 | +npm start # Serve ion-test-app |
| 14 | +npm run storybook # Start Storybook on port 6006 |
| 15 | + |
| 16 | +# Building |
| 17 | +npm run build ion # Build the ion library to dist/ion |
| 18 | +npm run build-storybook # Build Storybook static site to dist/storybook/ion |
| 19 | + |
| 20 | +# Testing |
| 21 | +npm test # Run all Jest tests |
| 22 | +npx jest --testPathPattern=button # Run tests matching a pattern |
| 23 | +npx jest --coverage # Run with coverage report |
| 24 | +``` |
| 25 | + |
| 26 | +## Project Structure |
| 27 | + |
| 28 | +``` |
| 29 | +projects/ |
| 30 | + ion/ # Core library (published to npm) |
| 31 | + src/ |
| 32 | + lib/ # Component directories (one folder per component) |
| 33 | + lib/core/types/ # Shared TypeScript interfaces/types |
| 34 | + lib/core/bn-*/ # Business components (bn- prefix) |
| 35 | + styles/ # Global design tokens (colors, fonts, shadows, z-indexes, themes) |
| 36 | + stories/ # Storybook stories |
| 37 | + public-api.ts # Barrel export — all public exports go here |
| 38 | + ion-test-app/ # Showcase / integration test app |
| 39 | +``` |
| 40 | + |
| 41 | +## Angular Component Conventions |
| 42 | + |
| 43 | +- Angular v21: standalone components are **default** — do NOT set `standalone: true` |
| 44 | +- Always use `changeDetection: ChangeDetectionStrategy.OnPush` |
| 45 | +- Selector prefix: `ion-` (e.g. `ion-button`); class naming: `Ion<Name>Component` |
| 46 | +- Use `input()` / `output()` signal functions — NOT `@Input()` / `@Output()` decorators |
| 47 | +- Use `signal()`, `computed()`, `effect()` for state; update with `.set()` / `.update()` |
| 48 | +- Use `host: {}` in `@Component` — NOT `@HostBinding` / `@HostListener` |
| 49 | +- Templates: `@if`, `@for`, `@switch` (native control flow) — NOT `*ngIf`, `*ngFor` |
| 50 | +- Bindings: `[class.name]` — NOT `ngClass`; `[style.prop]` — NOT `ngStyle` |
| 51 | +- Test selectors: `[attr.data-testid]` following pattern `'btn-' + (label() || id())` |
| 52 | +- Use `inject()` for dependency injection, not constructor injection |
| 53 | +- Every new public component/directive/service must be exported from `public-api.ts` |
| 54 | + |
| 55 | +## Testing Conventions |
| 56 | + |
| 57 | +```typescript |
| 58 | +// Standard setup for standalone components |
| 59 | +await TestBed.configureTestingModule({ |
| 60 | + imports: [IonMyComponent], // standalone goes in imports |
| 61 | +}).compileComponents(); |
| 62 | + |
| 63 | +// Setting signal inputs |
| 64 | +fixture.componentRef.setInput('label', 'Click me'); |
| 65 | +fixture.detectChanges(); |
| 66 | + |
| 67 | +// DOM queries |
| 68 | +fixture.nativeElement.querySelector('[data-testid="btn-myId"]'); |
| 69 | +document.body.querySelector(...) // for overlays/portals (modal, tooltip, dropdown) |
| 70 | + |
| 71 | +// Event testing |
| 72 | +const clickSpy = jest.fn(); |
| 73 | +component.ionOnClick.subscribe(clickSpy); |
| 74 | +``` |
| 75 | + |
| 76 | +## Styling Conventions |
| 77 | + |
| 78 | +- SCSS only; external files via `styleUrls` (not inline styles) |
| 79 | +- Theme files are named `_<name>.theme.scss` |
| 80 | +- Always use existing design tokens from `projects/ion/src/styles/` — never hardcode values |
| 81 | + - Colors: `styles/colors/colors.scss` |
| 82 | + - Fonts: `styles/fonts/index.scss` |
| 83 | + - Shadows: `styles/shadows/index.scss` |
| 84 | + - Z-indexes: `styles/z-indexes/index.scss` |
| 85 | + - Themes (light/dark CSS vars): `styles/themes/index.scss` |
| 86 | +- CSS class naming: `ion-btn-primary`, `ion-btn-sm`, `ion-btn-md`, etc. |
| 87 | + |
| 88 | +## Storybook Conventions |
| 89 | + |
| 90 | +Use CSF3 format with `Meta<Component>` and `StoryObj<Component>`, `tags: ['autodocs']`, and `argTypes` for outputs. If a component requires services, use `applicationConfig` with `providers`. Stories live in `projects/ion/src/stories/`. |
| 91 | + |
| 92 | +## CI/CD |
| 93 | + |
| 94 | +- PRs to `main`: runs `npm test` + `npm run build ion` via GitHub Actions (Node 22.22.0) |
| 95 | +- Release: triggered on GitHub Release publish; builds and publishes to npm with provenance |
| 96 | +- Branch strategy: `main` (Angular v21), `support/v19` (LTS), `support/v8` (legacy) |
| 97 | +- Changes to older branches are propagated via `git cherry-pick` |
0 commit comments