Skip to content

Commit 7806658

Browse files
committed
chore: update CLAUDE.md
1 parent 7d51f31 commit 7806658

1 file changed

Lines changed: 115 additions & 9 deletions

File tree

β€ŽCLAUDE.mdβ€Ž

Lines changed: 115 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
1515
## Essential Commands
1616

1717
```bash
18-
# Development
19-
yarn install # Setup (use Node version from .nvmrc)
20-
yarn build # Full build
18+
# Development (requires Node 24 β€” see .nvmrc)
19+
yarn install # Setup
20+
yarn build # Full build (CSS, translations, Vite, types, SCSS)
2121
yarn test # Run Jest tests
22-
yarn test <pattern> # Run specific test
23-
yarn lint-fix # Fix all lint/format issues
24-
yarn types # TypeScript type checking
22+
yarn test <pattern> # Run specific test (e.g., yarn test Channel)
23+
yarn lint-fix # Fix all lint/format issues (prettier + eslint)
24+
yarn types # TypeScript type checking (noEmit mode)
25+
26+
# E2E
27+
yarn e2e-fixtures # Generate e2e test fixtures
28+
yarn e2e # Run Playwright tests
2529

2630
# Before committing
2731
yarn lint-fix # ALWAYS run this first
@@ -71,7 +75,7 @@ ChatContext # Client, active channel, theme, navigation
7175

7276
### 2. WebSocket Event Processing
7377

74-
**File:** `src/components/Channel/Channel.tsx` (lines 342-433)
78+
**File:** `src/components/Channel/Channel.tsx` (`handleEvent` function)
7579

7680
```ts
7781
// Events are THROTTLED to 500ms to prevent excessive re-renders
@@ -104,10 +108,10 @@ Messages are processed in order:
104108

105109
### 4. Virtualization Strategy
106110

107-
**File:** `src/components/MessageList/VirtualizedMessageList.tsx`
111+
**Files:** `src/components/MessageList/VirtualizedMessageList.tsx` + `VirtualizedMessageListComponents.tsx`
108112

109113
- Uses **react-virtuoso** with custom item sizing
110-
- **Offset trick:** Uses `PREPEND_OFFSET = 10^7` to handle prepended messages without Virtuoso knowing
114+
- **Offset trick:** `PREPEND_OFFSET = 10^7` in `VirtualizedMessageListComponents.tsx` handles prepended messages without Virtuoso knowing
111115
- Only visible items + overscan buffer rendered
112116
- `skipMessageDataMemoization` prop exists for channels with 1000s of messages
113117

@@ -248,6 +252,108 @@ Closes #123
248252

249253
**Release:** Automated via semantic-release based on commit messages.
250254

255+
### Deprecation Pattern
256+
257+
When deprecating, use `@deprecated` JSDoc tag with reason and docs link. Commit under `deprecate` type. See `developers/DEPRECATIONS.md` for full process.
258+
259+
## Build System
260+
261+
The build runs 5 steps in parallel via `concurrently`:
262+
263+
1. **`copy-css.sh`** β€” Copies pre-built CSS/SCSS/assets from `@stream-io/stream-chat-css` into `dist/`
264+
2. **`build-translations`** β€” Extracts `t()` calls from source via `i18next-cli`
265+
3. **`vite build`** β€” Bundles 3 entry points (index, emojis, mp3-encoder) as CJS + ESM, no minification
266+
4. **`tsc`** β€” Generates `.d.ts` type declarations only (`tsconfig.lib.json`)
267+
5. **`build-styling`** β€” Compiles `src/styling/index.scss` β†’ `dist/css/index.css`
268+
269+
All steps write to separate directories under `dist/` so they don't conflict.
270+
271+
## Styling Architecture
272+
273+
### Dual-Layer CSS System
274+
275+
This repo has **two style sources**:
276+
277+
1. **`@stream-io/stream-chat-css`** (external dep) β€” Base design system. Copied to `dist/css/v2/` and `dist/scss/v2/` at build time. Organized as `*-layout.scss` (structure) + `*-theme.scss` (colors/typography) per component.
278+
2. **`src/styling/`** (this repo) β€” Component styles, theme variables, animations. Compiled to `dist/css/index.css`.
279+
280+
### CSS Layers (cascade order, low β†’ high)
281+
282+
```
283+
css-reset β†’ stream (v2 base) β†’ stream-new (compiled index.css) β†’ stream-overrides β†’ stream-app-overrides
284+
```
285+
286+
See `examples/vite/src/index.scss` for reference implementation. Layers eliminate the need for `!important`.
287+
288+
### Theming Variables (3 tiers)
289+
290+
1. **Primitives** (`src/styling/variables.css`) β€” Figma-sourced: `--slate-50`, `--blue-500`, etc.
291+
2. **Semantic tokens** (`src/styling/_global-theme-variables.scss`) β€” `--str-chat__primary-color`, `--str-chat__text-color` with light/dark variants
292+
3. **Component tokens** (per-component SCSS) β€” `--str-chat__message-bubble-background-color`, etc.
293+
294+
## i18n System
295+
296+
- **12 languages**: de, en, es, fr, hi, it, ja, ko, nl, pt, ru, tr (JSON files in `src/i18n/`)
297+
- **Keys are English text**: `t('Mute')`, `t('{{ user }} is typing...')`
298+
- **Extraction**: `i18next-cli extract` scans `t()` calls in source β†’ updates JSON files
299+
- **Validation**: `yarn lint` runs `scripts/validate-translations.js` β€” fails on any empty translation string (zero tolerance)
300+
- **Date/time**: `Streami18n` class wraps i18next + Dayjs with per-locale calendar formats
301+
- **When adding translatable strings**: Use `t()` from `useTranslationContext()`, then run `yarn build-translations` to update JSON files. All 12 language files must have non-empty values.
302+
303+
## Styling Architecture
304+
305+
### Dual-Layer CSS System
306+
307+
Styles come from two sources:
308+
309+
1. **`@stream-io/stream-chat-css`** β€” Base design system (copied to `dist/css/v2/` and `dist/scss/v2/` via `scripts/copy-css.sh`). Layout and theme SCSS split per component (`*-layout.scss` + `*-theme.scss`).
310+
2. **`src/styling/`** β€” SDK-specific styles compiled to `dist/css/index.css` via Sass. Master entry: `src/styling/index.scss`.
311+
312+
Component styles live in `src/components/*/styling/index.scss` and are imported by the master stylesheet.
313+
314+
### CSS Layers & Theming
315+
316+
CSS layers control cascade order (no `!important` needed):
317+
318+
```
319+
css-reset β†’ stream (v2 base) β†’ stream-new (compiled SDK CSS) β†’ stream-overrides β†’ stream-app-overrides
320+
```
321+
322+
See `examples/vite/src/index.scss` for the reference layer setup.
323+
324+
**Theming uses a 3-tier CSS variable hierarchy:**
325+
326+
1. **Primitives** (`src/styling/variables.css`) β€” Figma-sourced color palette tokens
327+
2. **Semantic tokens** (`src/styling/_global-theme-variables.scss`) β€” Light/dark mode mappings (e.g., `--str-chat__primary-color`)
328+
3. **Component tokens** (per-component SCSS) β€” e.g., `--str-chat__message-bubble-background-color`
329+
330+
### Build System
331+
332+
`yarn build` runs 5 tasks in parallel via `concurrently`:
333+
334+
1. `scripts/copy-css.sh` β€” Copies `stream-chat-css` assets into `dist/`
335+
2. `yarn build-translations` β€” Extracts `t()` calls via `i18next-cli`
336+
3. `vite build` β€” Bundles 3 entry points (index, emojis, mp3-encoder) as ESM + CJS
337+
4. `tsc --project tsconfig.lib.json` β€” Generates `.d.ts` type declarations only
338+
5. `yarn build-styling` β€” Compiles SCSS to `dist/css/index.css`
339+
340+
**Library entry points** (from `package.json` exports):
341+
342+
- `stream-chat-react` β€” Main SDK (all components, hooks, contexts)
343+
- `stream-chat-react/emojis` β€” Emoji picker plugin (`src/plugins/Emojis/`)
344+
- `stream-chat-react/mp3-encoder` β€” MP3 encoding for voice messages (`src/plugins/encoders/mp3.ts`)
345+
346+
Vite config: no minification, sourcemaps enabled, all deps externalized. Target: ES2020.
347+
348+
### i18n System
349+
350+
- 12 languages in `src/i18n/*.json` β€” **Natural language keys** (English text = key)
351+
- `yarn build-translations` extracts `t()` calls from source via `i18next-cli extract`
352+
- `yarn validate-translations` (runs during `yarn lint`) β€” **zero-tolerance: any empty string value fails the build**
353+
- `Streami18n` class (`src/i18n/Streami18n.ts`) wraps i18next, integrates Dayjs for date/time formatting
354+
- Interpolation: `t('Failed to update {{ field }}', { field })`, Plurals: `_one`/`_other` suffixes
355+
- Access via `useTranslationContext()` hook β€” only works inside `<Chat>`
356+
251357
## Key Patterns for Development
252358

253359
### Adding Custom Components

0 commit comments

Comments
Β (0)