staffa 0.13.0 → 0.15.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.
@@ -37,8 +37,10 @@ A.insertGlobalCss({
37
37
  */
38
38
  export function select(opts: SelectOptions): void {
39
39
  drawField(opts, (id, isInvalid) => {
40
- A("div.s-select_wrap", opts.inputAttrs, () => {
41
- A("select.s-input", () => {
40
+ A("div.s-select_wrap", () => {
41
+ // On the <select> itself, like every other field control — an
42
+ // aria-label on the wrapper div would label nothing.
43
+ A("select.s-input", opts.inputAttrs, () => {
42
44
  applyControlAttrs(opts, id, isInvalid);
43
45
 
44
46
  A("change=", (e: Event) => {
@@ -144,8 +144,9 @@ export function revealInStrip(el: HTMLElement): void {
144
144
  // revealed item from sitting right against one.
145
145
  const pad = parseFloat(getComputedStyle(row).fontSize) * 2.6;
146
146
  const box = el.getBoundingClientRect(), strip = row.getBoundingClientRect();
147
- if (box.left < strip.left + pad) row.scrollBy({ left: box.left - strip.left - pad, behavior: "smooth" });
148
- else if (box.right > strip.right - pad) row.scrollBy({ left: box.right - strip.right + pad, behavior: "smooth" });
147
+ const left = box.left - strip.left, right = box.right - strip.right;
148
+ if (left < pad) row.scrollBy({ left: left - pad, behavior: "smooth" });
149
+ else if (right > -pad) row.scrollBy({ left: right + pad, behavior: "smooth" });
149
150
  }
150
151
 
151
152
  /**
@@ -96,7 +96,8 @@ mountPortal(() => {
96
96
 
97
97
  requestAnimationFrame(() => {
98
98
  if (!document.body.contains(tipEl)) return;
99
- const { x, y } = computePos(anchor.getBoundingClientRect(), tipEl.offsetWidth, tipEl.offsetHeight, placement);
99
+ const rect = anchor.getBoundingClientRect();
100
+ const { x, y } = computePos(rect, tipEl.offsetWidth, tipEl.offsetHeight, placement);
100
101
  tipEl.style.left = x + "px";
101
102
  tipEl.style.top = y + "px";
102
103
  tipEl.style.visibility = "";
package/src/index.ts CHANGED
@@ -41,7 +41,7 @@ export { buttonGroup, type ButtonGroupOptions } from "./components/buttonGroup.j
41
41
  export { checkbox, type CheckboxOptions } from "./components/checkbox.js";
42
42
  export { form, type FormOptions } from "./components/form.js";
43
43
  export { main, closeNav, type MainOptions } from "./components/main.js";
44
- export { type PanelStack, type Panel, type Routes, type RouteHandler, type RouteTable, type AncestorsHandler, type AncestorTable, type PathParams, type SegParams } from "./components/panels.js";
44
+ export { type PanelStack, type Panel, type PanelSize, type Routes, type RouteHandler, type RouteTable, type AncestorsHandler, type AncestorTable, type PathParams, type SegParams } from "./components/panels.js";
45
45
  export { menu, menuButton, showFloatingMenu, addContextMenu, isFloatingMenuOpen, closeFloatingMenu, type MenuListOptions, type MenuOptions, type MenuEntry, type MenuItem, type MenuSeparator, type FloatingMenuOptions, type ContextMenuOptions } from "./components/menu.js";
46
46
  export { dialog, alert, confirm, prompt, isDialogOpen, type DialogOptions } from "./components/dialog.js";
47
47
  export { select, type SelectOptions, type SelectOptionInput } from "./components/select.js";
package/src/theme.ts CHANGED
@@ -59,16 +59,31 @@ import A from "aberdeen";
59
59
  */
60
60
 
61
61
  /**
62
- * The surface sheen: the subtle single-colour wash every surface (and the page)
63
- * is painted with, as a `background:` declaration. A shared constant rather
64
- * than a CSS custom property, deliberately: `var()`s inside a custom property
65
- * resolve where the property is *defined*, so a `--s-sheen` at `:root` would
66
- * paint every surface with the page's wash instead of its own `$s-bg`'s. Also
67
- * used by panels.ts, where the routed columns have to visually *be* the
68
- * surface around them.
62
+ * The subtle single-colour wash a surface is painted with, as a `background:`
63
+ * declaration, at the given angle. Shared constants rather than a CSS custom
64
+ * property, deliberately: `var()`s inside a custom property resolve where the
65
+ * property is *defined*, so a `--s-sheen` at `:root` would paint every surface
66
+ * with the page's wash instead of its own `$s-bg`'s.
69
67
  */
70
- export const SURFACE_SHEEN =
71
- "background: linear-gradient(170deg, color-mix(in oklab, $s-bg, white 9%), color-mix(in oklab, $s-bg, black 9%));";
68
+ const sheen = (angle: string) =>
69
+ `background: linear-gradient(${angle}, color-mix(in oklab, $s-bg, white 9%), color-mix(in oklab, $s-bg, black 9%));`;
70
+
71
+ /** The surface sheen: the wash every surface (and the page) is painted with. */
72
+ export const SURFACE_SHEEN = sheen("170deg");
73
+
74
+ /**
75
+ * The same wash, straight down — for panels.ts, where the routed columns and
76
+ * the ground beside them have to look like one continuous surface.
77
+ *
78
+ * A gradient at an angle takes its extent from the box's *width* as well as its
79
+ * height, so a 430px column and the 1720px region behind it would paint
80
+ * different slices of the same wash and meet at a visible step. Straight down,
81
+ * the extent is the height alone — which every column shares exactly with the
82
+ * region (a column is `top:0 bottom:0` in it) and so with every other column.
83
+ * The 10° of tilt is worth losing there; it buys the one place in the app where
84
+ * boxes of *different widths* must be seamless.
85
+ */
86
+ export const PANEL_SHEEN = sheen("180deg");
72
87
 
73
88
  const STORAGE_KEY = "staffa:darkMode";
74
89