@sharadox/graphical-user-interface-web-library 0.2.0-development.25 → 0.2.0-development.29

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
@@ -112,6 +112,7 @@ everything below it: on the page, in one part of it, or on one piece.
112
112
  | `…/skeleton-value` | `SkeletonValue({ label?, width?, circle? })` | A shimmering shape for one value |
113
113
  | `…/copy-button` | `CopyButton({ value, label, copiedLabel, onCopied? })` | Copies a value and says so for two seconds |
114
114
  | `…/code-boxes` | `CodeBoxes({ label, digitLabel, ofLabel, name?, length?, onComplete? })` | One field box per digit of a one-time code |
115
+ | `…/navigation` | `Navigation({ brand, label, links, actions?, menuLabel, closeLabel, collapse? })` | The sticky bar, and a phone menu below `collapse` (960) |
115
116
 
116
117
  ### Box
117
118
 
@@ -0,0 +1,13 @@
1
+ import type { NavigationProperties } from "@sharadox/graphical-user-interface-web-library/navigation/type";
2
+ /**
3
+ * The site's bar, sticky at the top: the brand at its start, the links, and the actions at its end. Below `collapse`
4
+ * pixels wide the links and actions move into a phone menu, opened by a button: it covers the page under the bar,
5
+ * scrolls when it doesn't fit (a phone held sideways), keeps the page behind still, and closes on Escape, on anything
6
+ * tapped in it, and when the screen widens (`@sharadox/menu-web-library`). Links are transparent buttons; the current
7
+ * page's is foreground and marked `aria-current`.
8
+ *
9
+ * @example
10
+ * <Navigation brand={<Button href="/en" variant="inline">Name</Button>} label="Main" links={links} actions={<StyleSwitch … />} menuLabel="Open the menu" closeLabel="Close the menu" />
11
+ */
12
+ export declare function Navigation(properties: NavigationProperties): import("react").JSX.Element;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/navigation/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gEAAgE,CAAC;AAG3G;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,oBAAoB,+BA0E1D"}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useId } from "react";
4
+ import { classNames } from "@sharadox/web-library/class-name";
5
+ import { useMenu } from "@sharadox/menu-web-library/use-menu";
6
+ import { Box } from "@sharadox/graphical-user-interface-web-library/box";
7
+ import { Button } from "@sharadox/graphical-user-interface-web-library/button";
8
+ import { Wrapper } from "@sharadox/graphical-user-interface-web-library/wrapper";
9
+ import styles from "./index.module.css";
10
+ /**
11
+ * The site's bar, sticky at the top: the brand at its start, the links, and the actions at its end. Below `collapse`
12
+ * pixels wide the links and actions move into a phone menu, opened by a button: it covers the page under the bar,
13
+ * scrolls when it doesn't fit (a phone held sideways), keeps the page behind still, and closes on Escape, on anything
14
+ * tapped in it, and when the screen widens (`@sharadox/menu-web-library`). Links are transparent buttons; the current
15
+ * page's is foreground and marked `aria-current`.
16
+ *
17
+ * @example
18
+ * <Navigation brand={<Button href="/en" variant="inline">Name</Button>} label="Main" links={links} actions={<StyleSwitch … />} menuLabel="Open the menu" closeLabel="Close the menu" />
19
+ */
20
+ export function Navigation(properties) {
21
+ const { brand, label, links, actions, menuLabel, closeLabel, collapse = 960, className } = properties;
22
+ const id = useId();
23
+ const menu = useMenu({ wide: `(min-width: ${collapse}px)`, id });
24
+ const list = (direction) => links.map((link) => (_jsx(Button, { href: link.href, variant: "transparent", color: link.current ? "foreground" : "middleground", size: direction === "top-to-bottom" ? "large" : undefined, "aria-current": link.current ? "page" : undefined, className: direction === "top-to-bottom" ? styles.menuLink : undefined, children: link.label }, link.href)));
25
+ return (_jsxs(_Fragment, { children: [_jsxs(Wrapper, { as: "header", justify: "space-between", gap: 16, "data-collapse": collapse, className: classNames(styles.bar, className), ...menu.closer, children: [_jsx(Box, { justify: "start", className: styles.brand, children: brand }), _jsx(Box, { as: "nav", "aria-label": label, gap: 4, wrap: "wrap", className: styles.wide, children: list("left-to-right") }), actions !== undefined && (_jsx(Box, { gap: 8, wrap: "wrap", justify: "end", className: styles.wide, children: actions })), _jsx(Button, { ...menu.toggle, square: true, variant: "transparent", color: "foreground", icon: menu.open ? "close" : "menu", "aria-label": menu.open ? closeLabel : menuLabel, className: styles.toggle })] }), menu.open && (_jsxs(Box, { as: "nav", id: id, "aria-label": label, "data-lenis-prevent": "", direction: "top-to-bottom", align: "stretch", justify: "start", gap: 24, className: styles.menu, ...menu.closer, children: [_jsx(Box, { direction: "top-to-bottom", align: "stretch", gap: 4, children: list("top-to-bottom") }), actions !== undefined && (_jsx(Box, { "data-menu-actions": "", direction: "top-to-bottom", align: "start", gap: 12, children: actions }))] }))] }));
26
+ }
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/navigation/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,uDAAuD,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AAEjF,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,UAAgC;IACzD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,GAAG,GAAG,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC;IACtG,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,MAAM,IAAI,GAAG,OAAO,CAAC,EAAE,IAAI,EAAE,eAAe,QAAQ,KAA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C,SAAS,EAAE,MAAM,CAAC,IAAI,YAC1D,OAAO,GACJ,CACP,EACD,KAAC,MAAM,OACD,IAAI,CAAC,MAAM,EACf,MAAM,QACN,OAAO,EAAC,aAAa,EACrB,KAAK,EAAC,YAAY,EAClB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,gBACtB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EAC9C,SAAS,EAAE,MAAM,CAAC,MAAM,GACxB,IACM,EACT,IAAI,CAAC,IAAI,IAAI,CACZ,MAAC,GAAG,IACF,EAAE,EAAC,KAAK,EACR,EAAE,EAAE,EAAE,gBACM,KAAK,wBACE,EAAE,EACrB,SAAS,EAAC,eAAe,EACzB,KAAK,EAAC,SAAS,EACf,OAAO,EAAC,OAAO,EACf,GAAG,EAAE,EAAE,EACP,SAAS,EAAE,MAAM,CAAC,IAAI,KAClB,IAAI,CAAC,MAAM,aAEf,KAAC,GAAG,IAAC,SAAS,EAAC,eAAe,EAAC,KAAK,EAAC,SAAS,EAAC,GAAG,EAAE,CAAC,YAClD,IAAI,CAAC,eAAe,CAAC,GAClB,EACL,OAAO,KAAK,SAAS,IAAI,CACxB,KAAC,GAAG,yBAAmB,EAAE,EAAC,SAAS,EAAC,eAAe,EAAC,KAAK,EAAC,OAAO,EAAC,GAAG,EAAE,EAAE,YACtE,OAAO,GACJ,CACP,IACG,CACP,IACA,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ .bar{position:sticky;z-index:50;inset-block-start:0;min-block-size:var(--bar-height, 64px);padding-block:var(--scale-8);border-block-end:var(--line-thickness) var(--line-style) var(--foreground-border-color);background:rgb(var(--background-color-rgb)/80%);-webkit-backdrop-filter:blur(var(--glass-blur));backdrop-filter:blur(var(--glass-blur))}:where(.brand){flex:none}.menu{position:fixed;z-index:49;inset:var(--bar-height, 64px) 0 0;overflow-y:auto;padding:var(--scale-16) var(--wrapper-padding) var(--scale-32);background:var(--background-color);overscroll-behavior:contain;animation:open var(--duration) var(--easing)}.menuLink{justify-content:start}.toggle{display:none}@media(max-width: 639.98px){.bar[data-collapse="640"] .wide{display:none}.bar[data-collapse="640"] .toggle{display:inline-flex}}@media(max-width: 959.98px){.bar[data-collapse="960"] .wide{display:none}.bar[data-collapse="960"] .toggle{display:inline-flex}}@media(max-width: 1279.98px){.bar[data-collapse="1280"] .wide{display:none}.bar[data-collapse="1280"] .toggle{display:inline-flex}}@keyframes open{from{opacity:0;transform:translateY(calc(-1 * var(--scale-8)))}}@media(prefers-reduced-motion: reduce){.menu{animation:none}}
@@ -0,0 +1,64 @@
1
+ // The bar: sticky, see-through over the page (glass), a line under it. Plain classes, to beat the box's own values.
2
+ .bar {
3
+ position: sticky;
4
+ z-index: 50;
5
+ inset-block-start: 0;
6
+ min-block-size: var(--bar-height, 64px);
7
+ padding-block: var(--scale-8);
8
+ border-block-end: var(--line-thickness) var(--line-style) var(--foreground-border-color);
9
+ background: rgb(var(--background-color-rgb) / 80%);
10
+ -webkit-backdrop-filter: blur(var(--glass-blur));
11
+ backdrop-filter: blur(var(--glass-blur));
12
+ }
13
+
14
+ :where(.brand) {
15
+ flex: none;
16
+ }
17
+
18
+ // The phone menu: under the bar, over the whole page, scrolling when it doesn't fit.
19
+ .menu {
20
+ position: fixed;
21
+ z-index: 49;
22
+ inset: var(--bar-height, 64px) 0 0;
23
+ overflow-y: auto;
24
+ padding: var(--scale-16) var(--wrapper-padding) var(--scale-32);
25
+ background: var(--background-color);
26
+ overscroll-behavior: contain;
27
+ animation: open var(--duration) var(--easing);
28
+ }
29
+
30
+ .menuLink {
31
+ justify-content: start;
32
+ }
33
+
34
+ // Wide: links and actions in the bar, no menu button. Narrow: only the brand and the menu button.
35
+ .toggle {
36
+ display: none;
37
+ }
38
+
39
+ @each $width in 640, 960, 1280 {
40
+ @media (max-width: #{$width - 0.02}px) {
41
+ .bar[data-collapse="#{$width}"] {
42
+ .wide {
43
+ display: none;
44
+ }
45
+
46
+ .toggle {
47
+ display: inline-flex;
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ @keyframes open {
54
+ from {
55
+ opacity: 0;
56
+ transform: translateY(calc(-1 * var(--scale-8)));
57
+ }
58
+ }
59
+
60
+ @media (prefers-reduced-motion: reduce) {
61
+ .menu {
62
+ animation: none;
63
+ }
64
+ }
@@ -0,0 +1,24 @@
1
+ import type { ReactNode } from "react";
2
+ /** A link of the main navigation. */
3
+ export interface NavigationLink {
4
+ href: string;
5
+ label: ReactNode;
6
+ /** The page being shown: marked for assistive technology and drawn in foreground. */
7
+ current?: boolean;
8
+ }
9
+ export interface NavigationProperties {
10
+ /** The name or logo, at the bar's start (a link home). */
11
+ brand: ReactNode;
12
+ /** The navigation's name for assistive technology ("Main"). */
13
+ label: string;
14
+ links: readonly NavigationLink[];
15
+ /** What sits at the bar's end (style switches, a profile picture, a call to action); in the menu on phones. */
16
+ actions?: ReactNode;
17
+ /** The menu button's names, closed and open ("Open the menu", "Close the menu"). */
18
+ menuLabel: string;
19
+ closeLabel: string;
20
+ /** The width below which the links and actions move into the menu: 640, 960 (the default) or 1280. */
21
+ collapse?: 640 | 960 | 1280;
22
+ className?: string;
23
+ }
24
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/navigation/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,qCAAqC;AACrC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,qFAAqF;IACrF,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,KAAK,EAAE,SAAS,CAAC;IACjB,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IACjC,+GAA+G;IAC/G,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,sGAAsG;IACtG,QAAQ,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/navigation/type.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sharadox/graphical-user-interface-web-library",
3
- "version": "0.2.0-development.25",
3
+ "version": "0.2.0-development.29",
4
4
  "description": "One generic, accessible, fully configurable component library: every interface piece in every variant, color, corner, line, size and state, styled from a single source of truth that each brand configures.",
5
5
  "private": false,
6
6
  "license": "SEE LICENSE IN LICENCA.md",
@@ -52,7 +52,8 @@
52
52
  "*.{json,md,yml,yaml,scss}": "prettier --write"
53
53
  },
54
54
  "dependencies": {
55
- "@sharadox/icon-web-library": "0.7.0-development.39",
55
+ "@sharadox/icon-web-library": "0.7.0-development.42",
56
+ "@sharadox/menu-web-library": "^0.1.3",
56
57
  "@sharadox/style-web-library": "^0.3.1",
57
58
  "@sharadox/web-library": "^0.11.1"
58
59
  },