@besaitech/ng-design-system 0.0.11

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/README.md ADDED
@@ -0,0 +1,219 @@
1
+ # @besaitech/ng-design-system
2
+
3
+ Reusable **Angular 20** component library (`sds-` prefix) styled with **Tailwind CSS v4**, based on
4
+ the Saitech visual language. Buttons, inputs, selects, tables, tabs, accordions, a date picker,
5
+ phone input, plus the app shell (top bar + sidebar).
6
+
7
+ > **Important:** components are styled with Tailwind utility classes that live *in their templates* —
8
+ > the package does **not** ship compiled CSS. Your app must run Tailwind v4, scan this package, and
9
+ > define the design tokens (see [Tailwind setup](#3-tailwind-v4-setup)). Without that step the
10
+ > components render unstyled.
11
+
12
+ ---
13
+
14
+ ## Requirements
15
+
16
+ - Angular **20.3+, 21.x or 22.x** (`@angular/common`, `core`, `forms`, `platform-browser`, `router`)
17
+ - Tailwind CSS **v4** in the consuming app
18
+
19
+ ---
20
+
21
+ ## 1. Install
22
+
23
+ ```bash
24
+ npm install @besaitech/ng-design-system
25
+ ```
26
+
27
+ Published to the public npm registry, so no `.npmrc` and no read token are needed.
28
+
29
+ > Earlier releases were served from an internal GitLab Package Registry and this section carried the
30
+ > `@besaitech:registry=…` + `_authToken=…` lines for it. Those instructions no longer match where the
31
+ > package comes from — following them against a public install yields a 401 for a registry you do not
32
+ > need to reach.
33
+
34
+ ## 2. Tailwind setup
35
+
36
+ The Angular peer dependencies (`@angular/common`, `core`, `forms`, …) are already present in any
37
+ Angular 20.3+ / 21 / 22 app. If you don't have Tailwind yet, add it as a dev dependency:
38
+
39
+ ```bash
40
+ npm install -D tailwindcss @tailwindcss/postcss
41
+ ```
42
+
43
+ ## 3. Tailwind v4 setup
44
+
45
+ This is the step that makes the components look right. Tailwind v4 is CSS-first — there is no
46
+ `tailwind.config.js`.
47
+
48
+ **a. Register the PostCSS plugin.** Create `.postcssrc.json` at your project root:
49
+
50
+ ```json
51
+ {
52
+ "plugins": {
53
+ "@tailwindcss/postcss": {}
54
+ }
55
+ }
56
+ ```
57
+
58
+ **b. Import Tailwind, scan the library, and define the tokens** in your global stylesheet
59
+ (`src/styles.css`). The `@source` line is what tells Tailwind to generate the utility classes used
60
+ *inside* the library, and the `@theme` block defines the colors/radii those classes refer to —
61
+ **both are required**:
62
+
63
+ ```css
64
+ @import "tailwindcss";
65
+
66
+ /* Generate the utilities used inside @besaitech/ng-design-system templates.
67
+ Path is relative to THIS file (src/styles.css → ../node_modules). */
68
+ @source "../node_modules/@besaitech/ng-design-system";
69
+
70
+ /* Brand ramp: pick a theme preset. Must come AFTER the tailwindcss import —
71
+ Tailwind v4 processes @theme in imported files and later declarations win. */
72
+ @import "@besaitech/ng-design-system/themes/saitech.css"; /* blues */
73
+ /* @import "@besaitech/ng-design-system/themes/belvigo.css"; black */
74
+
75
+ /* Everything else is yours to tune (Tailwind utilities + CSS vars). */
76
+ @theme {
77
+ /* Neutrals / surfaces */
78
+ --color-canvas: #f5f6f8;
79
+ --color-surface: #ffffff;
80
+ --color-muted: #f8f9fb;
81
+ --color-border: #e6e9f0;
82
+ --color-ink: #1b2440;
83
+ --color-ink-soft: #5b6577;
84
+ --color-ink-faint: #8a93a6;
85
+
86
+ /* Accent icon-tiles (foreground + soft background) */
87
+ --color-accent-blue: #2f6bd4;
88
+ --color-accent-blue-soft: #e8effb;
89
+ --color-accent-green: #1f9d57;
90
+ --color-accent-green-soft: #e6f5ec;
91
+ --color-accent-amber: #e0902a;
92
+ --color-accent-amber-soft: #fdf0dd;
93
+ --color-accent-red: #df4f6b;
94
+ --color-accent-red-soft: #fde7ec;
95
+ --color-accent-indigo: #6c5ce7;
96
+ --color-accent-indigo-soft: #ece9fb;
97
+
98
+ /* Status */
99
+ --color-success: #27c06b;
100
+ --color-warning: #f3b73c;
101
+ --color-danger: #df4f6b;
102
+
103
+ /* Radius */
104
+ --radius-control: 0.5rem;
105
+ --radius-card: 0.75rem;
106
+
107
+ /* Typography */
108
+ --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
109
+ }
110
+
111
+ /* Layout dimensions used by <sds-shell> / <sds-sidebar> / <sds-topbar>.
112
+ Only needed if you use the layout components. */
113
+ @layer base {
114
+ :root {
115
+ --sds-topbar-h: 64px;
116
+ --sds-sidebar-w: 256px;
117
+ --sds-sidebar-w-collapsed: 76px;
118
+ }
119
+
120
+ body {
121
+ margin: 0;
122
+ font-family: var(--font-sans);
123
+ background-color: var(--color-canvas);
124
+ color: var(--color-ink);
125
+ }
126
+ }
127
+ ```
128
+
129
+ > Why `@source`? Tailwind v4 ignores `node_modules` by default. The explicit `@source` re-includes
130
+ > this package so the classes baked into its compiled templates produce real CSS. If components show
131
+ > up unstyled, this line (or a wrong relative path) is almost always the cause.
132
+
133
+ ## 4. Use a component
134
+
135
+ All components are **standalone** — import the ones you need directly into a component's `imports`:
136
+
137
+ ```ts
138
+ import { Component } from '@angular/core';
139
+ import { FormsModule } from '@angular/forms';
140
+ import { SdsButton, SdsInput, SdsIcon } from '@besaitech/ng-design-system';
141
+
142
+ @Component({
143
+ selector: 'app-member-form',
144
+ imports: [FormsModule, SdsButton, SdsInput, SdsIcon],
145
+ template: `
146
+ <sds-input label="Nom" [(ngModel)]="name" leadingIcon="search" clearable />
147
+
148
+ <sds-button variant="primary" (click)="save()">
149
+ <sds-icon sdsIconLeading name="user-plus" [size]="18" />
150
+ Créer un membre
151
+ </sds-button>
152
+ `,
153
+ })
154
+ export class MemberForm {
155
+ name = '';
156
+ save() {/* ... */}
157
+ }
158
+ ```
159
+
160
+ Form controls (`sds-input`, `sds-textarea`, `sds-select`, `sds-multi-select`, `sds-toggle-switch`,
161
+ `sds-date-picker`, `sds-phone-input`) implement `ControlValueAccessor`, so they work with both
162
+ template-driven (`[(ngModel)]`) and reactive (`formControlName`) forms.
163
+
164
+ ---
165
+
166
+ ## Component catalog
167
+
168
+ Import names are the `Sl…` classes; the markup selectors are `sds-…`.
169
+
170
+ **Controls & primitives**
171
+
172
+ | Component | Selector | Notes |
173
+ | --- | --- | --- |
174
+ | `SdsButton` | `<sds-button>` | `variant` (primary·secondary·tertiary·ghost·danger), `size`, `loading`, `block`, `iconOnly`; `[sdsIconLeading]`/`[sdsIconTrailing]` slots |
175
+ | `SdsInput` | `<sds-input>` | CVA. `label`, `hint`, `error`, `size`, `appearance` (default·on-brand), `leading/trailingIcon`, `clearable` |
176
+ | `SdsTextarea` | `<sds-textarea>` | CVA. Auto-grow, `label`, `hint`, `error` |
177
+ | `SdsToggleSwitch` | `<sds-toggle-switch>` | CVA boolean toggle |
178
+ | `SdsSelect` | `<sds-select>` | CVA single-select dropdown |
179
+ | `SdsMultiSelect` | `<sds-multi-select>` | CVA multi-select with chips |
180
+ | `SdsDatePicker` / `SdsCalendar` | `<sds-date-picker>` / `<sds-calendar>` | CVA date field + popover calendar (`date-utils` helpers) |
181
+ | `SdsPhoneInput` | `<sds-phone-input>` | CVA phone field with country selector (`phone-countries`) |
182
+ | `SdsIcon` | `<sds-icon>` | Inline-SVG icon; `name`, `size`, `strokeWidth` |
183
+ | `SdsAvatar` | `<sds-avatar>` | Initials/image + status dot |
184
+ | `SdsBadge` | `<sds-badge>` | Status pill; `variant`, `dot` |
185
+ | `SdsCard` | `<sds-card>` | Surface container; `variant`, `interactive`, `padding` |
186
+
187
+ **Composite**
188
+
189
+ | Component | Selectors |
190
+ | --- | --- |
191
+ | Tabs | `<sds-tabs>` · `<sds-tab-list>` · `<sds-tab>` · `<sds-tab-panels>` · `<sds-tab-panel>` |
192
+ | Accordion | `<sds-accordion>` · `<sds-accordion-panel>` · `<sds-accordion-header>` · `<sds-accordion-content>` |
193
+ | Table | `<sds-table>` · `<sds-table-cell>` · `<sds-table-row-expansion>` |
194
+ | Paginator | `<sds-paginator>` |
195
+
196
+ **Layout** (use the design tokens / layout vars from step 3b)
197
+
198
+ | Component | Selector | Notes |
199
+ | --- | --- | --- |
200
+ | `SdsShell` | `<sds-shell>` | Top bar + sidebar + scrollable content; `[sdsTopbar]`/`[sdsSidebar]` slots |
201
+ | `SdsTopbar` | `<sds-topbar>` | `appName`, `user`, `(logout)`; `[sdsLogo]` slot |
202
+ | `SdsSidebar` + `SdsNavGroup` + `SdsNavItem` | `<sds-sidebar>` … | Collapsible nav rail; collapse state via root-provided `SidebarStore`; items render `routerLink` or `<button>` |
203
+
204
+ ---
205
+
206
+ ## Troubleshooting
207
+
208
+ | Symptom | Cause / fix |
209
+ | --- | --- |
210
+ | `404 Project not found` on install | `.npmrc` missing the `@besaitech:registry` line, or token lacks access to project 922 |
211
+ | `403 insufficient_scope` | Token is missing `read_package_registry` scope |
212
+ | Components render unstyled | Missing/incorrect `@source` line, or no theme preset imported (step 3b) |
213
+ | Brand colours are wrong / absent | The theme preset is imported BEFORE `@import "tailwindcss"`, so it is overridden |
214
+ | `sds-icon` shows nothing | The `name` isn't in the icon registry; check available names via the `SdsIconName` type |
215
+
216
+ ## Versioning
217
+
218
+ Semver. Each release is published from the workspace with `npm run release:lib` (bump → build →
219
+ publish). Pin a version in your app and bump deliberately.