@f-ewald/components 0.1.0 → 0.2.1

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,58 @@
1
+ # `<radio-cards>`
2
+
3
+ Single-select group of full-width cards, each with a label and optional
4
+ description — for a handful of meaningfully different choices where the
5
+ description matters. For many short, same-shaped options (a color swatch,
6
+ a basemap style), use `radio-pills` instead. Wraps native radio inputs for
7
+ keyboard/a11y and fires `change` rather than relying on form submission.
8
+
9
+ ## Install
10
+
11
+ ```js
12
+ import "@f-ewald/components/radio-cards.js";
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```html
18
+ <radio-cards></radio-cards>
19
+ <script type="module">
20
+ const el = document.querySelector("radio-cards");
21
+ el.options = [
22
+ { value: "simple", label: "Simple", description: "Quick-ranking view" },
23
+ { value: "detailed", label: "Detailed", description: "Every section and layer" },
24
+ ];
25
+ el.value = "simple";
26
+ el.addEventListener("change", (e) => console.log(e.detail.value));
27
+ </script>
28
+ ```
29
+
30
+ ## Attributes / properties
31
+
32
+ | Property | Attribute | Type | Default | Description |
33
+ | --- | --- | --- | --- | --- |
34
+ | `options` | _(JS property only)_ | `RadioCardOption[]` | `[]` | Options to render, one card each. |
35
+ | `value` | `value` | `string` | `""` | Currently selected value. |
36
+
37
+ ## Events
38
+
39
+ | Event | Description |
40
+ | --- | --- |
41
+ | `change` | A card was selected; detail: { value }. |
42
+
43
+ ## Slots
44
+
45
+ _None._
46
+
47
+ ## CSS custom properties
48
+
49
+ | Custom property |
50
+ | --- |
51
+ | `--ui-border` |
52
+ | `--ui-font` |
53
+ | `--ui-font-size-sm` |
54
+ | `--ui-primary` |
55
+ | `--ui-radius-sm` |
56
+ | `--ui-surface-muted` |
57
+ | `--ui-text` |
58
+ | `--ui-text-muted` |
@@ -0,0 +1,56 @@
1
+ # `<radio-pills>`
2
+
3
+ Single-select group of compact pill-shaped options — for many short,
4
+ same-shaped choices (a basemap style, a unit toggle). For a handful of
5
+ choices where a description matters, use `radio-cards` instead. Wraps
6
+ native radio inputs for keyboard/a11y and fires `change` rather than
7
+ relying on form submission.
8
+
9
+ ## Install
10
+
11
+ ```js
12
+ import "@f-ewald/components/radio-pills.js";
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```html
18
+ <radio-pills></radio-pills>
19
+ <script type="module">
20
+ const el = document.querySelector("radio-pills");
21
+ el.options = [
22
+ { value: "light", label: "Light" },
23
+ { value: "streets", label: "Streets" },
24
+ ];
25
+ el.value = "light";
26
+ el.addEventListener("change", (e) => console.log(e.detail.value));
27
+ </script>
28
+ ```
29
+
30
+ ## Attributes / properties
31
+
32
+ | Property | Attribute | Type | Default | Description |
33
+ | --- | --- | --- | --- | --- |
34
+ | `options` | _(JS property only)_ | `RadioPillOption[]` | `[]` | Options to render, one pill each. |
35
+ | `value` | `value` | `string` | `""` | Currently selected value. |
36
+
37
+ ## Events
38
+
39
+ | Event | Description |
40
+ | --- | --- |
41
+ | `change` | A pill was selected; detail: { value }. |
42
+
43
+ ## Slots
44
+
45
+ _None._
46
+
47
+ ## CSS custom properties
48
+
49
+ | Custom property |
50
+ | --- |
51
+ | `--ui-border` |
52
+ | `--ui-font` |
53
+ | `--ui-font-size-sm` |
54
+ | `--ui-primary` |
55
+ | `--ui-surface-muted` |
56
+ | `--ui-text` |
@@ -0,0 +1,67 @@
1
+ # `<ui-button>`
2
+
3
+ Button (or link styled as one) with an optional leading icon, in three
4
+ visual weights. Set `href` to render an `<a>` instead of a `<button>` —
5
+ same styling either way — for cross-page navigation that should look like
6
+ an action button; a disabled/busy link stays a real `<a>` with
7
+ `aria-disabled` + `pointer-events: none` rather than losing its href.
8
+ Put the icon in the `icon` slot and the label in the default slot.
9
+
10
+ Form-associated (`type="submit"`/`"reset"`): the actual `<button>` lives in
11
+ this element's shadow root, which native HTML form association does not
12
+ cross into from an ancestor light-DOM `<form>`. `type="submit"`/`"reset"`
13
+ is instead wired through `ElementInternals.form` — the same mechanism
14
+ `address-autocomplete` uses to associate with an ancestor form.
15
+
16
+ ## Install
17
+
18
+ ```js
19
+ import "@f-ewald/components/ui-button.js";
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ```html
25
+ <ui-button variant="primary">
26
+ <span slot="icon">...</span>
27
+ New property
28
+ </ui-button>
29
+ <ui-button variant="danger">Delete</ui-button>
30
+ <ui-button variant="secondary" href="/properties?edit=42">Edit</ui-button>
31
+ ```
32
+
33
+ ## Attributes / properties
34
+
35
+ | Property | Attribute | Type | Default | Description |
36
+ | --- | --- | --- | --- | --- |
37
+ | `variant` | `variant` | `ButtonVariant` | `"primary"` | Visual weight. |
38
+ | `href` | `href` | `string | null` | `null` | Renders an `<a href="...">` instead of a `<button>` when set. |
39
+ | `type` | `type` | `"button" | "submit" | "reset"` | `"button"` | Native button `type`. Ignored when `href` is set. |
40
+ | `disabled` | `disabled` | `boolean` | `false` | Disables the control and dims it. |
41
+ | `busy` | `busy` | `boolean` | `false` | Shows a spinner in place of the icon slot and disables the control. |
42
+
43
+ ## Events
44
+
45
+ _None._
46
+
47
+ ## Slots
48
+
49
+ | Slot | Description |
50
+ | --- | --- |
51
+ | `(default)` | Button label. |
52
+ | `icon` | Optional leading icon (e.g. an inline SVG). |
53
+
54
+ ## CSS custom properties
55
+
56
+ | Custom property |
57
+ | --- |
58
+ | `--ui-border` |
59
+ | `--ui-danger` |
60
+ | `--ui-danger-hover` |
61
+ | `--ui-font` |
62
+ | `--ui-font-size-sm` |
63
+ | `--ui-primary` |
64
+ | `--ui-primary-hover` |
65
+ | `--ui-radius-sm` |
66
+ | `--ui-text` |
67
+ | `--ui-text-muted` |
@@ -0,0 +1,42 @@
1
+ # `<user-avatar>`
2
+
3
+ Circular avatar. Shows `src` when it loads successfully; falls back to the
4
+ first letter of `name` (uppercased) if `src` is unset or fails to load
5
+ (e.g. an expired OAuth profile-photo URL); falls back further to a generic
6
+ person icon if `name` is also unset. A broken image never leaves a blank
7
+ circle.
8
+
9
+ ## Install
10
+
11
+ ```js
12
+ import "@f-ewald/components/user-avatar.js";
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```html
18
+ <user-avatar src="https://example.com/photo.jpg" name="Freddy" size="40"></user-avatar>
19
+ ```
20
+
21
+ ## Attributes / properties
22
+
23
+ | Property | Attribute | Type | Default | Description |
24
+ | --- | --- | --- | --- | --- |
25
+ | `src` | `src` | `string | null` | `null` | Image URL to show. Falls back to initials/icon if unset or it fails to load. |
26
+ | `name` | `name` | `string | null` | `null` | Source string for the fallback initial (e.g. a display name or email) — first character, uppercased. |
27
+ | `size` | `size` | `number` | `32` | Diameter in CSS pixels. |
28
+
29
+ ## Events
30
+
31
+ _None._
32
+
33
+ ## Slots
34
+
35
+ _None._
36
+
37
+ ## CSS custom properties
38
+
39
+ | Custom property |
40
+ | --- |
41
+ | `--ui-font` |
42
+ | `--ui-primary` |
package/llms.txt CHANGED
@@ -234,6 +234,62 @@ Example:
234
234
  </script>
235
235
  ```
236
236
 
237
+ ## <radio-cards>
238
+
239
+ Single-select group of full-width cards, each with a label and optional
240
+ description — for a handful of meaningfully different choices where the
241
+ description matters. For many short, same-shaped options (a color swatch,
242
+ a basemap style), use `radio-pills` instead. Wraps native radio inputs for
243
+ keyboard/a11y and fires `change` rather than relying on form submission.
244
+
245
+ Import: `import "@f-ewald/components/radio-cards.js";`
246
+
247
+ Properties: `options` (JS property only) : RadioCardOption[], default []; `value` (attribute `value`) : string, default ""
248
+ Events: `change`
249
+ CSS custom properties: `--ui-border`, `--ui-font`, `--ui-font-size-sm`, `--ui-primary`, `--ui-radius-sm`, `--ui-surface-muted`, `--ui-text`, `--ui-text-muted`
250
+
251
+ Example:
252
+ ```html
253
+ <radio-cards></radio-cards>
254
+ <script type="module">
255
+ const el = document.querySelector("radio-cards");
256
+ el.options = [
257
+ { value: "simple", label: "Simple", description: "Quick-ranking view" },
258
+ { value: "detailed", label: "Detailed", description: "Every section and layer" },
259
+ ];
260
+ el.value = "simple";
261
+ el.addEventListener("change", (e) => console.log(e.detail.value));
262
+ </script>
263
+ ```
264
+
265
+ ## <radio-pills>
266
+
267
+ Single-select group of compact pill-shaped options — for many short,
268
+ same-shaped choices (a basemap style, a unit toggle). For a handful of
269
+ choices where a description matters, use `radio-cards` instead. Wraps
270
+ native radio inputs for keyboard/a11y and fires `change` rather than
271
+ relying on form submission.
272
+
273
+ Import: `import "@f-ewald/components/radio-pills.js";`
274
+
275
+ Properties: `options` (JS property only) : RadioPillOption[], default []; `value` (attribute `value`) : string, default ""
276
+ Events: `change`
277
+ CSS custom properties: `--ui-border`, `--ui-font`, `--ui-font-size-sm`, `--ui-primary`, `--ui-surface-muted`, `--ui-text`
278
+
279
+ Example:
280
+ ```html
281
+ <radio-pills></radio-pills>
282
+ <script type="module">
283
+ const el = document.querySelector("radio-pills");
284
+ el.options = [
285
+ { value: "light", label: "Light" },
286
+ { value: "streets", label: "Streets" },
287
+ ];
288
+ el.value = "light";
289
+ el.addEventListener("change", (e) => console.log(e.detail.value));
290
+ </script>
291
+ ```
292
+
237
293
  ## <relative-time>
238
294
 
239
295
  Inline relative-time display (e.g. "3 hours ago"). Accepts either a
@@ -333,6 +389,56 @@ Example:
333
389
  </script>
334
390
  ```
335
391
 
392
+ ## <ui-button>
393
+
394
+ Button (or link styled as one) with an optional leading icon, in three
395
+ visual weights. Set `href` to render an `<a>` instead of a `<button>` —
396
+ same styling either way — for cross-page navigation that should look like
397
+ an action button; a disabled/busy link stays a real `<a>` with
398
+ `aria-disabled` + `pointer-events: none` rather than losing its href.
399
+ Put the icon in the `icon` slot and the label in the default slot.
400
+
401
+ Form-associated (`type="submit"`/`"reset"`): the actual `<button>` lives in
402
+ this element's shadow root, which native HTML form association does not
403
+ cross into from an ancestor light-DOM `<form>`. `type="submit"`/`"reset"`
404
+ is instead wired through `ElementInternals.form` — the same mechanism
405
+ `address-autocomplete` uses to associate with an ancestor form.
406
+
407
+ Import: `import "@f-ewald/components/ui-button.js";`
408
+
409
+ Properties: `variant` (attribute `variant`) : ButtonVariant, default "primary"; `href` (attribute `href`) : string | null, default null; `type` (attribute `type`) : "button" | "submit" | "reset", default "button"; `disabled` (attribute `disabled`) : boolean, default false; `busy` (attribute `busy`) : boolean, default false
410
+ Events: none
411
+ CSS custom properties: `--ui-border`, `--ui-danger`, `--ui-danger-hover`, `--ui-font`, `--ui-font-size-sm`, `--ui-primary`, `--ui-primary-hover`, `--ui-radius-sm`, `--ui-text`, `--ui-text-muted`
412
+
413
+ Example:
414
+ ```html
415
+ <ui-button variant="primary">
416
+ <span slot="icon">...</span>
417
+ New property
418
+ </ui-button>
419
+ <ui-button variant="danger">Delete</ui-button>
420
+ <ui-button variant="secondary" href="/properties?edit=42">Edit</ui-button>
421
+ ```
422
+
423
+ ## <user-avatar>
424
+
425
+ Circular avatar. Shows `src` when it loads successfully; falls back to the
426
+ first letter of `name` (uppercased) if `src` is unset or fails to load
427
+ (e.g. an expired OAuth profile-photo URL); falls back further to a generic
428
+ person icon if `name` is also unset. A broken image never leaves a blank
429
+ circle.
430
+
431
+ Import: `import "@f-ewald/components/user-avatar.js";`
432
+
433
+ Properties: `src` (attribute `src`) : string | null, default null; `name` (attribute `name`) : string | null, default null; `size` (attribute `size`) : number, default 32
434
+ Events: none
435
+ CSS custom properties: `--ui-font`, `--ui-primary`
436
+
437
+ Example:
438
+ ```html
439
+ <user-avatar src="https://example.com/photo.jpg" name="Freddy" size="40"></user-avatar>
440
+ ```
441
+
336
442
  ## <weight-bar-chart>
337
443
 
338
444
  Sorted horizontal bar chart of labeled weights (normalized fractions
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@f-ewald/components",
3
3
  "private": false,
4
- "version": "0.1.0",
4
+ "version": "0.2.1",
5
5
  "description": "A collection of universally usable web components for various tasks.",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",