actual-css 0.20.2 → 0.21.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 (80) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +6 -6
  3. package/components.json +19 -4
  4. package/dist/actual.full.css +451 -118
  5. package/dist/actual.full.js +2 -2
  6. package/dist/actual.full.min.css +1 -1
  7. package/dist/types/data-flag.d.ts +1 -0
  8. package/dist/types/enhancement-loader-state.d.ts +6 -0
  9. package/dist/types/enhancement-loader.d.ts +0 -2
  10. package/dist/types/parse-config.d.ts +0 -1
  11. package/dist/types/popover-transport.d.ts +2 -0
  12. package/dist/types/status.d.ts +0 -1
  13. package/dist/types/validation.d.ts +6 -2
  14. package/docs/pages/components/app-navigation.md +67 -0
  15. package/docs/pages/components/button.md +3 -0
  16. package/docs/pages/components/dialog.md +3 -0
  17. package/docs/pages/components/list.md +13 -0
  18. package/docs/pages/components/segmented.md +7 -4
  19. package/docs/pages/components/table.md +4 -1
  20. package/docs/pages/enhancements/flyout.md +12 -3
  21. package/docs/pages/enhancements/tooltip.md +1 -0
  22. package/docs/pages/examples/overview.md +29 -1
  23. package/docs/pages/forms/combobox.md +10 -8
  24. package/docs/pages/forms/labels.md +7 -0
  25. package/docs/pages/forms/overview.md +13 -10
  26. package/docs/pages/forms/validation.md +3 -3
  27. package/docs/pages/foundations/philosophy.md +26 -0
  28. package/docs/pages/foundations/theming.md +80 -7
  29. package/docs/pages/foundations/tokens.md +39 -2
  30. package/docs/pages/guides/coding-agents.md +11 -0
  31. package/docs/pages/guides/introduction.md +1 -1
  32. package/docs/pages/guides/progressive-enhancement.md +88 -20
  33. package/docs/pages/guides/tailwind.md +12 -6
  34. package/docs/pages/guides/upgrading.md +52 -0
  35. package/docs/pages/layout/app-layout.md +50 -1
  36. package/docs/pages/patterns/empty-state.md +48 -10
  37. package/forms.json +325 -0
  38. package/llms.txt +2 -1
  39. package/package.json +3 -1
  40. package/reserved-classes.json +1 -0
  41. package/skills/actual-css/SKILL.md +1 -1
  42. package/skills/actual-css/references/api-and-vocabulary.md +2 -1
  43. package/src/cli/actual-css.js +8 -2
  44. package/src/css/components/app-nav.css +75 -18
  45. package/src/css/components/badge.css +7 -1
  46. package/src/css/components/button.css +20 -3
  47. package/src/css/components/flyout.css +5 -2
  48. package/src/css/components/list.css +28 -13
  49. package/src/css/components/menu.css +18 -0
  50. package/src/css/components/meter.css +4 -0
  51. package/src/css/components/progress.css +9 -2
  52. package/src/css/components/segmented.css +22 -12
  53. package/src/css/components/table.css +21 -2
  54. package/src/css/core/theme.css +11 -1
  55. package/src/css/core/tokens.css +16 -2
  56. package/src/css/forms/choice-card.css +4 -3
  57. package/src/css/forms/choice.css +28 -16
  58. package/src/css/forms/control.css +23 -16
  59. package/src/css/forms/custom-select.css +3 -1
  60. package/src/css/forms/form.css +8 -5
  61. package/src/css/forms/otp.css +2 -1
  62. package/src/css/forms/range.css +20 -6
  63. package/src/css/forms/select.css +12 -4
  64. package/src/css/forms/switch.css +11 -5
  65. package/src/css/layout/app-layout.css +104 -5
  66. package/src/js/data-flag.js +4 -0
  67. package/src/js/dialog.js +5 -8
  68. package/src/js/enhancement-loader-state.js +7 -0
  69. package/src/js/enhancement-loader.js +4 -21
  70. package/src/js/keys.js +5 -7
  71. package/src/js/parse-config.js +0 -2
  72. package/src/js/popover-transport.js +18 -0
  73. package/src/js/status.js +0 -2
  74. package/src/js/surface.js +35 -41
  75. package/src/js/tooltip.js +8 -36
  76. package/src/js/validation.js +24 -10
  77. package/src/tooling/css-bundle.js +5 -0
  78. package/src/tooling/design-tokens.js +8 -1
  79. package/src/tooling/theme-contrast.js +45 -17
  80. package/tokens.json +4 -0
@@ -139,6 +139,17 @@ it.
139
139
  A polished interface is not necessarily a finished design. Before polishing,
140
140
  strip the ornaments mentally and ask what the page actually says.
141
141
 
142
+ ## Prefer derived presentation
143
+
144
+ Before adding a JavaScript-managed class, data attribute or listener, check
145
+ whether native HTML, ARIA or an existing application attribute already exposes
146
+ the state. Use a local, readable CSS selector for the visual change. Reach for
147
+ intrinsic layouts or container queries when the change depends on available
148
+ space. Keep data updates, accessible state and focus management with the code
149
+ that owns the interaction.
150
+
151
+ See [Derive presentation from the state your HTML already exposes](../foundations/philosophy.md#derive-presentation-from-the-state-your-html-already-exposes).
152
+
142
153
  ## With a design skill
143
154
 
144
155
  A design skill and the Actual skill do not overlap. The design skill owns the
@@ -52,7 +52,7 @@ optimizing — the bare `actual-css` entrypoint and `actual-css/full` both resol
52
52
  to the complete compiled framework:
53
53
 
54
54
  ```html
55
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/actual-css@0.20/dist/actual.full.min.css">
55
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/actual-css@0.21/dist/actual.full.min.css">
56
56
  ```
57
57
 
58
58
  The package does not maintain separate partial bundles. Modular entrypoints map
@@ -183,7 +183,13 @@ published in `package.json#exports`:
183
183
  | `actual-css/js/menu` | Menu keyboard/click wiring, item vocabulary |
184
184
  | `actual-css/js/surface` | Surface lifecycle (`openSurface`, `closeSurface`, …) |
185
185
 
186
- The exports map is explicit — it *is* the statement of what is public.
186
+ Import from the JavaScript subpaths in `package.json#exports`. The symbols
187
+ exported by those entry points are the public API, including the helpers used
188
+ to compose widgets. Import a component entry point directly to run its setup
189
+ when it has no exports.
190
+
191
+ Use `parseConfig` from `actual-css/js/parse-config` to read
192
+ [declarative configuration](#declarative-configuration) in custom enhancements.
187
193
 
188
194
  ## Floating contract
189
195
 
@@ -572,23 +578,27 @@ export async function prepare({ resolve, loadStyle }) {
572
578
  await loadStyle(resolve("./autosubmit.css"));
573
579
  }
574
580
 
575
- export default function autosubmit(form, { config, signal, emit }) {
576
- const max = config.max ?? 3; // from data-enhance-config
581
+ export default function autosubmit(form, { config, signal }) {
582
+ const delay = config.delay ?? 200;
583
+ let timer;
577
584
 
578
- form.addEventListener("change", () => form.requestSubmit(), { signal });
585
+ form.addEventListener("change", () => {
586
+ clearTimeout(timer);
587
+ timer = setTimeout(() => form.requestSubmit(), delay);
588
+ }, { signal });
589
+ return () => clearTimeout(timer);
579
590
  }
580
591
  ```
581
592
 
582
593
  ```html
583
- <form data-enhance="autosubmit"
584
- data-enhance-config='{ "max": 3 }'>
594
+ <form data-enhance="autosubmit" data-enhance-config="delay:200">…</form>
585
595
  ```
586
596
 
587
- `data-enhance-config` is parsed with `parseConfig`: strict JSON first, with a
588
- tiny relaxed subset (unquoted keys, single-quoted strings) as a fallback. The
589
- connect function receives the element plus `{ config, signal, emit }`; `emit`
590
- dispatches `actual:<name>:<type>` events. Connect must be synchronous and may
591
- return a cleanup function or nothing; the loader owns the AbortController.
597
+ The connect function receives the element plus `{ config, signal, emit }`.
598
+ The loader reads `config` from [`data-enhance-config`](#declarative-configuration)
599
+ and owns the AbortController. Call `emit` to dispatch
600
+ `actual:<name>:<type>` events. Connect must be synchronous and may return
601
+ a cleanup function.
592
602
 
593
603
  #### Without a build
594
604
 
@@ -603,7 +613,7 @@ imports and registers it, on the same lifecycle as the built-in behaviors.
603
613
  </script>
604
614
  <script src="/dist/actual.full.js" defer></script>
605
615
 
606
- <form data-enhance="autosubmit">…</form>
616
+ <form data-enhance="autosubmit" data-enhance-config="delay:350">…</form>
607
617
  ```
608
618
 
609
619
  `/js/autosubmit.js` is an ES module with the default export shown above; no
@@ -614,8 +624,62 @@ connects. A behavior that owns its own attribute instead of a
614
624
 
615
625
  `loadScript(url)` and `loadStyle(url)` are public helpers for non-ESM assets.
616
626
  Names are reserved once per manifest set — redeclaring a name from a different
617
- URL throws, and duplicate declarations share one import promise. The
618
- `__`-prefixed exports are test hooks, not public API.
627
+ URL throws, and duplicate declarations share one import promise.
628
+
629
+ ## Declarative configuration
630
+
631
+ For hand-written HTML, use comma-separated `key:value` pairs. The outer
632
+ braces are optional.
633
+
634
+ ```html
635
+ <div data-config="delay:200,wrap:true"></div>
636
+ ```
637
+
638
+ The manifest loader reads `data-enhance-config` automatically. In a custom
639
+ enhancement, choose an attribute and import the `parseConfig` primitive from
640
+ `actual-css/js/parse-config`. Here, `data-config` is an application attribute.
641
+
642
+ ```js
643
+ import { parseConfig } from "actual-css/js/parse-config";
644
+
645
+ const config = parseConfig(element.getAttribute("data-config"));
646
+ // { delay: 200, wrap: true }
647
+ ```
648
+
649
+ Strict JSON objects work in the same attribute, including output from
650
+ `JSON.stringify()`. The parser tries strict JSON first and falls back to the
651
+ compact syntax if JSON parsing fails.
652
+
653
+ ```html
654
+ <div data-config='{"delay":200,"wrap":true}'></div>
655
+ ```
656
+
657
+ ### Supported syntax
658
+
659
+ - Separate pairs with commas and keys from values with a colon. Whitespace
660
+ around tokens is allowed. Nested objects require braces and arrays require
661
+ brackets. Both may contain compact objects and quoted strings.
662
+ - Unquoted keys match `[A-Za-z_$][A-Za-z0-9_$-]*`. Quote other keys with
663
+ single or double quotes.
664
+ - Values are quoted strings, JSON numbers (including decimals and exponents),
665
+ `true`, `false`, `null`, objects, or arrays. Quote text values such as
666
+ `placement:'bottom'`.
667
+ - Double-quoted strings use JSON escaping. In single-quoted strings, use
668
+ `\'` for an apostrophe, write double quotes literally, and use JSON escapes
669
+ such as `\n` and `\t` for control characters. In HTML, escape any quote
670
+ that matches the attribute delimiter as `&quot;` or `&#39;`.
671
+
672
+ ### Errors and defaults
673
+
674
+ `parseConfig()` returns an empty object for missing, blank, or non-string
675
+ input. The result of parsing a string must be an object. Valid JSON with
676
+ an array, scalar, or `null` at the root throws `TypeError`. Malformed input
677
+ throws `SyntaxError`, including trailing commas, bare text values, comments,
678
+ and unfinished strings.
679
+
680
+ Use the result to apply your enhancement's defaults and validate its option
681
+ values. If parsing throws during enhancer setup, the runtime logs the error
682
+ and skips setup for that element.
619
683
 
620
684
  ## Lifecycle rules
621
685
 
@@ -688,12 +752,14 @@ Actual's built-in filters.
688
752
  ```js
689
753
  import enhance from "actual-css/js/enhance";
690
754
  import { dispatchInput, onTextInput, selectionStart, setCaret } from "actual-css/js/input";
755
+ import { parseConfig } from "actual-css/js/parse-config";
691
756
 
692
757
  const filters = {
693
- currency(value) {
758
+ currency(value, precision) {
694
759
  const normalized = value.replace(/,/g, ".");
695
760
  const [whole, decimals = ""] = normalized.replace(/[^0-9.]/g, "").split(".");
696
- return decimals ? `${whole}.${decimals.slice(0, 2)}` : whole;
761
+ const fraction = decimals.slice(0, precision);
762
+ return fraction ? `${whole}.${fraction}` : whole;
697
763
  },
698
764
  time(value) {
699
765
  const digits = value.replace(/\D/g, "").slice(0, 4);
@@ -703,8 +769,10 @@ const filters = {
703
769
 
704
770
  enhance({
705
771
  "input[data-app-filter]": (input) => {
706
- const filter = filters[input.dataset.appFilter];
707
- if (!filter) return;
772
+ const { kind, precision } = parseConfig(input.dataset.appFilter);
773
+ if (typeof kind !== "string" || !Object.hasOwn(filters, kind)) return;
774
+ const digits = Number.isInteger(precision) && precision >= 0 ? precision : 2;
775
+ const filter = (value) => filters[kind](value, digits);
708
776
 
709
777
  const controller = new AbortController();
710
778
  let filtering = false;
@@ -734,8 +802,8 @@ enhance({
734
802
  ```
735
803
 
736
804
  ```html
737
- <input class="input" inputmode="decimal" data-app-filter="currency" autocomplete="off" />
738
- <input class="input" inputmode="numeric" data-app-filter="time" autocomplete="off" />
805
+ <input class="input" inputmode="decimal" data-app-filter="kind:'currency',precision:3" autocomplete="off" />
806
+ <input class="input" inputmode="numeric" data-app-filter="kind:'time'" autocomplete="off" />
739
807
  ```
740
808
 
741
809
  ## Textarea autogrow
@@ -166,7 +166,7 @@ consider whether the real requirement is simply “create another column wheneve
166
166
 
167
167
  This removes viewport breakpoint choreography entirely.
168
168
 
169
- ## Prefer intrinsic behavior over translating breakpoints
169
+ ## Context-aware components
170
170
 
171
171
  Tailwind allows almost every utility to be changed independently at a breakpoint:
172
172
 
@@ -186,7 +186,11 @@ If the requirement is:
186
186
 
187
187
  > Show these items horizontally when there is enough room, otherwise stack them.
188
188
 
189
- use a layout primitive such as `.switcher`.
189
+ use a layout primitive such as [`.switcher`](../layout/switcher.md). For cards
190
+ that reflow as space permits, use [`.grid`](../layout/grid.md). When a component
191
+ needs a specific width threshold, query its container in application CSS.
192
+ Actual's fixed-count grids and Steps can also read the shared
193
+ [`actual-container` context](../layout/grid.md#balanced-subdivision).
190
194
 
191
195
  If the requirement truly is:
192
196
 
@@ -312,7 +316,7 @@ Otherwise write the declaration normally.
312
316
 
313
317
  This is one of the largest mechanical differences for Tailwind-heavy applications.
314
318
 
315
- ## State variants move into component behavior or CSS
319
+ ## State-aware components
316
320
 
317
321
  Tailwind can keep highly specific state rules in markup:
318
322
 
@@ -342,9 +346,11 @@ For application-specific state styling, keep the semantic attribute and style it
342
346
  }
343
347
  ```
344
348
 
345
- The same applies to Tailwind's `group-*`, `peer-*`, arbitrary selector, and complex `data-*` variants.
346
-
347
- Do not invent an Actual variant grammar to replace them.
349
+ Apply the same approach to `group-*`, `peer-*`, `has-*` and arbitrary selector
350
+ variants. For example, the [Tasks workspace](../../demo/templates/tasks.html)
351
+ uses `:has(.task-check .check:checked)` on a named row so every instance shares
352
+ the completed style in one rule. See [the state principle](../foundations/philosophy.md#derive-presentation-from-the-state-your-html-already-exposes)
353
+ for the selector and the division of responsibilities.
348
354
 
349
355
  ## Colors and dark mode
350
356
 
@@ -7,6 +7,58 @@ sections in order when skipping a release.
7
7
 
8
8
  **Related terms:** migration, breaking changes, update, version.
9
9
 
10
+ ## 0.20 to 0.21
11
+
12
+ ### Field borders
13
+
14
+ `.input`, `.textarea`, `.select`, `.join-addon` and `.otp` cells rest on the
15
+ quiet `--border` edge, and on `--border-control` only under
16
+ `prefers-contrast: more`. On a fill identical to the surface, the quiet edge
17
+ does not meet the 3:1 of WCAG 1.4.11. To keep the strong edge everywhere:
18
+
19
+ ```css
20
+ :root {
21
+ --control-default-border: var(--border-control);
22
+ }
23
+ ```
24
+
25
+ [Theming](../foundations/theming.md) lists the other field treatments that
26
+ keep a 3:1 cue.
27
+
28
+ ### Button gradients
29
+
30
+ `.btn` paints `--btn-bg` with `background-color`. A gradient in `--ui-bg`,
31
+ `--btn-bg` or `--btn-default-bg` no longer renders: keep a color there and
32
+ move the image to `--finish`.
33
+
34
+ ### Named JavaScript exports
35
+
36
+ `actual-css/js/parse-config`, `actual-css/js/status` and
37
+ `actual-css/js/validation` have no default export:
38
+
39
+ ```js
40
+ import { parseConfig } from "actual-css/js/parse-config";
41
+ import { status } from "actual-css/js/status";
42
+ import { FormValidator } from "actual-css/js/validation";
43
+ ```
44
+
45
+ `nextItem()` from `actual-css/js/keys` stops at the first and last item. Pass
46
+ `{ wrap: true }` where focus should cycle.
47
+
48
+ ### App layout topbar
49
+
50
+ On wide screens, an `.app-layout` without an `.app-nav > header` lets its
51
+ `.topbar` span the side navigation. To keep the navigation at full height,
52
+ move the brand into an `.app-nav > header`.
53
+
54
+ ### Select
55
+
56
+ - A hovered `.select` no longer fills with `--surface-subtle`; set
57
+ `--control-hover-bg` to restore a hover fill on every field.
58
+ - The chevron sits `--select-icon-inset` from the edge, so the default
59
+ glyph's ink lines up with `--control-pad-x`. Set the offset for a
60
+ replacement `--icon-chevron` whose ink fills more or less of its box.
61
+
10
62
  ## 0.16 to 0.17
11
63
 
12
64
  ### Current nav link
@@ -8,6 +8,9 @@ Use `.app-layout` only when all three direct regions are intentional:
8
8
  - `.app-main` is the page's independent scroll container;
9
9
  - `.app-nav` changes from bottom navigation to labelled side navigation.
10
10
 
11
+ **Related terms:** app shell, workspace, inset shell, tab bar, bottom
12
+ navigation, side navigation, navigation rail, master-detail app.
13
+
11
14
  This is not a generic wrapper for a website, dashboard, or anything described
12
15
  as an "app." It fixes the shell to the dynamic viewport and hides overflow on
13
16
  that shell. A public, marketing, editorial, or normally scrolling page should
@@ -41,6 +44,28 @@ assigns those children to named grid areas and changes `.app-nav` from a bottom
41
44
  bar to labelled side navigation. Missing, renamed, or wrapped regions mean a
42
45
  different layout contract should be used.
43
46
 
47
+ ## Where the brand lives
48
+
49
+ From the side breakpoint, the brand's place decides who owns the top-left
50
+ corner:
51
+
52
+ - brand in the topbar, no `header` in `.app-nav`: the topbar is a global bar
53
+ over the navigation, for identity, global search, the account and other
54
+ application-wide context. Collapsing the rail leaves the brand untouched.
55
+ - brand in a side `.app-nav > header`: the navigation runs the full height,
56
+ the compact shape of a small standalone app.
57
+
58
+ No attribute chooses between them; adding or removing the `header` does. The
59
+ [Tasks template](../../demo/templates/tasks.html) switches between both from
60
+ its account menu.
61
+
62
+ The topbar earns its band with global actions, such as search or creation.
63
+ Without any, hide it from the side breakpoint (`@media (min-width: 48rem)`):
64
+ its row collapses, the side navigation's `header` carries the brand, and a
65
+ phone keeps the topbar, where that header is hidden. Size
66
+ `--app-layout-bar-size` to the main region's first row so the brand stays on
67
+ its line; the [Tasks template](../../demo/templates/tasks.html) does this.
68
+
44
69
  A direct-child `.fab` overlays the end of the main grid area. It therefore
45
70
  clears both bottom and side navigation without copying the navigation size or
46
71
  bottom safe-area inset. When navigation moves aside, the layout applies the
@@ -52,6 +77,30 @@ which avoids fixed-position offsets and keeps mobile keyboard resizing within
52
77
  the same layout contract. The topbar preserves its normal spacing below the
53
78
  top safe-area inset. The recipe provides no routing or page lifecycle.
54
79
 
55
- ### Hooks
80
+ The [Tasks template](../../demo/templates/tasks.html) composes it with a
81
+ master-detail workspace inset on the canvas: `.app-nav` drops its own surface,
82
+ and `.app-main` carries the raised one.
83
+
84
+ ## Rail
85
+
86
+ `data-nav="rail"` is a desktop preference for a captioned rail instead of labelled
87
+ side navigation. Below the side breakpoint both produce the same bottom bar.
88
+
89
+ ```html
90
+ <div class="app-layout" data-nav="rail">
91
+ ```
92
+
93
+ The layout only draws the rail. Toggling the attribute, labelling the toggle
94
+ and remembering the choice belong to the application; to use the rail on
95
+ tablets only, set the attribute from `matchMedia`. See
96
+ [App navigation](../components/app-navigation.md#rail) for what each tile shows.
97
+
98
+ ## Hooks
56
99
 
57
100
  - `--app-nav-side-size` controls the side navigation track.
101
+ - `--app-nav-rail-size` controls the rail track.
102
+ - `--app-layout-bar-size` is the top band shared by the topbar and the first
103
+ row of a side `.app-nav > header`, so the brand sits on the topbar's line and
104
+ the first destination starts level with the main region. Raise it when the
105
+ topbar holds taller content, or size it to the main region's first row when
106
+ the topbar is hidden on desktop.
@@ -37,22 +37,44 @@ For an icon on a tinted disc, compose an [icon slot](icon-slot.md).
37
37
 
38
38
  ## No results
39
39
 
40
- An empty search names the query and offers to clear it. Clearing removes the
41
- empty state and the button with it, so move focus back to the search field;
42
- otherwise it falls to the page.
40
+ Filter the list with `hidden` and announce the result count in a persistent
41
+ `role="status"` region. CSS shows the empty state when no list item is visible.
42
+ Browsers without `:has()` still show the count, including zero. When clearing
43
+ the search from the empty state, return focus to the field before the button
44
+ disappears. Try searching for “zebra”.
43
45
 
44
46
  ```html demo
47
+ <style>
48
+ #member-empty {
49
+ display: none;
50
+ }
51
+
52
+ #member-results:not(:has(> li:not([hidden]))) {
53
+ display: none;
54
+ }
55
+
56
+ #member-results:not(:has(> li:not([hidden]))) + #member-empty {
57
+ display: flex;
58
+ }
59
+ </style>
60
+
45
61
  <div class="stack">
46
62
  <div class="field">
47
63
  <label class="field-label" for="member-search">Search members</label>
48
- <input class="input" type="search" id="member-search" value="zebra">
64
+ <input class="input" type="search" id="member-search">
49
65
  </div>
50
66
 
51
- <section class="stack items-center text-center"
52
- id="no-results"
67
+ <p class="muted" id="member-count" role="status">3 members found.</p>
68
+ <ul class="list" id="member-results">
69
+ <li class="list-item">Alice Chen</li>
70
+ <li class="list-item">Bob Okafor</li>
71
+ <li class="list-item">Charlie Ruiz</li>
72
+ </ul>
73
+
74
+ <section class="stack items-center text-center" id="member-empty"
53
75
  aria-labelledby="no-results-title">
54
76
  <hgroup>
55
- <h3 id="no-results-title">No members match “zebra”</h3>
77
+ <h3 id="no-results-title">No matching members</h3>
56
78
  <p class="muted">Check the spelling, or clear the search to see everyone.</p>
57
79
  </hgroup>
58
80
  <button class="btn outline" type="button" id="clear-member-search">
@@ -61,14 +83,30 @@ otherwise it falls to the page.
61
83
  </section>
62
84
  </div>
63
85
 
64
- <script>
86
+ <script type="module">
65
87
  const search = document.getElementById("member-search");
66
- const noResults = document.getElementById("no-results");
88
+ const members = document.getElementById("member-results").children;
89
+ const count = document.getElementById("member-count");
67
90
 
91
+ function filterMembers() {
92
+ const query = search.value.trim().toLowerCase();
93
+ let matches = 0;
94
+
95
+ for (const member of members) {
96
+ member.hidden = !member.textContent.toLowerCase().includes(query);
97
+ if (!member.hidden) matches += 1;
98
+ }
99
+
100
+ count.textContent = `${matches} ${matches === 1 ? "member" : "members"} found.`;
101
+ }
102
+
103
+ search.addEventListener("input", filterMembers);
68
104
  document.getElementById("clear-member-search").addEventListener("click", () => {
69
105
  search.value = "";
70
- noResults.hidden = true;
71
106
  search.focus();
107
+ filterMembers();
72
108
  });
109
+
110
+ filterMembers();
73
111
  </script>
74
112
  ```