@ngrr/ds 0.1.29 → 0.1.31

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.
package/AI-short.md ADDED
@@ -0,0 +1,243 @@
1
+ # DS-Nagarro — Usage guide
2
+
3
+ > Condensed rules for context-limited tools. Full reference: `AI.md`
4
+ > Storybook: `https://699f3dfd3540c3f346868d55-kmskdmltrn.chromatic.com/`
5
+
6
+ ---
7
+
8
+ ## Setup
9
+
10
+ ```tsx
11
+ // main.tsx — before everything else
12
+ import '@ngrr/ds/style.css'
13
+ import '@ngrr/ds/tokens.css'
14
+ ```
15
+
16
+ ```css
17
+ /* host app CSS */
18
+ html, body { margin: 0; height: 100%; }
19
+ #root { height: 100%; display: flex; flex-direction: column; box-sizing: border-box; }
20
+ ```
21
+
22
+ `lucide-react` is bundled inside `@ngrr/ds` — never install it separately.
23
+
24
+ ---
25
+
26
+ ## AppShell — mandatory root layout
27
+
28
+ Every page must use `AppShell`. Never build layout with raw divs.
29
+ AppShell must always live inside a full-height wrapper div — never add height to AppShell itself.
30
+
31
+ ```tsx
32
+ <div style={{ height: '100vh', display: 'flex' }}>
33
+ <AppShell
34
+ header={<Navbar variant="title" title="Dashboard" rightActions={<Button variant="primary" size="md">New project</Button>} />}
35
+ sidebar={<Sidebar ... />}
36
+ >
37
+ {/* Always include this wrapper — never skip it */}
38
+ <div style={{ paddingInline: 'var(--page-margin-x)', paddingBlock: 'var(--inset-large)' }}>
39
+ {/* page content here */}
40
+ </div>
41
+ </AppShell>
42
+ </div>
43
+ ```
44
+
45
+ - Only the content area scrolls. Sidebar and Navbar are always fixed.
46
+ - Never pass `collapsed` to Sidebar — AppShell controls it automatically.
47
+ - `DataTable` is never wrapped in a `Card` — always full-width.
48
+
49
+ ---
50
+
51
+ ## Typography — never override
52
+
53
+ The design system sets all typography globally. Never fight it.
54
+
55
+ - Never set `font-family` — it is inherited.
56
+ - Never use raw `<h1>`–`<h6>` or `<p>` with custom font styling.
57
+ - Never set `font-size` with raw pixel values — use `var(--font-size-*)` tokens.
58
+
59
+ ```tsx
60
+ // CORRECT
61
+ <div style={{ fontSize: 'var(--font-size-body-l)', color: 'var(--color-text-primary)' }}>
62
+
63
+ // WRONG
64
+ <h2 style={{ fontFamily: 'Georgia, serif' }}> // never
65
+ <p style={{ fontSize: '18px' }}> // never
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Navbar rules
71
+
72
+ - `variant="title"` on top-level pages — plain title, no back arrow, no breadcrumbs.
73
+ - `variant="breadcrumbs"` on detail views — breadcrumb replaces the title, never both.
74
+ - Primary CTA always in `rightActions` — never inside a Card, never floating.
75
+ - Never use `position: fixed` or `position: absolute` on any Button.
76
+ - Maximum one Primary button per view. Order right-to-left: Ghost → Secondary → Primary.
77
+ - All titles, labels, copy: sentence case always. Never title case.
78
+
79
+ ---
80
+
81
+ ## Card structure
82
+
83
+ ```tsx
84
+ // CORRECT
85
+ <Card title="Team members">
86
+ <div style={{ padding: 'var(--inset-large)' }}>
87
+ {/* content here */}
88
+ </div>
89
+ </Card>
90
+
91
+ // WRONG
92
+ <Card style={{ padding: 'var(--inset-large)' }}> // never on Card itself
93
+ ```
94
+
95
+ Never add padding, margin, or gap to the Card header or bottom bar — they are pre-built.
96
+ Always wrap Card children in a div with `padding: var(--inset-large)`.
97
+
98
+ ---
99
+
100
+ ## KPI / stat card pattern
101
+
102
+ ```tsx
103
+ <Card>
104
+ <div style={{ padding: 'var(--inset-large)' }}>
105
+ <div style={{ fontSize: 'var(--font-size-body-s)', color: 'var(--color-text-secondary)', marginBottom: 'var(--space-tiny)' }}>
106
+ Active projects
107
+ </div>
108
+ <div style={{ fontSize: 'var(--font-size-heading-l)', fontWeight: 'var(--font-weight-semibold)', color: 'var(--color-text-primary)' }}>
109
+ 14
110
+ </div>
111
+ <div style={{ fontSize: 'var(--font-size-body-s)', color: 'var(--color-text-success)', marginTop: 'var(--space-tiny)' }}>
112
+ +2 this week
113
+ </div>
114
+ </div>
115
+ </Card>
116
+ ```
117
+
118
+ Never use raw HTML or custom typography for stat cards. Always use `<Card>` and token values.
119
+
120
+ ---
121
+
122
+ ## Component spacing — critical
123
+
124
+ Never add `padding`, `margin`, `gap`, `min-height`, or any spacing override directly on a DS-Nagarro component. Apply spacing tokens to wrapper/container elements only.
125
+
126
+ ```
127
+ ✅ <div style={{ gap: 'var(--space-standard)' }}><Button /><Button /></div>
128
+ ❌ <Button style={{ marginRight: 'var(--space-standard)' }} />
129
+ ❌ <Navbar style={{ paddingInline: 'var(--inset-large)' }} />
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Token rules
135
+
136
+ Never hardcode hex values, pixel sizes, or rgba. Always use CSS custom properties.
137
+
138
+ | Use case | Token |
139
+ |---|---|
140
+ | Gap between elements | `--space-*` |
141
+ | Padding inside a component | `--inset-*` |
142
+ | Horizontal page margin | `--page-margin-x` |
143
+ | Text color | `--color-text-*` |
144
+ | Background | `--background-*` |
145
+ | Border/outline | `--borders-*` |
146
+ | Chart/graph colors | `--color-dataviz-*` |
147
+
148
+ - `--space-*` = gaps **between** elements. Never for internal padding.
149
+ - `--inset-*` = padding **inside** a component. Never for gaps between elements.
150
+ - Never use generic semantic tokens for dataviz — always `--color-dataviz-*`.
151
+ - Dark mode: `data-theme="dark"` on the root element — never `@media (prefers-color-scheme: dark)`.
152
+
153
+ ---
154
+
155
+ ## Tag semantic mapping
156
+
157
+ Always match Tag variant to the meaning of the value. Never use the same variant for all tags in a list.
158
+
159
+ | Meaning | Variant |
160
+ |---|---|
161
+ | Done, approved, on track, success, complete | `success` |
162
+ | At risk, pending, in progress, waiting | `warning` |
163
+ | Blocked, failed, rejected, overdue | `error` |
164
+ | Draft, inactive, archived, unknown | `neutral` |
165
+ | Category label (name, topic, team) | `neutral` |
166
+
167
+ ```tsx
168
+ // WRONG — same variant for every tag
169
+ <Tag variant="warning">Completed</Tag> // completed = success
170
+ <Tag variant="warning">Not started</Tag> // not started = neutral
171
+
172
+ // CORRECT
173
+ <Tag variant="success">Completed</Tag>
174
+ <Tag variant="warning">In progress</Tag>
175
+ <Tag variant="neutral">Not started</Tag>
176
+ <Tag variant="error">Blocked</Tag>
177
+ ```
178
+
179
+ Tags are non-interactive. Never make a Tag clickable.
180
+
181
+ ---
182
+
183
+ ## Component decision rules
184
+
185
+ | Situation | Component |
186
+ |---|---|
187
+ | Toggle between 2–5 mutually exclusive views | `SegmentControl` — never plain text or custom buttons |
188
+ | Each option has a distinct content panel | `Tabs` |
189
+ | User selects or filters with a toggleable option | `Chip` |
190
+ | Non-interactive status or category label | `Tag` |
191
+ | User clicks a table row to see details | `Drawer` |
192
+ | User must complete a task before continuing | `Modal` |
193
+ | Numeric count on a nav icon | `Badge` |
194
+ | List needing sorting, filtering, or pagination | `DataTable` |
195
+ | No results or first-time empty section | `EmptyState` |
196
+ | Content loading, shape known | `Skeleton` — not `Spinner` |
197
+
198
+ ---
199
+
200
+ ## Forms
201
+
202
+ - Every field is mandatory by default. Never use a red asterisk.
203
+ - Mark optional fields only: `Team <span style="color: var(--color-text-tertiary)">Optional</span>`
204
+ - Primary submit must be disabled until all mandatory fields have a value.
205
+ - Validate on submit only — not in real time (exceptions: password strength, character count, search, OTP).
206
+ - Every primary submit button must show `⌘↵`: `<Button variant="primary">Save changes <Shortcut>⌘↵</Shortcut></Button>`
207
+
208
+ ---
209
+
210
+ ## What not to do
211
+
212
+ - ❌ Build layout with raw divs — always use `AppShell`
213
+ - ❌ Add `min-height`, `height`, or sizing directly to `<AppShell>`
214
+ - ❌ Skip the `<div style={{ height: '100vh', display: 'flex' }}>` wrapper around AppShell
215
+ - ❌ Skip the `paddingInline: var(--page-margin-x)` content wrapper inside AppShell
216
+ - ❌ Set `font-family` anywhere in app code
217
+ - ❌ Use `<h1>`–`<h6>` or `<p>` with custom font styling
218
+ - ❌ Set `font-size` with raw pixel values
219
+ - ❌ Add spacing overrides directly on DS-Nagarro components
220
+ - ❌ Add padding or margin directly to `<Card>` — wrap children instead
221
+ - ❌ Wrap `DataTable` in a `Card`
222
+ - ❌ Place the primary CTA inside a Card or as a floating button
223
+ - ❌ Use `position: fixed` or `position: absolute` on any Button
224
+ - ❌ Show a back arrow on top-level pages
225
+ - ❌ Hardcode hex values, pixel sizes, or rgba
226
+ - ❌ Use `--inset-*` for gaps between elements
227
+ - ❌ Use `--space-*` for padding inside components
228
+ - ❌ Use generic semantic tokens or hardcoded hex for dataviz
229
+ - ❌ Use the same Tag variant for all tags in a list
230
+ - ❌ Make a Tag interactive or clickable
231
+ - ❌ Place two Primary buttons side by side
232
+ - ❌ Use any icon library other than `lucide-react`
233
+ - ❌ Install `lucide-react` separately — it is bundled inside `@ngrr/ds`
234
+ - ❌ Leave placeholder icons, help text, or hint icons in place
235
+ - ❌ Use "OK", "Confirm", or "Yes" as button labels — always specific verbs
236
+ - ❌ Use title case — always sentence case
237
+ - ❌ Override dark mode with `@media (prefers-color-scheme: dark)` — use `data-theme="dark"`
238
+ - ❌ Use `Spinner` when content shape is known — use `Skeleton`
239
+ - ❌ Leave an empty state as blank space — always use `EmptyState`
240
+
241
+ ---
242
+
243
+ *DS-Nagarro usage guide. Full reference: `AI.md`. Last updated: 2026-04-01.*