gantri-components 2.210.0 → 2.211.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/CLAUDE.md +452 -0
  2. package/package.json +3 -2
package/CLAUDE.md ADDED
@@ -0,0 +1,452 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Commands
6
+
7
+ ### Building and Development
8
+
9
+ ```bash
10
+ # Install dependencies
11
+ yarn install
12
+
13
+ # Build the library
14
+ yarn build
15
+
16
+ # Clean and build (removes dist folder first)
17
+ yarn clean-build
18
+
19
+ # Start Storybook development server
20
+ yarn storybook
21
+
22
+ # Build Storybook static site
23
+ yarn build-storybook
24
+
25
+ # Generate icons (create React components from SVG files)
26
+ yarn generate-icons
27
+
28
+ # Type checking
29
+ yarn typecheck
30
+ ```
31
+
32
+ ### Testing
33
+
34
+ ```bash
35
+ # Run tests in watch mode (default)
36
+ yarn test
37
+
38
+ # Run specific tests
39
+ yarn test -- <file-pattern> # e.g. yarn test -- button.test
40
+
41
+ # Run tests with coverage report
42
+ yarn test:coverage
43
+
44
+ # Run tests in CI mode
45
+ yarn test:ci
46
+ ```
47
+
48
+ ## Repository Structure and Architecture
49
+
50
+ The Gantri Components library is a React component library implementing Gantri's design system. It provides a set of reusable UI components built with React and styled-components.
51
+
52
+ ### Core Architecture
53
+
54
+ - `src/components/`: Contains all UI components in separate directories
55
+ - Each component typically follows this structure:
56
+ - `index.ts` - Re-exports everything from the component directory
57
+ - `component-name.tsx` - Main component implementation
58
+ - `component-name.types.ts` - TypeScript interfaces and types
59
+ - `component-name.styles.tsx` - Styled components
60
+ - `component-name.presets.ts` - Default props and variations
61
+ - `component-name.stories.tsx` - Storybook stories
62
+ - `__tests__/` - Test files
63
+
64
+ - `src/styles/`: Contains theme definitions and styling utilities
65
+ - `theme.tsx` - The theme object with colors, typography, spacing
66
+ - `animations.ts` - Animation definitions
67
+ - `media.ts` - Media query utilities for responsive design
68
+
69
+ - `src/assets/`: Contains static assets
70
+ - `icons/` - SVG icon files organized by category
71
+ - `fonts/` - Font files
72
+
73
+ - `src/helpers/`: Utility functions and hooks
74
+ - Various helper modules for common tasks
75
+
76
+ ### Design System
77
+
78
+ The design system is based around these key concepts:
79
+
80
+ 1. **Theming** - Light and dark themes defined in `src/styles/theme.tsx`
81
+ 2. **Colors** - Comprehensive color palette with semantic colors
82
+ 3. **Typography** - Predefined typography styles (h1-h6, p0-p3, etc.)
83
+ 4. **Spacing** - Consistent spacing based on an 8px grid
84
+ 5. **Breakpoints** - Responsive design with predefined breakpoints
85
+
86
+ ### Component Architecture
87
+
88
+ Components use a composition pattern where simpler components are combined to create more complex ones:
89
+
90
+ - `Box` - The foundation component for layout with space, color, and flexbox properties
91
+ - `Flex` - Extends Box with flexbox container properties
92
+ - `Typography` - Text rendering with predefined styles
93
+ - etc.
94
+
95
+ Most components accept:
96
+ - Standard HTML props for their base elements
97
+ - Theme-based styling props (colors, spacing, etc.)
98
+ - Component-specific functionality props
99
+
100
+ ## Theme System
101
+
102
+ ### 4 Themes
103
+ - `lightTheme` (id: `classic-light`) - Classic light
104
+ - `darkTheme` (id: `classic-dark`) - Classic dark
105
+ - `modernLightTheme` (id: `modern-light`) - Modern light with opacity/glass effects
106
+ - `modernDarkTheme` (id: `modern-dark`) - Modern dark with luminosity blends
107
+
108
+ ### Theme Structure
109
+ ```typescript
110
+ theme.name // 'light' | 'dark' - base mode for backward compatibility
111
+ theme.id // unique identifier: 'classic-light', 'modern-dark', etc.
112
+ theme.fallbacks // resolution chain for themeStyle: ['modern-dark', 'dark']
113
+ ```
114
+
115
+ ### Adding Modern Theme Styles
116
+ Use `themeStyle` utility for theme-specific CSS. **Never** check `theme.id` directly.
117
+
118
+ ```typescript
119
+ import { themeStyle } from 'gantri-components';
120
+
121
+ // themeStyle MUST be inside the main interpolation block
122
+ const StyledBox = styled.div<StyledBoxProps>`
123
+ ${({ theme }) => css`
124
+ background: ${theme.colors.surfaces.monochrome.t1};
125
+
126
+ ${themeStyle<StyledBoxProps>({
127
+ 'modern-dark': ({ $prop }: StyledBoxProps) => css`
128
+ background: rgba(204, 204, 204, 0.13);
129
+ `,
130
+ })}
131
+ `}
132
+ `;
133
+ ```
134
+
135
+ **CRITICAL**: Always add explicit type annotations to themeStyle callback params to avoid TS7031.
136
+
137
+ ### Modern Theme Design Tokens
138
+
139
+ **Flat (modern-light):**
140
+ - Input bg: `rgba(0,0,0,0.07)`, hover: `rgba(0,0,0,0.19)`
141
+ - Text: primary `rgba(0,0,0,0.9)`, secondary `rgba(0,0,0,0.5)`, tertiary `rgba(0,0,0,0.35)`
142
+ - Border radius: 12px inputs, 40px buttons
143
+ - Hover glow: `inset 0 0 48px white`
144
+
145
+ **Dynamic (modern-dark):**
146
+ - Input bg: luminosity `rgba(204,204,204,0.13)` + backdrop-blur 32px
147
+ - Text: primary `white`, secondary `rgba(242,242,242,0.7)`, tertiary `rgba(229,229,229,0.6)`
148
+ - Hover glow: same with luminosity blend
149
+
150
+ ## Component Quick Reference
151
+
152
+ ### Button
153
+
154
+ **How to identify variants from Figma:**
155
+
156
+ | What you see in Figma | Variant to use |
157
+ |---|---|
158
+ | Green/brand color filled button | `primary` |
159
+ | Dark/black filled button | `primaryContrast` |
160
+ | Light gray or translucent filled button (not prominent) | `secondary` |
161
+ | Same as secondary but with visible border | `tertiary` |
162
+ | Transparent button, no background, text only | `ghost` |
163
+ | Red/danger filled button | `primaryAlert` |
164
+ | On dark backgrounds: bright/white glass-like button | `primaryContrast` |
165
+ | On dark backgrounds: subtle translucent button | `secondaryContrast` |
166
+ | On dark backgrounds: transparent, no background | `ghostContrast` |
167
+
168
+ **How to identify sizes from Figma:**
169
+
170
+ | Figma height | Size prop |
171
+ |---|---|
172
+ | ~36-40px | `small` |
173
+ | ~48px | `medium` |
174
+ | ~56-64px | `large` |
175
+ | ~80px | `extraLarge` |
176
+
177
+ **Icon-only**: If the button is a perfect circle with just an icon (no text), pass `icon` without `text`.
178
+
179
+ - Modern themes: pill shape (40px radius), inner glow, no border
180
+ - Classic themes: square corners (theme.borderRadius), solid borders
181
+
182
+ ### TextField / TextArea
183
+
184
+ **How to identify from Figma:**
185
+
186
+ | What you see | Props |
187
+ |---|---|
188
+ | Input with solid/tinted background, no underline | `variant="filled"` |
189
+ | Input with only a bottom border line | `variant="line"` |
190
+ | Floating label inside the input that shrinks on focus | Size `L` (large) — label is inside |
191
+ | External label above the input | Size `M` (medium) — label is outside |
192
+ | "(Optional)" text next to label | `required` is false (default) |
193
+ | No "(Optional)" text | `required={true}` |
194
+
195
+ - **Sizes**: `small`, `medium` (default), `large`
196
+ - Label uses `Label` component internally
197
+
198
+ ### OptionSelector
199
+ - Grid of selectable options with `columns`, `gap`, `size`, `optionMaxWidth`
200
+ - Supports string items or `{ value, label, badge?, disabled? }` objects
201
+ - `labelText` for built-in label, `required` prop
202
+ - Formik compatible via `FormikInput` `Field` prop
203
+
204
+ ### Banner
205
+
206
+ **How to identify variants from Figma:**
207
+
208
+ | What you see | Variant |
209
+ |---|---|
210
+ | Green background | `success` |
211
+ | Blue/purple background | `info` |
212
+ | Orange background | `warning` |
213
+ | Red background | `alert` |
214
+ | Light gray/subtle background | `subtle` |
215
+ | Dark/black background | `contrast` |
216
+ | Glass/blur background on dark surface | `dynamic` |
217
+ | Solid vibrant color | `emphasized={true}` (default) |
218
+ | Light tinted/muted color | `emphasized={false}` |
219
+ | Label + chevron `>` on right, single row | `layout="horizontal"` |
220
+ | Label + caption + "Action" button below | `layout="vertical"` |
221
+
222
+ ### Typography
223
+
224
+ **CRITICAL: Always use Typography for text. Never put raw text in JSX.**
225
+
226
+ ```typescript
227
+ <Typography text="Hello" variant="p2" color="t1" />
228
+ ```
229
+
230
+ **How to identify variant from Figma:**
231
+
232
+ | Figma font size | Variant | Font |
233
+ |---|---|---|
234
+ | 130px | `mh1` | Roboto Mono |
235
+ | 50px | `mh2` | Roboto Mono |
236
+ | 25px | `mp1` | Roboto Mono |
237
+ | 16px | `mp2` | Roboto Mono |
238
+ | 12px (mono) | `mp3` / `mh3`-`mh6` | Roboto Mono |
239
+ | 52px | `h1` | Söhne |
240
+ | 44px | `h2` | Söhne |
241
+ | 28px | `h3` | Söhne |
242
+ | 22px | `h4` | Söhne |
243
+ | 20px | `h5` | Söhne |
244
+ | 15px (heading) | `h6` | Söhne |
245
+ | 32px | `p0` | Söhne |
246
+ | 20px (body) | `p1` | Söhne |
247
+ | 15px (body) | `p2` | Söhne |
248
+ | 12px (body) | `p3` | Söhne |
249
+
250
+ **Color prop values:** `t1` (primary), `t2` (secondary), `t3` (tertiary), `alt` (white/contrast), `link` (green), `alert` (red), `success`, `warning`
251
+
252
+ **Spacing:** Typography extends ElementSpacingProps — use `marginTop="2x"`, `paddingBottom="x"`, etc.
253
+
254
+ **Bold text:** Use `fontWeight={700}`, NOT `textStyle="bold"`
255
+
256
+ ### Grid / Cell (Layout System)
257
+
258
+ **Use Grid+Cell for page-level section layouts, not Flex.**
259
+
260
+ ```typescript
261
+ <Grid columns={{ lg: 12, md: 4 }}>
262
+ <Cell width={{ lg: 6, md: 4 }} row={{ md: 2 }}>
263
+ <LeftContent />
264
+ </Cell>
265
+ <Cell column={{ lg: 8 }} width={{ lg: 5, md: 4 }} row={{ md: 1 }}>
266
+ <RightContent />
267
+ </Cell>
268
+ </Grid>
269
+ ```
270
+
271
+ **Responsive cascade:** Values cascade downward: `lg → md → sm`. If `md` is set but not `sm`, `sm` inherits `md`.
272
+
273
+ **Desktop:** 12 columns. **Mobile:** 4 columns.
274
+
275
+ ### Box
276
+
277
+ Foundation layout component. All spacing props use `BoxDimension` values.
278
+
279
+ ```typescript
280
+ <Box marginTop="3x" paddingLeft="2x" />
281
+ ```
282
+
283
+ **BoxDimension values:** `.5x` (4px), `x` (8px), `2x` (16px), `3x` (24px), `4x` (32px), `5x` (40px), `6x` (48px), `8x` (64px), `10x` (80px), `12x` (96px), `16x` (128px), `20x` (160px), `24x` (192px)
284
+
285
+ ### Flex
286
+
287
+ Extends Box with flexbox props.
288
+
289
+ ```typescript
290
+ <Flex direction="column" justifyContent="space-between" alignItems="center" gap="2x">
291
+ <Child />
292
+ </Flex>
293
+ ```
294
+
295
+ **Props:** `direction` (not `flexDirection`), `justifyContent` (not `justify`), `alignItems` (not `align`), `gap`
296
+
297
+ ### Stack
298
+
299
+ Vertical stack with padding.
300
+
301
+ ```typescript
302
+ <Stack horizontalPadding="2x" verticalPadding="3x">
303
+ <Child />
304
+ </Stack>
305
+ ```
306
+
307
+ ### Icon
308
+
309
+ ```typescript
310
+ <Icon name="category:icon_name" size="24px" color="t1" />
311
+ ```
312
+
313
+ **Categories:** `actions`, `alert`, `arrows`, `docs`, `media`, `ui-control`, `view`, `work`
314
+
315
+ **Common icons:**
316
+ - `ui-control:plus`, `ui-control:x`, `ui-control:check_mark`
317
+ - `arrows:arrow_right`, `arrows:arrow_left`, `arrows:arrow_chevron_right`, `arrows:arrow_chevron_down`
318
+ - `view:magnifying_glass`, `docs:pencil`, `alert:i_circle`
319
+ - `work:box`, `work:light_bulb`
320
+
321
+ ### Modal
322
+
323
+ ```typescript
324
+ <Modal closeable header="Title" footer={footerJSX} maxWidth="520px" onClose={onClose}>
325
+ <Content />
326
+ </Modal>
327
+ ```
328
+
329
+ Always use gantri-components Modal, never custom modal wrappers.
330
+
331
+ ### Dropdown
332
+
333
+ ```typescript
334
+ <Dropdown items={[{ value: 1, label: 'Option' }]} labelText="Select" placeholder="Choose..." />
335
+ ```
336
+
337
+ Delegates to TextField internally for label/input rendering.
338
+
339
+ ### SearchField
340
+
341
+ ```typescript
342
+ <SearchField items={items} labelText="Search" placeholder="Type..." maxHeight={300} />
343
+ ```
344
+
345
+ ### FormikInput (Formik Integration)
346
+
347
+ Wraps any component for Formik form binding:
348
+
349
+ ```typescript
350
+ <FormikInput name="fieldName" labelText="Label" placeholder="..." />
351
+ <FormikInput name="selection" Field={<OptionSelector items={[...]} />} />
352
+ <FormikInput name="color" Field={<ColorPicker />} />
353
+ <FormikInput name="agree" Field={<Checkbox labelText="I agree" />} />
354
+ ```
355
+
356
+ ### Conditional / Responsive
357
+
358
+ ```typescript
359
+ <Conditional condition={isLoading} Fallback={<Content />}>
360
+ <LoadingScreen />
361
+ </Conditional>
362
+
363
+ <Responsive sm={<MobileView />} md={<TabletView />} lg={<DesktopView />} />
364
+ ```
365
+
366
+ ### Label
367
+ - Shows "(Optional)" when `required` is false/undefined
368
+ - Used internally by TextField, TextArea, OptionSelector
369
+
370
+ ### Checkbox / Radio / Toggle
371
+
372
+ **How to identify from Figma:**
373
+
374
+ | What you see | Component |
375
+ |---|---|
376
+ | Square/rounded-square check box | `Checkbox` |
377
+ | Circle with dot inside | `Radio` |
378
+ | Pill-shaped sliding switch | `Toggle` |
379
+ | Grid of selectable card/tile options | `RadioList` with `showAsTiles` or `OptionSelector` |
380
+ | Simple text options in a row | `RadioList` inline |
381
+
382
+ - Modern themes: 24px size, no border, luminosity/solid fills, inner glow when checked
383
+ - Classic themes: 20px, bordered, green fill when checked
384
+
385
+ ## Styling Rules
386
+
387
+ - Always use CSS variables: `var(--surface-secondary)`, `var(--text-t1)`, `var(--spacing-2x)`
388
+ - Styled components: wrap dynamic styles in `${() => css\`\`}`
389
+ - Use `$` prefix for styled-component-only props
390
+ - 8px spacing grid: `x`=8px, `2x`=16px, `.5x`=4px
391
+
392
+ ## Exports
393
+ ```typescript
394
+ import {
395
+ Button, TextField, TextArea, OptionSelector, Banner, Label,
396
+ Checkbox, Radio, RadioList, Toggle, Icon, Typography,
397
+ Flex, Box, Grid, Cell, Modal, Stack, FormikInput,
398
+ lightTheme, darkTheme, modernLightTheme, modernDarkTheme,
399
+ ThemeProvider, createTheme, themeStyle,
400
+ palette, spacing, media,
401
+ } from 'gantri-components';
402
+ ```
403
+
404
+ ## Best Practices
405
+
406
+ ### Adding New Components
407
+
408
+ 1. Follow the existing component structure (create all necessary files)
409
+ 2. Start from `Box` or another primitive component when possible
410
+ 3. Use theme values for colors, spacing, typography
411
+ 4. Ensure components are fully typed
412
+ 5. Write tests (use React Testing Library)
413
+ 6. Create Storybook stories for documentation
414
+
415
+ ### Testing
416
+
417
+ - Tests use Jest and React Testing Library
418
+ - Components should have unit tests covering functionality
419
+ - Use `renderWithThemeProvider` from test-utils for rendering components with theme context
420
+ - Follow the "Arrange-Act-Assert" pattern in tests
421
+
422
+ ### Working with Icons
423
+
424
+ When adding new icons:
425
+
426
+ 1. Add SVG files to appropriate category in `/src/assets/icons/`
427
+ 2. Follow the naming convention (lowercase, no spaces)
428
+ 3. Run `yarn generate-icons` to create React components
429
+
430
+ ### Commit Guidelines
431
+
432
+ The repository uses conventional commits for automated versioning:
433
+
434
+ - `feat:` - A new feature (minor version)
435
+ - `fix:` - A bug fix (patch version)
436
+ - `docs:` - Documentation only changes
437
+ - `style:` - Changes that don't affect the meaning of the code
438
+ - `refactor:` - Code change that neither fixes a bug nor adds a feature
439
+ - `perf:` - Performance improvements
440
+ - `test:` - Adding missing tests or correcting existing tests
441
+ - `chore:` - Changes to the build process or auxiliary tools
442
+
443
+ Note: `chore` commit prefixes do not trigger a new version deployment.
444
+
445
+ ### Publishing Process
446
+
447
+ To deploy changes, merge them into the appropriate branch:
448
+
449
+ - `main` - For production releases
450
+ - `beta` - For beta releases (can be installed with `yarn add gantri-components@beta`)
451
+
452
+ Semantic Release automates versioning and publishing based on commit messages.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantri-components",
3
- "version": "2.210.0",
3
+ "version": "2.211.0",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "umd": "dist/index.umd.js",
@@ -173,7 +173,8 @@
173
173
  "uuid": "^8.3.2"
174
174
  },
175
175
  "files": [
176
- "dist"
176
+ "dist",
177
+ "CLAUDE.md"
177
178
  ],
178
179
  "engines": {
179
180
  "node": ">= 18.0.0",