@maggioli-design-system/magma-angular 2.0.0-beta.2 → 2.0.0-beta.3

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.
@@ -0,0 +1,211 @@
1
+ <!--
2
+ GENERATED FILE - do not edit by hand.
3
+ Source of truth: docs/agents/ in the magma monorepo.
4
+ Regenerate with: npm run sync.agent-docs (from the stencil package).
5
+ -->
6
+ # agents usage.md
7
+
8
+ ## Purpose
9
+
10
+ How to actually use Magma components and styles once installed. This is the
11
+ cross-cutting "how the system works" knowledge that does not come from the TypeScript
12
+ types: naming, the tone/variant axes, events, slots, compound rules, icons,
13
+ accessibility, and app-level styling (token color classes, typography utilities, dark
14
+ mode). For the per-component API (props, events, slots, CSS custom properties) read the
15
+ shipped reference - see "Per-component API" below - and for the catalogue of what
16
+ exists read [`components.md`](components.md).
17
+
18
+ This file is shipped inside each package as `agents/usage.md`, versioned with it.
19
+
20
+ ## Per-component API (already shipped - read these first)
21
+
22
+ The published package already carries the full component reference. Do not guess prop
23
+ names; look them up:
24
+
25
+ | Source | Path (resolves from node_modules) | Use for |
26
+ | ------ | --------------------------------- | ------- |
27
+ | Types | `@maggioli-design-system/magma/dist/types/components.d.ts` | Prop names and their typed value sets, event types. Drives editor IntelliSense |
28
+ | Full docs | `@maggioli-design-system/magma/dist/documentation.json` | Per-component `readme`, `usage`, `props`, `events`, `slots`, `styles`, `parts` in one structured file |
29
+ | Catalogue | [`components.md`](components.md) | Which component to reach for (tag + summary) |
30
+
31
+ The `magma` core package is always installed (the React/Angular wrappers depend on it),
32
+ so these paths resolve regardless of target.
33
+
34
+ To inspect one component from `documentation.json` without reading 2 MB:
35
+
36
+ ```bash
37
+ node -e "const d=require('@maggioli-design-system/magma/dist/documentation.json');const c=d.components.find(c=>c.tag==='mds-button');console.log(JSON.stringify({props:c.props,events:c.events,slots:c.slots,styles:c.styles},null,2))"
38
+ ```
39
+
40
+ React and Angular consumers get the same metadata typed through the wrapper components /
41
+ directives - import a component and the editor surfaces its props.
42
+
43
+ ## Naming
44
+
45
+ - Every tag is prefixed `mds-`, lowercase kebab-case.
46
+ - Compound children share the parent prefix: `mds-accordion` / `mds-accordion-item`.
47
+ - Events are camelCase with the component name as prefix: `mdsButtonClick`,
48
+ `mdsInputChange`.
49
+
50
+ ## Tone and variant
51
+
52
+ Many components accept two independent axes:
53
+
54
+ - `variant` = color role: `primary`, `secondary`, `error`, `success`, `warning`,
55
+ `info`, `ai`, `dark`, `light`, plus decorative label colors (`red`, `aqua`, `blue`,
56
+ `green`, `lime`, `orange`, `purple`, `sky`, `violet`, `yellow`, `amaranth`, `orchid`).
57
+ - `tone` = visual intensity: `strong` (filled), `weak` (tinted), `outline` (bordered),
58
+ `text` (no background).
59
+
60
+ ```html
61
+ <mds-button variant="primary" tone="strong">Save</mds-button>
62
+ <mds-button variant="error" tone="outline">Delete</mds-button>
63
+ ```
64
+
65
+ > Magma 2.0 renamed `ghost` -> `outline` and `quiet` -> `text`. The old names are gone.
66
+
67
+ ## Boolean, disabled and await props
68
+
69
+ - Boolean props default to `false`/`undefined`. Prefer removing the attribute over
70
+ setting it to `false`.
71
+ - Disabled: `<mds-button disabled>`. Never `disabled="false"` - remove it instead.
72
+ - Async: `<mds-button await>` shows a spinner and blocks interaction; remove `await`
73
+ (set `undefined`) when done.
74
+
75
+ ## Events
76
+
77
+ Listen with `addEventListener` or framework bindings. The payload is on `event.detail`:
78
+
79
+ ```javascript
80
+ document.querySelector('mds-input')
81
+ .addEventListener('mdsInputChange', (e) => console.log(e.detail.value));
82
+ ```
83
+
84
+ ```tsx
85
+ // React
86
+ <MdsInput onMdsInputChange={(e) => console.log(e.detail.value)} />
87
+ ```
88
+
89
+ ```html
90
+ <!-- Angular -->
91
+ <mds-input (mdsInputChange)="onChange($event)"></mds-input>
92
+ ```
93
+
94
+ ## Slots
95
+
96
+ - The `default` slot accepts plain text only, unless the component's own docs say
97
+ otherwise. Prefer the `label` prop for text content.
98
+ - Named slots (`slot="header"`, `slot="footer"`) accept HTML and components.
99
+ - Do not wrap slotted content in arbitrary elements - it can break layout and
100
+ compound-component communication.
101
+
102
+ ## Compound components
103
+
104
+ Parent/child pairs communicate internally. Rules:
105
+
106
+ 1. The child must be a **direct slot child** of its parent - no wrappers.
107
+ 2. Never use a child outside its parent (no `mds-accordion-item` without `mds-accordion`).
108
+ 3. Never mix child types across parents.
109
+
110
+ ```html
111
+ <mds-accordion>
112
+ <mds-accordion-item>...</mds-accordion-item>
113
+ </mds-accordion>
114
+ ```
115
+
116
+ ## Icons
117
+
118
+ Reference icons by **slug**, never inline `<svg>` and never import an icon package:
119
+
120
+ ```html
121
+ <mds-icon name="action-email-send"></mds-icon>
122
+ <mds-button icon="action-email-send">Send</mds-button>
123
+ ```
124
+
125
+ The icon path must be configured once at startup (see `agents/assets.md`):
126
+ `sessionStorage.setItem('mdsIconSvgPath', '/svg/')`.
127
+
128
+ ## Accessibility
129
+
130
+ - `mds-button` derives `role`, `aria-label` and `title` from `label`/slot. Icon-only
131
+ buttons must set `label` or `aria-label`.
132
+ - Form components (`mds-input`, `mds-input-select`, ...) are form-associated and
133
+ participate in native form submission.
134
+ - Use the preference components / classes for high contrast and reduced motion - do not
135
+ hard-code those styles.
136
+
137
+ ## Styling components from outside
138
+
139
+ The only supported customisation is the **CSS custom properties** each component
140
+ exposes (listed under "CSS Custom Properties" in its reference). Never pierce the
141
+ shadow DOM.
142
+
143
+ ```css
144
+ /* correct */
145
+ mds-button { --mds-button-radius: 999px; }
146
+
147
+ /* deep customisation, use sparingly */
148
+ mds-button::part(icon) { fill: rgb(var(--variant-primary-03)); }
149
+
150
+ /* incorrect - do not target internal nodes */
151
+ mds-button >>> .internal { color: red; }
152
+ ```
153
+
154
+ ## App-level styling
155
+
156
+ Beyond components, build your own UI with Magma's tokens and utilities (these require
157
+ the styles setup in `agents/assets.md`).
158
+
159
+ ### Color classes
160
+
161
+ Use semantic token classes, never raw Tailwind primitives - they break dark mode:
162
+
163
+ ```html
164
+ <!-- correct -->
165
+ <div class="bg-tone-neutral text-tone-neutral-03">...</div>
166
+ <!-- incorrect -->
167
+ <div class="bg-white text-gray-700">...</div>
168
+ ```
169
+
170
+ Prefixes: `tone-neutral`, `tone-porcelain`, `tone-kaolin`, `tone-fireclay`,
171
+ `tone-bisque`, `status-{info,success,warning,error}`, `label-*`,
172
+ `variant-{primary,secondary,ai}`, `brand-maggioli`. Outside Tailwind, always use the
173
+ RGB wrapper so opacity works:
174
+
175
+ ```css
176
+ .sel { color: rgb(var(--tone-neutral-03)); background: rgb(var(--tone-neutral-03) / 0.15); }
177
+ ```
178
+
179
+ ### Typography utilities
180
+
181
+ Use the semantic `text-*` utilities instead of composing `font-*` + `text-*`:
182
+ `text-title-h1`..`h6`, `text-title-action`, `text-info-{paragraph,detail,caption,label,option,tip}`,
183
+ `text-read-{paragraph,detail,caption}`, `text-code-{snippet,hack}`.
184
+
185
+ ### Dark mode and preferences
186
+
187
+ Handled at the palette level - no per-element classes. Activate on `<html>`:
188
+
189
+ ```html
190
+ <html class="pref-theme-system"><!-- or pref-theme-light / pref-theme-dark --></html>
191
+ ```
192
+
193
+ Same pattern for `pref-contrast-*` and `pref-animation-*`. For programmatic control use
194
+ the `mds-pref-theme` component. Never write `color-scheme` or dark-mode media queries by
195
+ hand.
196
+
197
+ ### Global design decisions
198
+
199
+ Override `--magma-*` vars only inside the `overrides` cascade layer:
200
+ `--magma-corner-shape` (default `squircle`), `--magma-disabled-opacity` (`0.5`),
201
+ `--magma-backdrop-opacity` (`0.1`), `--magma-outline-focus`.
202
+
203
+ ```css
204
+ @layer overrides { :root { --magma-corner-shape: round; } }
205
+ ```
206
+
207
+ ## See also
208
+
209
+ - [`components.md`](components.md) - the component catalogue
210
+ - [`assets.md`](assets.md) - styles / fonts / icons setup
211
+ - [`AGENTS.md`](../AGENTS.md) - the install entry point