@instacks/peak 1.3.2 → 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
@@ -236,7 +236,8 @@ Code blocks that scroll get a shade along each edge with more code beyond it (CS
236
236
 
237
237
  Text colors: `.peak-text-primary`, `-secondary`, `-contrast`, `-muted`, `-success`, `-danger`,
238
238
  `-info`. Alignment by writing direction: `.peak-text-start`, `-center`, `-end`; margin resets
239
- `.peak-mt-0` and `.peak-mb-0`. Headings get balanced line breaks, letter-spacing from `--peak-heading-tracking` (h1 4/3
239
+ `.peak-mt-0` and `.peak-mb-0`; image fit `.peak-fit-cover` / `.peak-fit-contain` in a box of
240
+ `--peak-ratio`. Headings get balanced line breaks, letter-spacing from `--peak-heading-tracking` (h1 4/3
240
241
  of it, `.peak-display` 5/3) and Blades' per-level line heights around `--peak-heading-line-height`.
241
242
  Optional weights for h1 (`--peak-display-weight`), h4–h6 (`--peak-subheading-font-weight`) and
242
243
  buttons (`--peak-button-font-weight`) fall back to the heading or body weight while unset.
@@ -282,9 +283,12 @@ All of these work without JavaScript.
282
283
  <aside><nav class="peak-sidebar-nav"><ul><li><a aria-current="page">…</a></li></ul></nav></aside>
283
284
  ```
284
285
 
285
- 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`)
286
287
  remembers a `<select class="peak-scheme">` light/dark choice across pages. Load it in `<head>`
287
- 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.
288
292
 
289
293
  ## Accessibility preferences
290
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;
@@ -5541,6 +5553,20 @@
5541
5553
  }
5542
5554
  }
5543
5555
 
5556
+ .peak-fit-cover, .peak-fit-contain {
5557
+ aspect-ratio: var(--peak-ratio, auto);
5558
+ object-position: center;
5559
+ block-size: auto;
5560
+ }
5561
+
5562
+ .peak-fit-cover {
5563
+ object-fit: cover;
5564
+ }
5565
+
5566
+ .peak-fit-contain {
5567
+ object-fit: contain;
5568
+ }
5569
+
5544
5570
  .peak-visually-hidden:not(:focus-within) {
5545
5571
  clip-path: inset(50%);
5546
5572
  white-space: nowrap;