@newtone-dev/ui-react-web 0.2.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/LICENSE +21 -0
- package/README.md +83 -0
- package/dist/accordion/accordion.css +239 -0
- package/dist/accordion/accordion.d.ts +106 -0
- package/dist/accordion/accordion.d.ts.map +1 -0
- package/dist/accordion/accordion.js +15 -0
- package/dist/accordion/accordion.js.map +1 -0
- package/dist/accordion/index.d.ts +4 -0
- package/dist/accordion/index.d.ts.map +1 -0
- package/dist/accordion/index.js +3 -0
- package/dist/accordion/index.js.map +1 -0
- package/dist/action/action.css +86 -0
- package/dist/action/action.d.ts +62 -0
- package/dist/action/action.d.ts.map +1 -0
- package/dist/action/action.js +59 -0
- package/dist/action/action.js.map +1 -0
- package/dist/action/index.d.ts +4 -0
- package/dist/action/index.d.ts.map +1 -0
- package/dist/action/index.js +3 -0
- package/dist/action/index.js.map +1 -0
- package/dist/avatar/avatar.css +39 -0
- package/dist/avatar/avatar.d.ts +43 -0
- package/dist/avatar/avatar.d.ts.map +1 -0
- package/dist/avatar/avatar.js +38 -0
- package/dist/avatar/avatar.js.map +1 -0
- package/dist/avatar/index.d.ts +4 -0
- package/dist/avatar/index.d.ts.map +1 -0
- package/dist/avatar/index.js +3 -0
- package/dist/avatar/index.js.map +1 -0
- package/dist/button/button.css +112 -0
- package/dist/button/button.d.ts +36 -0
- package/dist/button/button.d.ts.map +1 -0
- package/dist/button/button.js +24 -0
- package/dist/button/button.js.map +1 -0
- package/dist/button/index.d.ts +3 -0
- package/dist/button/index.d.ts.map +1 -0
- package/dist/button/index.js +2 -0
- package/dist/button/index.js.map +1 -0
- package/dist/card-box/card-box.css +75 -0
- package/dist/card-box/card-box.d.ts +114 -0
- package/dist/card-box/card-box.d.ts.map +1 -0
- package/dist/card-box/card-box.js +9 -0
- package/dist/card-box/card-box.js.map +1 -0
- package/dist/card-box/index.d.ts +4 -0
- package/dist/card-box/index.d.ts.map +1 -0
- package/dist/card-box/index.js +3 -0
- package/dist/card-box/index.js.map +1 -0
- package/dist/card-grid/card-grid.css +97 -0
- package/dist/card-grid/card-grid.d.ts +63 -0
- package/dist/card-grid/card-grid.d.ts.map +1 -0
- package/dist/card-grid/card-grid.js +27 -0
- package/dist/card-grid/card-grid.js.map +1 -0
- package/dist/card-grid/index.d.ts +4 -0
- package/dist/card-grid/index.d.ts.map +1 -0
- package/dist/card-grid/index.js +3 -0
- package/dist/card-grid/index.js.map +1 -0
- package/dist/color/gamut.d.ts +20 -0
- package/dist/color/gamut.d.ts.map +1 -0
- package/dist/color/gamut.js +72 -0
- package/dist/color/gamut.js.map +1 -0
- package/dist/color/index.d.ts +8 -0
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/index.js +21 -0
- package/dist/color/index.js.map +1 -0
- package/dist/color/oklch.d.ts +35 -0
- package/dist/color/oklch.d.ts.map +1 -0
- package/dist/color/oklch.js +103 -0
- package/dist/color/oklch.js.map +1 -0
- package/dist/color/scale.d.ts +20 -0
- package/dist/color/scale.d.ts.map +1 -0
- package/dist/color/scale.js +75 -0
- package/dist/color/scale.js.map +1 -0
- package/dist/color/seeds.d.ts +33 -0
- package/dist/color/seeds.d.ts.map +1 -0
- package/dist/color/seeds.js +148 -0
- package/dist/color/seeds.js.map +1 -0
- package/dist/control/control.css +203 -0
- package/dist/control/control.d.ts +112 -0
- package/dist/control/control.d.ts.map +1 -0
- package/dist/control/control.js +107 -0
- package/dist/control/control.js.map +1 -0
- package/dist/control/index.d.ts +4 -0
- package/dist/control/index.d.ts.map +1 -0
- package/dist/control/index.js +3 -0
- package/dist/control/index.js.map +1 -0
- package/dist/data-list/data-list.css +52 -0
- package/dist/data-list/data-list.d.ts +55 -0
- package/dist/data-list/data-list.d.ts.map +1 -0
- package/dist/data-list/data-list.js +51 -0
- package/dist/data-list/data-list.js.map +1 -0
- package/dist/data-list/index.d.ts +5 -0
- package/dist/data-list/index.d.ts.map +1 -0
- package/dist/data-list/index.js +3 -0
- package/dist/data-list/index.js.map +1 -0
- package/dist/data-list/row/row.d.ts +16 -0
- package/dist/data-list/row/row.d.ts.map +1 -0
- package/dist/data-list/row/row.js +15 -0
- package/dist/data-list/row/row.js.map +1 -0
- package/dist/feature-card/feature-card.css +93 -0
- package/dist/feature-card/feature-card.d.ts +68 -0
- package/dist/feature-card/feature-card.d.ts.map +1 -0
- package/dist/feature-card/feature-card.js +11 -0
- package/dist/feature-card/feature-card.js.map +1 -0
- package/dist/feature-card/index.d.ts +4 -0
- package/dist/feature-card/index.d.ts.map +1 -0
- package/dist/feature-card/index.js +3 -0
- package/dist/feature-card/index.js.map +1 -0
- package/dist/framed-icon/framed-icon.css +77 -0
- package/dist/framed-icon/framed-icon.d.ts +61 -0
- package/dist/framed-icon/framed-icon.d.ts.map +1 -0
- package/dist/framed-icon/framed-icon.js +14 -0
- package/dist/framed-icon/framed-icon.js.map +1 -0
- package/dist/framed-icon/index.d.ts +4 -0
- package/dist/framed-icon/index.d.ts.map +1 -0
- package/dist/framed-icon/index.js +3 -0
- package/dist/framed-icon/index.js.map +1 -0
- package/dist/gallery/gallery.css +165 -0
- package/dist/gallery/gallery.d.ts +85 -0
- package/dist/gallery/gallery.d.ts.map +1 -0
- package/dist/gallery/gallery.js +75 -0
- package/dist/gallery/gallery.js.map +1 -0
- package/dist/gallery/index.d.ts +4 -0
- package/dist/gallery/index.d.ts.map +1 -0
- package/dist/gallery/index.js +3 -0
- package/dist/gallery/index.js.map +1 -0
- package/dist/icon/icon.css +83 -0
- package/dist/icon/icon.d.ts +69 -0
- package/dist/icon/icon.d.ts.map +1 -0
- package/dist/icon/icon.js +18 -0
- package/dist/icon/icon.js.map +1 -0
- package/dist/icon/index.d.ts +4 -0
- package/dist/icon/index.d.ts.map +1 -0
- package/dist/icon/index.js +3 -0
- package/dist/icon/index.js.map +1 -0
- package/dist/icon-link/icon-link.css +57 -0
- package/dist/icon-link/icon-link.d.ts +47 -0
- package/dist/icon-link/icon-link.d.ts.map +1 -0
- package/dist/icon-link/icon-link.js +35 -0
- package/dist/icon-link/icon-link.js.map +1 -0
- package/dist/icon-link/index.d.ts +4 -0
- package/dist/icon-link/index.d.ts.map +1 -0
- package/dist/icon-link/index.js +3 -0
- package/dist/icon-link/index.js.map +1 -0
- package/dist/identity/identity.d.ts +25 -0
- package/dist/identity/identity.d.ts.map +1 -0
- package/dist/identity/identity.js +25 -0
- package/dist/identity/identity.js.map +1 -0
- package/dist/identity/index.d.ts +3 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/identity/index.js +2 -0
- package/dist/identity/index.js.map +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/link/index.d.ts +3 -0
- package/dist/link/index.d.ts.map +1 -0
- package/dist/link/index.js +2 -0
- package/dist/link/index.js.map +1 -0
- package/dist/link/link.css +65 -0
- package/dist/link/link.d.ts +38 -0
- package/dist/link/link.d.ts.map +1 -0
- package/dist/link/link.js +22 -0
- package/dist/link/link.js.map +1 -0
- package/dist/logo-marquee/index.d.ts +4 -0
- package/dist/logo-marquee/index.d.ts.map +1 -0
- package/dist/logo-marquee/index.js +3 -0
- package/dist/logo-marquee/index.js.map +1 -0
- package/dist/logo-marquee/logo-marquee.css +227 -0
- package/dist/logo-marquee/logo-marquee.d.ts +69 -0
- package/dist/logo-marquee/logo-marquee.d.ts.map +1 -0
- package/dist/logo-marquee/logo-marquee.js +11 -0
- package/dist/logo-marquee/logo-marquee.js.map +1 -0
- package/dist/media-plate/index.d.ts +4 -0
- package/dist/media-plate/index.d.ts.map +1 -0
- package/dist/media-plate/index.js +3 -0
- package/dist/media-plate/index.js.map +1 -0
- package/dist/media-plate/media-plate.css +41 -0
- package/dist/media-plate/media-plate.d.ts +45 -0
- package/dist/media-plate/media-plate.d.ts.map +1 -0
- package/dist/media-plate/media-plate.js +5 -0
- package/dist/media-plate/media-plate.js.map +1 -0
- package/dist/media-window/media-window.css +82 -0
- package/dist/navbar/actions/actions.d.ts +14 -0
- package/dist/navbar/actions/actions.d.ts.map +1 -0
- package/dist/navbar/actions/actions.js +12 -0
- package/dist/navbar/actions/actions.js.map +1 -0
- package/dist/navbar/brand/brand.d.ts +12 -0
- package/dist/navbar/brand/brand.d.ts.map +1 -0
- package/dist/navbar/brand/brand.js +10 -0
- package/dist/navbar/brand/brand.js.map +1 -0
- package/dist/navbar/context.d.ts +12 -0
- package/dist/navbar/context.d.ts.map +1 -0
- package/dist/navbar/context.js +13 -0
- package/dist/navbar/context.js.map +1 -0
- package/dist/navbar/index.d.ts +8 -0
- package/dist/navbar/index.d.ts.map +1 -0
- package/dist/navbar/index.js +8 -0
- package/dist/navbar/index.js.map +1 -0
- package/dist/navbar/link/drawer/drawer.css +50 -0
- package/dist/navbar/link/drawer/drawer.d.ts +20 -0
- package/dist/navbar/link/drawer/drawer.d.ts.map +1 -0
- package/dist/navbar/link/drawer/drawer.js +44 -0
- package/dist/navbar/link/drawer/drawer.js.map +1 -0
- package/dist/navbar/link/link.css +54 -0
- package/dist/navbar/link/link.d.ts +30 -0
- package/dist/navbar/link/link.d.ts.map +1 -0
- package/dist/navbar/link/link.js +29 -0
- package/dist/navbar/link/link.js.map +1 -0
- package/dist/navbar/links/links.d.ts +14 -0
- package/dist/navbar/links/links.d.ts.map +1 -0
- package/dist/navbar/links/links.js +14 -0
- package/dist/navbar/links/links.js.map +1 -0
- package/dist/navbar/menu-button/menu-button.css +20 -0
- package/dist/navbar/menu-button/menu-button.d.ts +13 -0
- package/dist/navbar/menu-button/menu-button.d.ts.map +1 -0
- package/dist/navbar/menu-button/menu-button.js +20 -0
- package/dist/navbar/menu-button/menu-button.js.map +1 -0
- package/dist/navbar/navbar.css +179 -0
- package/dist/navbar/navbar.d.ts +58 -0
- package/dist/navbar/navbar.d.ts.map +1 -0
- package/dist/navbar/navbar.js +96 -0
- package/dist/navbar/navbar.js.map +1 -0
- package/dist/numbered-list/index.d.ts +4 -0
- package/dist/numbered-list/index.d.ts.map +1 -0
- package/dist/numbered-list/index.js +3 -0
- package/dist/numbered-list/index.js.map +1 -0
- package/dist/numbered-list/numbered-list.css +46 -0
- package/dist/numbered-list/numbered-list.d.ts +31 -0
- package/dist/numbered-list/numbered-list.d.ts.map +1 -0
- package/dist/numbered-list/numbered-list.js +26 -0
- package/dist/numbered-list/numbered-list.js.map +1 -0
- package/dist/on-media/on-media.css +198 -0
- package/dist/quick-action/index.d.ts +4 -0
- package/dist/quick-action/index.d.ts.map +1 -0
- package/dist/quick-action/index.js +3 -0
- package/dist/quick-action/index.js.map +1 -0
- package/dist/quick-action/quick-action.css +70 -0
- package/dist/quick-action/quick-action.d.ts +68 -0
- package/dist/quick-action/quick-action.d.ts.map +1 -0
- package/dist/quick-action/quick-action.js +54 -0
- package/dist/quick-action/quick-action.js.map +1 -0
- package/dist/segmented-control/index.d.ts +4 -0
- package/dist/segmented-control/index.d.ts.map +1 -0
- package/dist/segmented-control/index.js +3 -0
- package/dist/segmented-control/index.js.map +1 -0
- package/dist/segmented-control/segmented-control.css +206 -0
- package/dist/segmented-control/segmented-control.d.ts +91 -0
- package/dist/segmented-control/segmented-control.d.ts.map +1 -0
- package/dist/segmented-control/segmented-control.js +9 -0
- package/dist/segmented-control/segmented-control.js.map +1 -0
- package/dist/stat-card/index.d.ts +4 -0
- package/dist/stat-card/index.d.ts.map +1 -0
- package/dist/stat-card/index.js +3 -0
- package/dist/stat-card/index.js.map +1 -0
- package/dist/stat-card/stat-card.css +56 -0
- package/dist/stat-card/stat-card.d.ts +48 -0
- package/dist/stat-card/stat-card.d.ts.map +1 -0
- package/dist/stat-card/stat-card.js +11 -0
- package/dist/stat-card/stat-card.js.map +1 -0
- package/dist/surface/index.d.ts +3 -0
- package/dist/surface/index.d.ts.map +1 -0
- package/dist/surface/index.js +2 -0
- package/dist/surface/index.js.map +1 -0
- package/dist/surface/surface.d.ts +40 -0
- package/dist/surface/surface.d.ts.map +1 -0
- package/dist/surface/surface.js +22 -0
- package/dist/surface/surface.js.map +1 -0
- package/dist/tag/index.d.ts +4 -0
- package/dist/tag/index.d.ts.map +1 -0
- package/dist/tag/index.js +3 -0
- package/dist/tag/index.js.map +1 -0
- package/dist/tag/tag.css +77 -0
- package/dist/tag/tag.d.ts +80 -0
- package/dist/tag/tag.d.ts.map +1 -0
- package/dist/tag/tag.js +16 -0
- package/dist/tag/tag.js.map +1 -0
- package/dist/text/index.d.ts +3 -0
- package/dist/text/index.d.ts.map +1 -0
- package/dist/text/index.js +2 -0
- package/dist/text/index.js.map +1 -0
- package/dist/text/text.css +232 -0
- package/dist/text/text.d.ts +64 -0
- package/dist/text/text.d.ts.map +1 -0
- package/dist/text/text.js +37 -0
- package/dist/text/text.js.map +1 -0
- package/dist/video-lightbox/index.d.ts +4 -0
- package/dist/video-lightbox/index.d.ts.map +1 -0
- package/dist/video-lightbox/index.js +3 -0
- package/dist/video-lightbox/index.js.map +1 -0
- package/dist/video-lightbox/video-lightbox.css +167 -0
- package/dist/video-lightbox/video-lightbox.d.ts +92 -0
- package/dist/video-lightbox/video-lightbox.d.ts.map +1 -0
- package/dist/video-lightbox/video-lightbox.js +31 -0
- package/dist/video-lightbox/video-lightbox.js.map +1 -0
- package/dist/wrapper/index.d.ts +3 -0
- package/dist/wrapper/index.d.ts.map +1 -0
- package/dist/wrapper/index.js +2 -0
- package/dist/wrapper/index.js.map +1 -0
- package/dist/wrapper/wrapper.d.ts +113 -0
- package/dist/wrapper/wrapper.d.ts.map +1 -0
- package/dist/wrapper/wrapper.js +83 -0
- package/dist/wrapper/wrapper.js.map +1 -0
- package/package.json +184 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// The state the parts share, lifted out of navbar.tsx.
|
|
2
|
+
//
|
|
3
|
+
// A private module and a private subcomponent are the same kind of thing here and are marked
|
|
4
|
+
// the same way: no index.ts, so nothing outside navbar/ can reach either.
|
|
5
|
+
import { createContext, useContext } from 'react';
|
|
6
|
+
export const NavbarContext = createContext(null);
|
|
7
|
+
export function useNavbar(part) {
|
|
8
|
+
const ctx = useContext(NavbarContext);
|
|
9
|
+
if (!ctx)
|
|
10
|
+
throw new Error(`Navbar.${part} must be used inside a Navbar`);
|
|
11
|
+
return ctx;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/navbar/context.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,EAAE;AACF,6FAA6F;AAC7F,0EAA0E;AAE1E,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAsBjD,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAA4B,IAAI,CAAC,CAAA;AAE3E,MAAM,UAAU,SAAS,CAAC,IAAY;IAClC,MAAM,GAAG,GAAG,UAAU,CAAC,aAAa,CAAC,CAAA;IACrC,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,+BAA+B,CAAC,CAAA;IACxE,OAAO,GAAG,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Navbar } from './navbar.js';
|
|
2
|
+
export type { NavbarProps } from './navbar.js';
|
|
3
|
+
export type { NavbarBrandProps } from './brand/brand.js';
|
|
4
|
+
export type { NavbarLinksProps } from './links/links.js';
|
|
5
|
+
export type { NavbarLinkProps } from './link/link.js';
|
|
6
|
+
export type { NavbarActionsProps } from './actions/actions.js';
|
|
7
|
+
export type { NavbarMenuButtonProps } from './menu-button/menu-button.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navbar/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// The door. Navbar, and every part's prop types -- but none of the parts.
|
|
2
|
+
//
|
|
3
|
+
// A type cannot be rendered in a hero section, so exporting NavbarLinkProps does not weaken
|
|
4
|
+
// the boundary; section 3 documents those props and a consumer typing a wrapper needs them.
|
|
5
|
+
// The parts themselves are reachable only as Navbar.Brand, Navbar.Link and so on, because
|
|
6
|
+
// their folders have no index.ts to import from.
|
|
7
|
+
export { Navbar } from './navbar.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/navbar/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,4FAA4F;AAC5F,4FAA4F;AAC5F,0FAA0F;AAC1F,iDAAiD;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* ---- the drawer ---------------------------------------------------------
|
|
2
|
+
*
|
|
3
|
+
* A panel of destinations under one link. Its trigger is a button and not an anchor, for the
|
|
4
|
+
* reason contracts/navbar.md gives: an anchor would have to navigate and disclose at once, and
|
|
5
|
+
* every way of resolving that strands either touch or the keyboard.
|
|
6
|
+
*
|
|
7
|
+
* **It spends navbar.bar.* and declares nothing of its own.** The drawer is the bar continued
|
|
8
|
+
* downward -- same ground, same hairline -- rather than a floating surface with its own
|
|
9
|
+
* identity. Giving it navbar.drawer.* would be two names for one decision, and two names for
|
|
10
|
+
* one decision is how they come apart.
|
|
11
|
+
*
|
|
12
|
+
* The trigger is `button.newtone-navbar-link`, so every rule above styling that class applies
|
|
13
|
+
* to it unchanged, including both positions of the current axis. That is why the button carries
|
|
14
|
+
* the same class rather than one of its own.
|
|
15
|
+
*/
|
|
16
|
+
.newtone-navbar-drawer-host {
|
|
17
|
+
position: relative;
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.newtone-navbar-drawer-host > .newtone-navbar-link {
|
|
22
|
+
border: 0;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
font: inherit;
|
|
25
|
+
font-family: var(--newtone-navbar-link-label-family);
|
|
26
|
+
font-size: var(--newtone-navbar-link-label-size);
|
|
27
|
+
font-weight: var(--newtone-navbar-link-label-weight);
|
|
28
|
+
line-height: var(--newtone-navbar-link-label-line-height);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.newtone-navbar-drawer {
|
|
32
|
+
display: none;
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: calc(100% + var(--newtone-navbar-padding-y));
|
|
35
|
+
left: 0;
|
|
36
|
+
min-width: 14rem;
|
|
37
|
+
padding: var(--newtone-navbar-link-padding-y) var(--newtone-navbar-link-padding-x);
|
|
38
|
+
background: var(--newtone-navbar-bar-fill);
|
|
39
|
+
border: 1px solid var(--newtone-navbar-bar-border);
|
|
40
|
+
border-radius: var(--newtone-navbar-link-radius);
|
|
41
|
+
}
|
|
42
|
+
.newtone-navbar-drawer[data-open] {
|
|
43
|
+
display: block;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Inside a drawer the links stack and fill the width: it is a list of destinations rather than
|
|
47
|
+
a row of them, and a row is what the bar already is. */
|
|
48
|
+
.newtone-navbar-drawer .newtone-navbar-link {
|
|
49
|
+
display: flex;
|
|
50
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A link that carries a drawer, which is a button.
|
|
4
|
+
*
|
|
5
|
+
* **An anchor cannot do this job.** It would have to navigate and disclose at once: hover to
|
|
6
|
+
* open does not exist on a touch screen, click to navigate leaves a keyboard no way in, and
|
|
7
|
+
* `aria-expanded` on something that navigates describes a state it does not have. So the
|
|
8
|
+
* trigger discloses and the page it would have pointed at becomes the drawer's first item.
|
|
9
|
+
*
|
|
10
|
+
* `aria-current` stays on the trigger. It is valid on any element, not only on links, so a
|
|
11
|
+
* drawer whose section the reader is inside says so -- and so does the matching item within it.
|
|
12
|
+
* Both are true and they are not the same statement.
|
|
13
|
+
*/
|
|
14
|
+
export declare function NavbarDrawerLink({ current, drawer, className, children, }: {
|
|
15
|
+
current: boolean;
|
|
16
|
+
drawer: ReactNode;
|
|
17
|
+
className: string;
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}): import("react").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=drawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../../../src/navbar/link/drawer/drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAE1E;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,EAC7B,OAAO,EACP,MAAM,EACN,SAAS,EACT,QAAQ,GACX,EAAE;IACC,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,SAAS,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,SAAS,CAAA;CACtB,+BAqDA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useId, useRef, useState } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* A link that carries a drawer, which is a button.
|
|
5
|
+
*
|
|
6
|
+
* **An anchor cannot do this job.** It would have to navigate and disclose at once: hover to
|
|
7
|
+
* open does not exist on a touch screen, click to navigate leaves a keyboard no way in, and
|
|
8
|
+
* `aria-expanded` on something that navigates describes a state it does not have. So the
|
|
9
|
+
* trigger discloses and the page it would have pointed at becomes the drawer's first item.
|
|
10
|
+
*
|
|
11
|
+
* `aria-current` stays on the trigger. It is valid on any element, not only on links, so a
|
|
12
|
+
* drawer whose section the reader is inside says so -- and so does the matching item within it.
|
|
13
|
+
* Both are true and they are not the same statement.
|
|
14
|
+
*/
|
|
15
|
+
export function NavbarDrawerLink({ current, drawer, className, children, }) {
|
|
16
|
+
const [open, setOpen] = useState(false);
|
|
17
|
+
const hostRef = useRef(null);
|
|
18
|
+
const buttonRef = useRef(null);
|
|
19
|
+
const drawerId = useId();
|
|
20
|
+
// Escape closes and hands focus back. Outside-click closes and does not, because the pointer
|
|
21
|
+
// has already moved the reader's attention somewhere this component does not own.
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!open)
|
|
24
|
+
return;
|
|
25
|
+
const onKeyDown = (event) => {
|
|
26
|
+
if (event.key !== 'Escape')
|
|
27
|
+
return;
|
|
28
|
+
setOpen(false);
|
|
29
|
+
buttonRef.current?.focus();
|
|
30
|
+
};
|
|
31
|
+
const onPointerDown = (event) => {
|
|
32
|
+
if (!hostRef.current?.contains(event.target))
|
|
33
|
+
setOpen(false);
|
|
34
|
+
};
|
|
35
|
+
document.addEventListener('keydown', onKeyDown);
|
|
36
|
+
document.addEventListener('mousedown', onPointerDown);
|
|
37
|
+
return () => {
|
|
38
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
39
|
+
document.removeEventListener('mousedown', onPointerDown);
|
|
40
|
+
};
|
|
41
|
+
}, [open]);
|
|
42
|
+
return (_jsxs("div", { ref: hostRef, className: "newtone-navbar-drawer-host", children: [_jsx("button", { ref: buttonRef, type: "button", "aria-expanded": open, "aria-controls": drawerId, "aria-current": current ? 'page' : undefined, className: className, onClick: () => setOpen(!open), children: children }), _jsx("div", { id: drawerId, className: "newtone-navbar-drawer", "data-open": open ? '' : undefined, onClick: () => setOpen(false), children: drawer })] }));
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=drawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer.js","sourceRoot":"","sources":["../../../../src/navbar/link/drawer/drawer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAA;AAE1E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC7B,OAAO,EACP,MAAM,EACN,SAAS,EACT,QAAQ,GAMX;IACG,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IACvC,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;IAC5C,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAA;IACjD,MAAM,QAAQ,GAAG,KAAK,EAAE,CAAA;IAExB,6FAA6F;IAC7F,kFAAkF;IAClF,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,IAAI;YAAE,OAAM;QACjB,MAAM,SAAS,GAAG,CAAC,KAAoB,EAAE,EAAE;YACvC,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ;gBAAE,OAAM;YAClC,OAAO,CAAC,KAAK,CAAC,CAAA;YACd,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,CAAA;QAC9B,CAAC,CAAA;QACD,MAAM,aAAa,GAAG,CAAC,KAAiB,EAAE,EAAE;YACxC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAc,CAAC;gBAAE,OAAO,CAAC,KAAK,CAAC,CAAA;QACxE,CAAC,CAAA;QACD,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;QAC/C,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAA;QACrD,OAAO,GAAG,EAAE;YACR,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;YAClD,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAA;QAC5D,CAAC,CAAA;IACL,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,OAAO,CACH,eAAK,GAAG,EAAE,OAAO,EAAE,SAAS,EAAC,4BAA4B,aACrD,iBACI,GAAG,EAAE,SAAS,EACd,IAAI,EAAC,QAAQ,mBACE,IAAI,mBACJ,QAAQ,kBACT,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAC1C,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,YAE5B,QAAQ,GACJ,EAKT,cACI,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAC,uBAAuB,eACtB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAChC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,YAE5B,MAAM,GACL,IACJ,CACT,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
.newtone-navbar-link {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
padding: var(--newtone-navbar-link-padding-y) var(--newtone-navbar-link-padding-x);
|
|
5
|
+
font-family: var(--newtone-navbar-link-label-family);
|
|
6
|
+
font-size: var(--newtone-navbar-link-label-size);
|
|
7
|
+
font-weight: var(--newtone-navbar-link-label-weight);
|
|
8
|
+
line-height: var(--newtone-navbar-link-label-line-height);
|
|
9
|
+
text-decoration: none;
|
|
10
|
+
border-radius: var(--newtone-navbar-link-radius);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* ---- the two axes -------------------------------------------------------
|
|
14
|
+
*
|
|
15
|
+
* `current` is not an event state. A link can be the current page *and* under the pointer, so
|
|
16
|
+
* the two cannot share an axis: filed as one, a hovered current link has no defined appearance
|
|
17
|
+
* and whichever rule was written last wins.
|
|
18
|
+
*
|
|
19
|
+
* So there are two, and they are keyed off `[aria-current]` and `:not([aria-current])` rather
|
|
20
|
+
* than off a class this component would also have to keep in step. The selectors are mutually
|
|
21
|
+
* exclusive, which means nothing about the order of the rules below decides anything.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
.newtone-navbar-link:not([aria-current]) {
|
|
25
|
+
background: var(--newtone-navbar-link-elsewhere-rest-fill);
|
|
26
|
+
color: var(--newtone-navbar-link-elsewhere-rest-text);
|
|
27
|
+
}
|
|
28
|
+
.newtone-navbar-link:not([aria-current]):hover {
|
|
29
|
+
background: var(--newtone-navbar-link-elsewhere-hover-fill);
|
|
30
|
+
color: var(--newtone-navbar-link-elsewhere-hover-text);
|
|
31
|
+
}
|
|
32
|
+
.newtone-navbar-link:not([aria-current]):active {
|
|
33
|
+
background: var(--newtone-navbar-link-elsewhere-pressed-fill);
|
|
34
|
+
color: var(--newtone-navbar-link-elsewhere-pressed-text);
|
|
35
|
+
}
|
|
36
|
+
.newtone-navbar-link:not([aria-current]):focus-visible {
|
|
37
|
+
outline-color: var(--newtone-navbar-link-elsewhere-focus-ring);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.newtone-navbar-link[aria-current] {
|
|
41
|
+
background: var(--newtone-navbar-link-here-rest-fill);
|
|
42
|
+
color: var(--newtone-navbar-link-here-rest-text);
|
|
43
|
+
}
|
|
44
|
+
.newtone-navbar-link[aria-current]:hover {
|
|
45
|
+
background: var(--newtone-navbar-link-here-hover-fill);
|
|
46
|
+
color: var(--newtone-navbar-link-here-hover-text);
|
|
47
|
+
}
|
|
48
|
+
.newtone-navbar-link[aria-current]:active {
|
|
49
|
+
background: var(--newtone-navbar-link-here-pressed-fill);
|
|
50
|
+
color: var(--newtone-navbar-link-here-pressed-text);
|
|
51
|
+
}
|
|
52
|
+
.newtone-navbar-link[aria-current]:focus-visible {
|
|
53
|
+
outline-color: var(--newtone-navbar-link-here-focus-ring);
|
|
54
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AnchorHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface NavbarLinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> {
|
|
3
|
+
/** Required unless a `drawer` is given, in which case the destination moves inside it. */
|
|
4
|
+
href?: string;
|
|
5
|
+
/** Whether this link points at the page the reader is on. */
|
|
6
|
+
current?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* A panel of further destinations under this one. Its presence turns the link into a
|
|
9
|
+
* disclosure button -- see the contract, "A link with a drawer is a button".
|
|
10
|
+
*/
|
|
11
|
+
drawer?: ReactNode;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* One destination.
|
|
16
|
+
*
|
|
17
|
+
* **`aria-current="page"` -- the string, not `true`.** `page` says which kind of current this
|
|
18
|
+
* is, and it is what the two hand-written mastheads this component replaces were both missing.
|
|
19
|
+
* The colour was there in both; the announcement was in neither.
|
|
20
|
+
*
|
|
21
|
+
* **`current` is not an event state.** A link can be current *and* hovered, so it cannot be a
|
|
22
|
+
* fifth value beside rest, hover and pressed -- those three are exclusive by nature and this is
|
|
23
|
+
* not. It is a second axis, `here` against `elsewhere`, and navbar.css keys the two off the
|
|
24
|
+
* presence of the attribute so that source order decides nothing.
|
|
25
|
+
*
|
|
26
|
+
* Following a link inside an open panel closes it. Nothing else would: the site's router
|
|
27
|
+
* changes the URL without unmounting this component.
|
|
28
|
+
*/
|
|
29
|
+
export declare function NavbarLink({ href, current, drawer, className, children, onClick, ...rest }: NavbarLinkProps): import("react").JSX.Element;
|
|
30
|
+
//# sourceMappingURL=link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../src/navbar/link/link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAI5D,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC9F,0FAA0F;IAC1F,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,QAAQ,EAAE,SAAS,CAAA;CACtB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,EACvB,IAAI,EACJ,OAAe,EACf,MAAM,EACN,SAAS,EACT,QAAQ,EACR,OAAO,EACP,GAAG,IAAI,EACV,EAAE,eAAe,+BAqBjB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useNavbar } from '../context.js';
|
|
3
|
+
import { NavbarDrawerLink } from './drawer/drawer.js';
|
|
4
|
+
/**
|
|
5
|
+
* One destination.
|
|
6
|
+
*
|
|
7
|
+
* **`aria-current="page"` -- the string, not `true`.** `page` says which kind of current this
|
|
8
|
+
* is, and it is what the two hand-written mastheads this component replaces were both missing.
|
|
9
|
+
* The colour was there in both; the announcement was in neither.
|
|
10
|
+
*
|
|
11
|
+
* **`current` is not an event state.** A link can be current *and* hovered, so it cannot be a
|
|
12
|
+
* fifth value beside rest, hover and pressed -- those three are exclusive by nature and this is
|
|
13
|
+
* not. It is a second axis, `here` against `elsewhere`, and navbar.css keys the two off the
|
|
14
|
+
* presence of the attribute so that source order decides nothing.
|
|
15
|
+
*
|
|
16
|
+
* Following a link inside an open panel closes it. Nothing else would: the site's router
|
|
17
|
+
* changes the URL without unmounting this component.
|
|
18
|
+
*/
|
|
19
|
+
export function NavbarLink({ href, current = false, drawer, className, children, onClick, ...rest }) {
|
|
20
|
+
const { setOpen } = useNavbar('Link');
|
|
21
|
+
const cls = ['newtone-navbar-link', className].filter(Boolean).join(' ');
|
|
22
|
+
if (drawer !== undefined)
|
|
23
|
+
return _jsx(NavbarDrawerLink, { current, drawer, className: cls, children });
|
|
24
|
+
return (_jsx("a", { href: href, "aria-current": current ? 'page' : undefined, className: cls, onClick: (event) => {
|
|
25
|
+
setOpen(false);
|
|
26
|
+
onClick?.(event);
|
|
27
|
+
}, ...rest, children: children }));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../../src/navbar/link/link.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAerD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,UAAU,CAAC,EACvB,IAAI,EACJ,OAAO,GAAG,KAAK,EACf,MAAM,EACN,SAAS,EACT,QAAQ,EACR,OAAO,EACP,GAAG,IAAI,EACO;IACd,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,CAAA;IACrC,MAAM,GAAG,GAAG,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAExE,IAAI,MAAM,KAAK,SAAS;QACpB,OAAO,KAAC,gBAAgB,IAAO,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,GAAM,CAAA;IAElF,OAAO,CACH,YACI,IAAI,EAAE,IAAI,kBACI,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAC1C,SAAS,EAAE,GAAG,EACd,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,CAAA;YACd,OAAO,EAAE,CAAC,KAAK,CAAC,CAAA;QACpB,CAAC,KACG,IAAI,YAEP,QAAQ,GACT,CACP,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface NavbarLinksProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The primary navigation, and **the same element is the collapsed panel at narrow widths** --
|
|
8
|
+
* repositioned by CSS, gated on the bar's `data-newtone-navbar-menu-open`.
|
|
9
|
+
*
|
|
10
|
+
* There is no second container to fill. Writing the links twice would duplicate the id that
|
|
11
|
+
* ties `aria-controls` to its target and would read every link twice to a screen reader.
|
|
12
|
+
*/
|
|
13
|
+
export declare function NavbarLinks({ className, children }: NavbarLinksProps): import("react").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../../src/navbar/links/links.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,MAAM,WAAW,gBAAgB;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAA;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,gBAAgB,+BAOpE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useNavbar } from '../context.js';
|
|
3
|
+
/**
|
|
4
|
+
* The primary navigation, and **the same element is the collapsed panel at narrow widths** --
|
|
5
|
+
* repositioned by CSS, gated on the bar's `data-newtone-navbar-menu-open`.
|
|
6
|
+
*
|
|
7
|
+
* There is no second container to fill. Writing the links twice would duplicate the id that
|
|
8
|
+
* ties `aria-controls` to its target and would read every link twice to a screen reader.
|
|
9
|
+
*/
|
|
10
|
+
export function NavbarLinks({ className, children }) {
|
|
11
|
+
const { panelId } = useNavbar('Links');
|
|
12
|
+
return (_jsx("nav", { id: panelId, className: ['newtone-navbar-links', className].filter(Boolean).join(' '), children: children }));
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.js","sourceRoot":"","sources":["../../../src/navbar/links/links.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAOzC;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAoB;IACjE,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,CAAA;IACtC,OAAO,CACH,cAAK,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YACrF,QAAQ,GACP,CACT,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* The menu button is a plain control rather than a Button: it belongs to the navbar's own token
|
|
2
|
+
group, and reaching for button.* here would be one component spending another's colours. */
|
|
3
|
+
.newtone-navbar-menu-button {
|
|
4
|
+
display: none;
|
|
5
|
+
align-items: center;
|
|
6
|
+
padding: var(--newtone-navbar-link-padding-y) var(--newtone-navbar-link-padding-x);
|
|
7
|
+
font-family: var(--newtone-navbar-link-label-family);
|
|
8
|
+
font-size: var(--newtone-navbar-link-label-size);
|
|
9
|
+
font-weight: var(--newtone-navbar-link-label-weight);
|
|
10
|
+
line-height: var(--newtone-navbar-link-label-line-height);
|
|
11
|
+
background: var(--newtone-navbar-link-elsewhere-rest-fill);
|
|
12
|
+
color: var(--newtone-navbar-link-elsewhere-rest-text);
|
|
13
|
+
border: 1px solid var(--newtone-navbar-bar-border);
|
|
14
|
+
border-radius: var(--newtone-navbar-link-radius);
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
}
|
|
17
|
+
.newtone-navbar-menu-button:hover {
|
|
18
|
+
background: var(--newtone-navbar-link-elsewhere-hover-fill);
|
|
19
|
+
color: var(--newtone-navbar-link-elsewhere-hover-text);
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface NavbarMenuButtonProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The disclosure that opens the links panel.
|
|
8
|
+
*
|
|
9
|
+
* It takes its own glyph as a child. No icon system exists -- contracts/button.md defers icon
|
|
10
|
+
* slots on that same absence -- and this component does not invent one to get a hamburger.
|
|
11
|
+
*/
|
|
12
|
+
export declare function NavbarMenuButton({ className, children }: NavbarMenuButtonProps): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=menu-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-button.d.ts","sourceRoot":"","sources":["../../../src/navbar/menu-button/menu-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAGjD,MAAM,WAAW,qBAAqB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,SAAS,CAAA;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,qBAAqB,+BAsB9E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { useNavbar } from '../context.js';
|
|
4
|
+
/**
|
|
5
|
+
* The disclosure that opens the links panel.
|
|
6
|
+
*
|
|
7
|
+
* It takes its own glyph as a child. No icon system exists -- contracts/button.md defers icon
|
|
8
|
+
* slots on that same absence -- and this component does not invent one to get a hamburger.
|
|
9
|
+
*/
|
|
10
|
+
export function NavbarMenuButton({ className, children }) {
|
|
11
|
+
const { open, setOpen, panelId, triggerRef, registerTrigger } = useNavbar('MenuButton');
|
|
12
|
+
// Its presence is what turns the links into a collapsible panel. A bar with no disclosure
|
|
13
|
+
// keeps its links in the bar at every width, because there would be nothing to open.
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
registerTrigger(true);
|
|
16
|
+
return () => registerTrigger(false);
|
|
17
|
+
}, [registerTrigger]);
|
|
18
|
+
return (_jsx("button", { ref: triggerRef, type: "button", "aria-expanded": open, "aria-controls": panelId, className: ['newtone-navbar-menu-button', className].filter(Boolean).join(' '), onClick: () => setOpen(!open), children: children }));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=menu-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-button.js","sourceRoot":"","sources":["../../../src/navbar/menu-button/menu-button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,OAAO,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAOzC;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAyB;IAC3E,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC,YAAY,CAAC,CAAA;IAEvF,0FAA0F;IAC1F,qFAAqF;IACrF,SAAS,CAAC,GAAG,EAAE;QACX,eAAe,CAAC,IAAI,CAAC,CAAA;QACrB,OAAO,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;IACvC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAA;IAErB,OAAO,CACH,iBACI,GAAG,EAAE,UAAU,EACf,IAAI,EAAC,QAAQ,mBACE,IAAI,mBACJ,OAAO,EACtB,SAAS,EAAE,CAAC,4BAA4B,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC9E,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,YAE5B,QAAQ,GACJ,CACZ,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/* The bar's own rules, and the ordered list of its parts.
|
|
2
|
+
*
|
|
3
|
+
* `@import` must precede every other rule, so the three files below load before anything
|
|
4
|
+
* declared here. That is a real reordering and it was checked rather than assumed: every rule
|
|
5
|
+
* in this file that touches a part is either higher-specificity -- the collapse is gated on
|
|
6
|
+
* `.newtone-navbar[data-newtone-navbar-collapsible] ...`, the drawer's overrides carry two
|
|
7
|
+
* classes -- or targets an element the parts do not: the sentinel, the bar, the brand. The one
|
|
8
|
+
* shared rule, the focus ring across link, brand and menu button, still lands after the link's
|
|
9
|
+
* own focus rules, which is the order it had.
|
|
10
|
+
*
|
|
11
|
+
* This file stays what `@newtone-dev/ui-react-web/navbar.css` points at, so no consumer's import
|
|
12
|
+
* changes. Native @import; nothing was added to the toolchain to do this.
|
|
13
|
+
*/
|
|
14
|
+
@import './link/link.css';
|
|
15
|
+
@import './link/drawer/drawer.css';
|
|
16
|
+
@import './menu-button/menu-button.css';
|
|
17
|
+
|
|
18
|
+
/* Navbar's own styles. Every colour is a navbar.* token; nothing here names a colour, reads a
|
|
19
|
+
role, or mentions a facet.
|
|
20
|
+
*
|
|
21
|
+
* Two literals, and both are the arrangement contracts/button.md already allows for radius:
|
|
22
|
+
* absence in tokens, a value the library picks, and the contract does not object.
|
|
23
|
+
* - `1px` for the bar's hairline. Border *width* is blocked in tokens on the same decision as
|
|
24
|
+
* radius and letter-spacing -- there is no core length scale to point at, and adding one
|
|
25
|
+
* fires the third-length-group trigger. The hairline's *colour* is a token.
|
|
26
|
+
* - `48rem` for the width below which the links become a panel. **This file stopped being its
|
|
27
|
+
* source on 2026-09-03: it is `breakpoint.compact` in newtone_ui_tokens now.** A media query
|
|
28
|
+
* condition cannot read a custom property -- `@media (max-width: var(--newtone-breakpoint-compact))`
|
|
29
|
+
* is invalid and drops the whole block -- so the number is still typed out here, exactly as it
|
|
30
|
+
* is in five site stylesheets, and the copies are checked instead:
|
|
31
|
+
* `node tools/check-breakpoints.mjs`, from ~/source. A site that needs a different one still
|
|
32
|
+
* overrides the two blocks at the bottom of this file.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/* Out of flow and anchored to the document origin: it has no positioned ancestor, so `top: 0`
|
|
36
|
+
means the top of the page rather than the top of anything. Its height is the scroll threshold
|
|
37
|
+
and the consumer owns it -- default 1px, `100vh` for "after the first screenful". */
|
|
38
|
+
.newtone-navbar-sentinel {
|
|
39
|
+
position: absolute;
|
|
40
|
+
top: 0;
|
|
41
|
+
left: 0;
|
|
42
|
+
width: 1px;
|
|
43
|
+
height: var(--newtone-navbar-threshold, 1px);
|
|
44
|
+
visibility: hidden;
|
|
45
|
+
pointer-events: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* THE BAR IS 65px AND 48 OF THEM ARE THE SITE'S. blueprints/newtone/contracts/navbar.md,
|
|
49
|
+
"The bar is 65px".
|
|
50
|
+
*
|
|
51
|
+
* 64 of content box -- 8 + 48 + 8 -- plus the 1px hairline. Until 2026-09-17 this rule declared no
|
|
52
|
+
* height at all, so the bar was `padding-y x 2 + whatever the tallest child came to`: measured that
|
|
53
|
+
* morning, 62px on an Adenario public page and 75px on a desk document. One component, two bars, and
|
|
54
|
+
* a 13px spread nobody had chosen.
|
|
55
|
+
*
|
|
56
|
+
* IT IS A FLOOR AND NOT A HEIGHT, which is the whole of why this rule owes no overflow and no clip
|
|
57
|
+
* check -- governance/documents/a-shell-that-cannot-overflow-is-editing-the-document.md. A site that
|
|
58
|
+
* renders a 56px control gets a 72px bar, visibly, rather than a control with its bottom cut off.
|
|
59
|
+
*
|
|
60
|
+
* `box-sizing` IS DECLARED HERE AND NOWHERE ELSE IN THIS LIBRARY, because nothing else here
|
|
61
|
+
* promises a measurement. Four of the five consuming sites carry a global border-box reset; a
|
|
62
|
+
* component that rests its own arithmetic on the consumer's reset is making a promise it cannot
|
|
63
|
+
* keep, and the consumer it breaks for is the one that has not been written yet.
|
|
64
|
+
*
|
|
65
|
+
* THE HAIRLINE IS ONE CUSTOM PROPERTY BECAUSE IT IS SPENT TWICE IN THIS RULE -- the border and the
|
|
66
|
+
* calc that adds it to the floor. It stays a plain property rather than a design token: `1px` is
|
|
67
|
+
* written 26 times across five repos and no other border width exists anywhere, so there is nothing
|
|
68
|
+
* for a token to choose between (the contract's `bar.border is a colour and not a width`). What
|
|
69
|
+
* there WAS is the same number typed twice, three lines apart --
|
|
70
|
+
* governance/documents/staleness/a-second-copy-is-a-thing-that-drifts.md at its smallest scale. */
|
|
71
|
+
.newtone-navbar {
|
|
72
|
+
position: sticky;
|
|
73
|
+
top: 0;
|
|
74
|
+
z-index: 10;
|
|
75
|
+
box-sizing: border-box;
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
gap: var(--newtone-navbar-gap);
|
|
79
|
+
min-block-size: calc(var(--newtone-navbar-min-block-size) + var(--newtone-navbar-hairline));
|
|
80
|
+
padding: var(--newtone-navbar-padding-y) var(--newtone-navbar-padding-x);
|
|
81
|
+
background: var(--newtone-navbar-bar-fill);
|
|
82
|
+
border-bottom: var(--newtone-navbar-hairline) solid var(--newtone-navbar-bar-border);
|
|
83
|
+
|
|
84
|
+
--newtone-navbar-hairline: 1px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* What this margin does to the position of the links and the actions, why no prop exposes it, and
|
|
88
|
+
which of the two centres a site writes for itself: blueprints/newtone/contracts/navbar.md,
|
|
89
|
+
"Where the parts sit", and the `align` row in "Deliberately not in v1".
|
|
90
|
+
*
|
|
91
|
+
* IT SAID "THREE CENTRES" UNTIL 2026-09-20 and the contract it points at says two -- three
|
|
92
|
+
* MECHANISMS producing TWO different centres, navbar.md "The bar ships no centre". A comment that
|
|
93
|
+
* sends a reader to a document and disagrees with it about the thing it is sending them for is the
|
|
94
|
+
* worst shape this kind of comment has, because the reader arrives already holding a wrong number.
|
|
95
|
+
* issues/done/136-the-counts-the-issues-carry-that-are-no-longer-true.md.
|
|
96
|
+
*
|
|
97
|
+
* THIS COMMENT WAS THE ONLY STATEMENT OF THE ARRANGEMENT ANYWHERE IN THE HOUSE UNTIL 2026-09-16,
|
|
98
|
+
* and a consumer deciding whether to override had to open this file to find out what it was
|
|
99
|
+
* overriding. It also promised "one rule", which is the wrong centre. Both are in the contract now
|
|
100
|
+
* and neither is restated here: a second copy is a thing that drifts, and of the two copies the
|
|
101
|
+
* contract is the one that leads --
|
|
102
|
+
* governance/documents/staleness/a-second-copy-is-a-thing-that-drifts.md. */
|
|
103
|
+
.newtone-navbar-brand {
|
|
104
|
+
display: inline-flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
color: inherit;
|
|
107
|
+
text-decoration: none;
|
|
108
|
+
margin-right: auto;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.newtone-navbar-links,
|
|
112
|
+
.newtone-navbar-actions {
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
gap: var(--newtone-navbar-gap);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* :focus-visible, not :focus, per contracts/button.md. A navbar is the first thing a keyboard
|
|
119
|
+
reaches on every page, so of everywhere focus could be missing, here is the worst. */
|
|
120
|
+
.newtone-navbar-link:focus-visible,
|
|
121
|
+
.newtone-navbar-brand:focus-visible,
|
|
122
|
+
.newtone-navbar-menu-button:focus-visible {
|
|
123
|
+
outline: 2px solid;
|
|
124
|
+
outline-offset: 2px;
|
|
125
|
+
}
|
|
126
|
+
.newtone-navbar-brand:focus-visible,
|
|
127
|
+
.newtone-navbar-menu-button:focus-visible {
|
|
128
|
+
outline-color: var(--newtone-navbar-link-elsewhere-focus-ring);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* ---- the collapsed panel ------------------------------------------------
|
|
132
|
+
*
|
|
133
|
+
* The same `nav` element, repositioned. There is no second container: writing the links twice
|
|
134
|
+
* would duplicate the id `aria-controls` points at and read every link twice aloud.
|
|
135
|
+
*
|
|
136
|
+
* **All of it is gated on `data-newtone-navbar-collapsible`, which is present only when the site
|
|
137
|
+
* rendered a MenuButton.** Without that gate a bar with no disclosure lost its links entirely on
|
|
138
|
+
* a phone: display:none, and nothing in the page able to undo it. That was found by measuring a
|
|
139
|
+
* real bar at 360px rather than by reading this file.
|
|
140
|
+
*
|
|
141
|
+
* See ../DECISIONS.md, "The navbar's collapsed menu is built ahead of its evidence".
|
|
142
|
+
*/
|
|
143
|
+
@media (max-width: 48rem) {
|
|
144
|
+
.newtone-navbar[data-newtone-navbar-collapsible] .newtone-navbar-menu-button {
|
|
145
|
+
display: inline-flex;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.newtone-navbar[data-newtone-navbar-collapsible] .newtone-navbar-links {
|
|
149
|
+
position: absolute;
|
|
150
|
+
top: 100%;
|
|
151
|
+
left: 0;
|
|
152
|
+
right: 0;
|
|
153
|
+
display: none;
|
|
154
|
+
flex-direction: column;
|
|
155
|
+
align-items: stretch;
|
|
156
|
+
padding: var(--newtone-navbar-padding-y) var(--newtone-navbar-padding-x);
|
|
157
|
+
background: var(--newtone-navbar-bar-fill);
|
|
158
|
+
border-bottom: 1px solid var(--newtone-navbar-bar-border);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.newtone-navbar[data-newtone-navbar-collapsible][data-newtone-navbar-menu-open]
|
|
162
|
+
.newtone-navbar-links {
|
|
163
|
+
display: flex;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* In the collapsed panel a drawer stops floating and becomes part of the list. There is no
|
|
167
|
+
room to hang a panel off a panel, and a reader who has already opened one disclosure should
|
|
168
|
+
not have to reason about a second one overlapping it. */
|
|
169
|
+
.newtone-navbar-drawer-host {
|
|
170
|
+
display: block;
|
|
171
|
+
}
|
|
172
|
+
.newtone-navbar-drawer {
|
|
173
|
+
position: static;
|
|
174
|
+
min-width: 0;
|
|
175
|
+
border: 0;
|
|
176
|
+
border-radius: 0;
|
|
177
|
+
padding-left: var(--newtone-navbar-gap);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { NavbarBrand } from './brand/brand.js';
|
|
3
|
+
import { NavbarLinks } from './links/links.js';
|
|
4
|
+
import { NavbarLink } from './link/link.js';
|
|
5
|
+
import { NavbarActions } from './actions/actions.js';
|
|
6
|
+
import { NavbarMenuButton } from './menu-button/menu-button.js';
|
|
7
|
+
/**
|
|
8
|
+
* Discharges blueprints/newtone/contracts/navbar.md.
|
|
9
|
+
*
|
|
10
|
+
* **The navbar reports. The site decides.** This component publishes the two facts it is the
|
|
11
|
+
* only thing that can see -- whether the page has scrolled past the threshold, and whether its
|
|
12
|
+
* menu is open -- as attributes on the bar, and it has no opinion about what either should
|
|
13
|
+
* mean. There is no `showLogo`, no `showMonogram`, no `collapseOnScroll`, no `hideCtaOnMobile`.
|
|
14
|
+
*
|
|
15
|
+
* That absence is the design and not an omission. Every one of those props is one line to add
|
|
16
|
+
* and is the first half of a pair that can contradict its other half: `showLogo` and
|
|
17
|
+
* `showMonogram` can both be false and something still has to render. A default with an opt-out
|
|
18
|
+
* is the same mistake with a better name -- the moment the bar has an opinion, a site that
|
|
19
|
+
* disagrees needs a second prop to say so.
|
|
20
|
+
*
|
|
21
|
+
* So a site puts both of its marks inside `Navbar.Brand` and writes two CSS rules. Newtone
|
|
22
|
+
* hides its wordmark; joshuaallen.mx compresses a name into a phonetic monogram; a dashboard
|
|
23
|
+
* leaves the slot empty and ignores both attributes. One component, nothing passed to it to
|
|
24
|
+
* tell the three apart.
|
|
25
|
+
*
|
|
26
|
+
* **This is the one contract that binds a single library.** A navbar is a website component and
|
|
27
|
+
* newtone_ui_swift and newtone_ui_android do not build websites. See ../DECISIONS.md.
|
|
28
|
+
*/
|
|
29
|
+
export interface NavbarProps extends HTMLAttributes<HTMLElement> {
|
|
30
|
+
/** Controlled open state for the collapsed menu. Omit for uncontrolled. */
|
|
31
|
+
open?: boolean;
|
|
32
|
+
onOpenChange?: (open: boolean) => void;
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The bar. Sticky, and that is not a prop: `data-newtone-navbar-scrolled` has nothing to report
|
|
37
|
+
* on a bar that scrolls away.
|
|
38
|
+
*
|
|
39
|
+
* **The threshold is a CSS custom property, not a number this file picks.** The sentinel below
|
|
40
|
+
* is absolutely positioned against the document origin -- it has no positioned ancestor -- so it
|
|
41
|
+
* sits at the top of the page, out of flow, taking up no space. Its height is
|
|
42
|
+
* `--newtone-navbar-threshold`, default `1px`, and the attribute appears when it scrolls out of
|
|
43
|
+
* view. A site that wants the swap to happen after the first screenful sets that property to
|
|
44
|
+
* `100vh`. Picking the number here would be this component deciding what a fold is for layouts
|
|
45
|
+
* it has never seen.
|
|
46
|
+
*
|
|
47
|
+
* An IntersectionObserver rather than a scroll handler: a scroll handler runs on every frame of
|
|
48
|
+
* every scroll to answer a question whose answer changes twice a page.
|
|
49
|
+
*/
|
|
50
|
+
export declare function Navbar({ open: openProp, onOpenChange, className, children, ...rest }: NavbarProps): import("react").JSX.Element;
|
|
51
|
+
export declare namespace Navbar {
|
|
52
|
+
export { NavbarBrand as Brand };
|
|
53
|
+
export { NavbarLinks as Links };
|
|
54
|
+
export { NavbarLink as Link };
|
|
55
|
+
export { NavbarActions as Actions };
|
|
56
|
+
export { NavbarMenuButton as MenuButton };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=navbar.d.ts.map
|