@instacks/peak 1.4.0 → 1.5.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.
package/README.md CHANGED
@@ -283,9 +283,12 @@ All of these work without JavaScript.
283
283
  <aside><nav class="peak-sidebar-nav"><ul><li><a aria-current="page">…</a></li></ul></nav></aside>
284
284
  ```
285
285
 
286
- One script ships for the one thing CSS can't do: `@instacks/peak/scheme` (`dist/peak-scheme.js`)
286
+ Two small scripts ship for what CSS can't do. `@instacks/peak/scheme` (`dist/peak-scheme.js`)
287
287
  remembers a `<select class="peak-scheme">` light/dark choice across pages. Load it in `<head>`
288
- without `defer`; the select works for the current page without it.
288
+ without `defer`; the select works for the current page without it. `@instacks/peak/commands`
289
+ (`dist/peak-commands.js`) makes `command`/`commandfor` buttons and `closedby="any"` work in
290
+ browsers that don't have them yet (they arrived in 2025); where the browser has them it does
291
+ nothing.
289
292
 
290
293
  ## Accessibility preferences
291
294
 
@@ -0,0 +1,34 @@
1
+ /*!
2
+ * peak-commands.js: command/commandfor and closedby="any" for browsers that don't have them yet
3
+ * (docs: site/pages/dialogs.html).
4
+ *
5
+ * Peak's dialogs and drawers open and close with attributes only (Invoker Commands,
6
+ * <button command="show-modal" commandfor="id">), which reached the major browsers during 2025,
7
+ * after Peak's browser baseline. Load this anywhere on the page (defer is fine) to make those
8
+ * buttons work in older browsers too. Where the browser has both features it does nothing.
9
+ */
10
+ (() => {
11
+ if (!("command" in HTMLButtonElement.prototype)) {
12
+ document.addEventListener("click", (event) => {
13
+ const button = event.target.closest?.("button[commandfor]");
14
+ if (!button) return;
15
+ const target = document.getElementById(button.getAttribute("commandfor"));
16
+ const command = button.getAttribute("command");
17
+ if (!target) return;
18
+ if (command === "show-modal") target.showModal();
19
+ else if (command === "close") target.close(button.value || undefined);
20
+ else if (command === "request-close") (target.requestClose ?? target.close).call(target);
21
+ else if (command === "toggle-popover") target.togglePopover();
22
+ else if (command === "show-popover") target.showPopover();
23
+ else if (command === "hide-popover") target.hidePopover();
24
+ });
25
+ }
26
+
27
+ // closedby="any": a click on the dialog's own box outside its content (the backdrop) closes it
28
+ if (typeof HTMLDialogElement !== "undefined" && !("closedBy" in HTMLDialogElement.prototype)) {
29
+ document.addEventListener("click", (event) => {
30
+ const dialog = event.target;
31
+ if (dialog instanceof HTMLDialogElement && dialog.open && dialog.getAttribute("closedby") === "any") dialog.close();
32
+ });
33
+ }
34
+ })();
package/dist/peak.css CHANGED
@@ -3939,6 +3939,10 @@
3939
3939
  min-inline-size: 60%;
3940
3940
  }
3941
3941
 
3942
+ .peak-with-sidebar.end > :is(aside, .peak-sidebar), .peak-with-sidebar.end > .out:has( > .peak-sidebar) {
3943
+ order: 1;
3944
+ }
3945
+
3942
3946
  @container peak-sidebar (width >= 45rem) {
3943
3947
  .peak-with-sidebar.sticky > :is(aside, .peak-sidebar), .peak-with-sidebar.sticky > .out:has( > .peak-sidebar) {
3944
3948
  align-self: start;
@@ -3974,6 +3978,10 @@
3974
3978
  align-items: center;
3975
3979
  }
3976
3980
 
3981
+ .peak-media.end > :first-child {
3982
+ order: 1;
3983
+ }
3984
+
3977
3985
  .peak-switcher {
3978
3986
  gap: var(--peak-gap, var(--pico-spacing));
3979
3987
  flex-wrap: wrap;
@@ -4080,6 +4088,10 @@
4080
4088
  margin-block-start: var(--pico-typography-spacing-vertical) !important;
4081
4089
  }
4082
4090
 
4091
+ :is(.peak-callout, .peak-accordion > details, [popover], .site-footer, :scope.site-footer) > .out:last-child > .stacks_in > :last-child {
4092
+ margin-block-end: 0;
4093
+ }
4094
+
4083
4095
  @media (width < 576px) {
4084
4096
  .stacks_in.peak-hide-below-sm {
4085
4097
  display: none !important;