@canonical/react-ds-app 0.38.0 → 0.40.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/dist/esm/lib/SideNavigation/SideNavigation.js +51 -9
- package/dist/esm/lib/SideNavigation/SideNavigation.js.map +1 -1
- package/dist/esm/lib/SideNavigation/common/CollapseToggle/CollapseToggle.js +14 -6
- package/dist/esm/lib/SideNavigation/common/CollapseToggle/CollapseToggle.js.map +1 -1
- package/dist/esm/lib/SideNavigation/common/CollapseToggle/styles.css +48 -2
- package/dist/esm/lib/SideNavigation/common/Content/Content.js +9 -5
- package/dist/esm/lib/SideNavigation/common/Content/Content.js.map +1 -1
- package/dist/esm/lib/SideNavigation/common/Content/styles.css +45 -21
- package/dist/esm/lib/SideNavigation/common/ContextSwitcher/ContextSwitcher.js +70 -0
- package/dist/esm/lib/SideNavigation/common/ContextSwitcher/ContextSwitcher.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/ContextSwitcher/index.js +2 -0
- package/dist/esm/lib/SideNavigation/common/ContextSwitcher/index.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/ContextSwitcher/styles.css +94 -0
- package/dist/esm/lib/SideNavigation/common/ContextSwitcher/types.js +2 -0
- package/dist/esm/lib/SideNavigation/common/ContextSwitcher/types.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Footer/Footer.js +46 -6
- package/dist/esm/lib/SideNavigation/common/Footer/Footer.js.map +1 -1
- package/dist/esm/lib/SideNavigation/common/Footer/styles.css +13 -3
- package/dist/esm/lib/SideNavigation/common/Group/Group.js +14 -0
- package/dist/esm/lib/SideNavigation/common/Group/Group.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Group/index.js +2 -0
- package/dist/esm/lib/SideNavigation/common/Group/index.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Group/styles.css +18 -0
- package/dist/esm/lib/SideNavigation/common/Group/types.js +2 -0
- package/dist/esm/lib/SideNavigation/common/Group/types.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/GroupHeader/GroupHeader.js +17 -0
- package/dist/esm/lib/SideNavigation/common/GroupHeader/GroupHeader.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/GroupHeader/index.js +2 -0
- package/dist/esm/lib/SideNavigation/common/GroupHeader/index.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/GroupHeader/styles.css +31 -0
- package/dist/esm/lib/SideNavigation/common/GroupHeader/types.js +2 -0
- package/dist/esm/lib/SideNavigation/common/GroupHeader/types.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Header/Header.js +4 -2
- package/dist/esm/lib/SideNavigation/common/Header/Header.js.map +1 -1
- package/dist/esm/lib/SideNavigation/common/Header/styles.css +66 -28
- package/dist/esm/lib/SideNavigation/common/Item/Item.js +9 -13
- package/dist/esm/lib/SideNavigation/common/Item/Item.js.map +1 -1
- package/dist/esm/lib/SideNavigation/common/Item/styles.css +71 -36
- package/dist/esm/lib/SideNavigation/common/ItemButton/ItemButton.js +18 -0
- package/dist/esm/lib/SideNavigation/common/ItemButton/ItemButton.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/ItemButton/index.js +2 -0
- package/dist/esm/lib/SideNavigation/common/ItemButton/index.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/ItemButton/styles.css +79 -0
- package/dist/esm/lib/SideNavigation/common/ItemButton/types.js +2 -0
- package/dist/esm/lib/SideNavigation/common/ItemButton/types.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/ItemExpandable/ItemExpandable.js +71 -0
- package/dist/esm/lib/SideNavigation/common/ItemExpandable/ItemExpandable.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/ItemExpandable/index.js +2 -0
- package/dist/esm/lib/SideNavigation/common/ItemExpandable/index.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/ItemExpandable/styles.css +121 -0
- package/dist/esm/lib/SideNavigation/common/ItemExpandable/types.js +2 -0
- package/dist/esm/lib/SideNavigation/common/ItemExpandable/types.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/NavTree/NavTree.js +63 -21
- package/dist/esm/lib/SideNavigation/common/NavTree/NavTree.js.map +1 -1
- package/dist/esm/lib/SideNavigation/common/NavTree/styles.css +7 -30
- package/dist/esm/lib/SideNavigation/common/index.js +5 -0
- package/dist/esm/lib/SideNavigation/common/index.js.map +1 -1
- package/dist/esm/lib/SideNavigation/helpItem.js +29 -0
- package/dist/esm/lib/SideNavigation/helpItem.js.map +1 -0
- package/dist/esm/lib/SideNavigation/hooks/useCollapseShortcut/index.js +2 -0
- package/dist/esm/lib/SideNavigation/hooks/useCollapseShortcut/index.js.map +1 -0
- package/dist/esm/lib/SideNavigation/hooks/useCollapseShortcut/types.js +2 -0
- package/dist/esm/lib/SideNavigation/hooks/useCollapseShortcut/types.js.map +1 -0
- package/dist/esm/lib/SideNavigation/hooks/useCollapseShortcut/useCollapseShortcut.js +45 -0
- package/dist/esm/lib/SideNavigation/hooks/useCollapseShortcut/useCollapseShortcut.js.map +1 -0
- package/dist/esm/lib/SideNavigation/index.js +1 -0
- package/dist/esm/lib/SideNavigation/index.js.map +1 -1
- package/dist/esm/lib/SideNavigation/styles.css +272 -19
- package/dist/types/lib/SideNavigation/SideNavigation.d.ts +22 -1
- package/dist/types/lib/SideNavigation/SideNavigation.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/CollapseToggle/CollapseToggle.d.ts +9 -2
- package/dist/types/lib/SideNavigation/common/CollapseToggle/CollapseToggle.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/CollapseToggle/types.d.ts +6 -1
- package/dist/types/lib/SideNavigation/common/CollapseToggle/types.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Content/Content.d.ts +8 -4
- package/dist/types/lib/SideNavigation/common/Content/Content.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Content/types.d.ts +5 -8
- package/dist/types/lib/SideNavigation/common/Content/types.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/ContextSwitcher/ContextSwitcher.d.ts +20 -0
- package/dist/types/lib/SideNavigation/common/ContextSwitcher/ContextSwitcher.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/ContextSwitcher/index.d.ts +3 -0
- package/dist/types/lib/SideNavigation/common/ContextSwitcher/index.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/ContextSwitcher/types.d.ts +52 -0
- package/dist/types/lib/SideNavigation/common/ContextSwitcher/types.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Footer/Footer.d.ts +8 -4
- package/dist/types/lib/SideNavigation/common/Footer/Footer.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Footer/types.d.ts +5 -8
- package/dist/types/lib/SideNavigation/common/Footer/types.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Group/Group.d.ts +13 -0
- package/dist/types/lib/SideNavigation/common/Group/Group.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Group/index.d.ts +3 -0
- package/dist/types/lib/SideNavigation/common/Group/index.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Group/types.d.ts +10 -0
- package/dist/types/lib/SideNavigation/common/Group/types.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/GroupHeader/GroupHeader.d.ts +13 -0
- package/dist/types/lib/SideNavigation/common/GroupHeader/GroupHeader.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/GroupHeader/index.d.ts +3 -0
- package/dist/types/lib/SideNavigation/common/GroupHeader/index.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/GroupHeader/types.d.ts +8 -0
- package/dist/types/lib/SideNavigation/common/GroupHeader/types.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Header/Header.d.ts +3 -1
- package/dist/types/lib/SideNavigation/common/Header/Header.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Item/Item.d.ts +8 -9
- package/dist/types/lib/SideNavigation/common/Item/Item.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Item/types.d.ts +18 -7
- package/dist/types/lib/SideNavigation/common/Item/types.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/ItemButton/ItemButton.d.ts +17 -0
- package/dist/types/lib/SideNavigation/common/ItemButton/ItemButton.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/ItemButton/index.d.ts +3 -0
- package/dist/types/lib/SideNavigation/common/ItemButton/index.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/ItemButton/types.d.ts +17 -0
- package/dist/types/lib/SideNavigation/common/ItemButton/types.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/ItemExpandable/ItemExpandable.d.ts +26 -0
- package/dist/types/lib/SideNavigation/common/ItemExpandable/ItemExpandable.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/ItemExpandable/index.d.ts +3 -0
- package/dist/types/lib/SideNavigation/common/ItemExpandable/index.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/ItemExpandable/types.d.ts +32 -0
- package/dist/types/lib/SideNavigation/common/ItemExpandable/types.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/NavTree/NavTree.d.ts +12 -13
- package/dist/types/lib/SideNavigation/common/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/NavTree/types.d.ts +7 -5
- package/dist/types/lib/SideNavigation/common/NavTree/types.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/index.d.ts +5 -0
- package/dist/types/lib/SideNavigation/common/index.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/helpItem.d.ts +20 -0
- package/dist/types/lib/SideNavigation/helpItem.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/hooks/useCollapseShortcut/index.d.ts +3 -0
- package/dist/types/lib/SideNavigation/hooks/useCollapseShortcut/index.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/hooks/useCollapseShortcut/types.d.ts +14 -0
- package/dist/types/lib/SideNavigation/hooks/useCollapseShortcut/types.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/hooks/useCollapseShortcut/useCollapseShortcut.d.ts +14 -0
- package/dist/types/lib/SideNavigation/hooks/useCollapseShortcut/useCollapseShortcut.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/index.d.ts +1 -0
- package/dist/types/lib/SideNavigation/index.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/types.d.ts +168 -24
- package/dist/types/lib/SideNavigation/types.d.ts.map +1 -1
- package/package.json +17 -17
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useId, useState } from "react";
|
|
3
|
-
import { Content, Footer, Header } from "./common/index.js";
|
|
2
|
+
import { useCallback, useEffect, useId, useState } from "react";
|
|
3
|
+
import { Content, ContextSwitcher, Footer, Header } from "./common/index.js";
|
|
4
|
+
import { useCollapseShortcut } from "./hooks/useCollapseShortcut/index.js";
|
|
4
5
|
import "./styles.css";
|
|
5
6
|
const componentCssClassName = "ds side-navigation";
|
|
6
7
|
/**
|
|
@@ -9,23 +10,60 @@ const componentCssClassName = "ds side-navigation";
|
|
|
9
10
|
* `defaultExpanded` — and wires the header's collapse toggle to the content
|
|
10
11
|
* region it controls.
|
|
11
12
|
*
|
|
13
|
+
* Four regions: Header (branding, collapse toggle), the optional
|
|
14
|
+
* ContextSwitcher region (a `role="menu"` select-like widget — not
|
|
15
|
+
* navigation, so it sits outside the landmark in a plain `<div>` between
|
|
16
|
+
* Header and Content; hidden when collapsed, where labels are unviable),
|
|
17
|
+
* Content (the main `<nav>` landmark) and Footer (user profile, settings
|
|
18
|
+
* and non-navigational actions). The root element is a plain `<div>` and
|
|
19
|
+
* the component's single *navigation* landmark is Content's `<nav>`, so
|
|
20
|
+
* screen readers announce exactly one navigation region; the regions
|
|
21
|
+
* themselves are `<header>`/`<footer>` elements, which additionally
|
|
22
|
+
* expose banner/contentinfo landmarks. `aria-label` is forwarded to the
|
|
23
|
+
* `<nav>` and defaults to `"Main navigation"`.
|
|
24
|
+
*
|
|
25
|
+
* A visually hidden "Skip to main content" link is the first element in the
|
|
26
|
+
* component's DOM order, so keyboard users can bypass the navigation block;
|
|
27
|
+
* target it with `skipTo` (default `"#main-content"`).
|
|
28
|
+
*
|
|
12
29
|
* Routing-agnostic: navigable items render via `LinkComponent` (default `"a"`);
|
|
13
30
|
* pass a router `Link` to integrate client-side navigation. The active item is
|
|
14
31
|
* resolved from `currentUrl`.
|
|
15
32
|
*
|
|
33
|
+
* Consumption pattern: data-driven only. Pass props and all four regions
|
|
34
|
+
* build; row-level and region components are private
|
|
35
|
+
* (`cs:react.component.subcomponent_export_api` — no dot-static exports),
|
|
36
|
+
* and render exclusively from data.
|
|
37
|
+
*
|
|
16
38
|
* @implements ds:apps.pattern.side-navigation
|
|
17
39
|
*/
|
|
18
|
-
const SideNavigation = ({ className, brand, applicationName, root, footerRoot, LinkComponent = "a", currentUrl,
|
|
40
|
+
const SideNavigation = ({ className, brand, applicationName, root, contextSwitcher, footerRoot, LinkComponent = "a", currentUrl, skipTo = "#main-content",
|
|
19
41
|
// Controlled circuit — not official yet.
|
|
20
42
|
// expanded: expandedProp,
|
|
21
|
-
defaultExpanded
|
|
43
|
+
defaultExpanded: defaultExpandedProp,
|
|
22
44
|
// onExpandedChange,
|
|
23
|
-
...props }) => {
|
|
45
|
+
keyboardShortcut = true, "aria-label": ariaLabel, ...props }) => {
|
|
24
46
|
const contentId = useId();
|
|
25
|
-
const [expanded, setExpanded] = useState(
|
|
47
|
+
const [expanded, setExpanded] = useState(defaultExpandedProp ?? true);
|
|
48
|
+
// Mobile seed: below the small breakpoint, the
|
|
49
|
+
// expanded state renders as a fullscreen fixed overlay — a takeover, not a
|
|
50
|
+
// rail — so with `defaultExpanded` left unset (desktop default `true`), a
|
|
51
|
+
// small viewport collapses the rail after mount instead. An explicit
|
|
52
|
+
// `defaultExpanded` always wins, on every viewport. Post-mount on purpose:
|
|
53
|
+
// the server cannot know the viewport, so SSR/hydration stay pure — the
|
|
54
|
+
// cost is one frame of the expanded rail on a phone before the flip.
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (defaultExpandedProp !== undefined)
|
|
57
|
+
return;
|
|
58
|
+
if (window.matchMedia("(width < 620px)").matches)
|
|
59
|
+
setExpanded(false);
|
|
60
|
+
}, [defaultExpandedProp]);
|
|
26
61
|
const handleToggle = useCallback(() => {
|
|
27
62
|
setExpanded((current) => !current);
|
|
28
63
|
}, []);
|
|
64
|
+
// Ctrl+B rail-collapse shortcut — on unless
|
|
65
|
+
// `keyboardShortcut` opts out. See hooks/useCollapseShortcut.
|
|
66
|
+
useCollapseShortcut({ condition: keyboardShortcut, onTrigger: handleToggle });
|
|
29
67
|
// --- Controlled circuit (not official yet) -------------------------------
|
|
30
68
|
// const [uncontrolledExpanded, setUncontrolledExpanded] =
|
|
31
69
|
// useState(defaultExpanded);
|
|
@@ -38,9 +76,13 @@ defaultExpanded = true,
|
|
|
38
76
|
// onExpandedChange?.(next);
|
|
39
77
|
// }, [expanded, isControlled, onExpandedChange]);
|
|
40
78
|
// -------------------------------------------------------------------------
|
|
41
|
-
return (_jsxs("div", { className: [componentCssClassName,
|
|
42
|
-
|
|
43
|
-
|
|
79
|
+
return (_jsxs("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), "data-expanded": expanded, ...props, children: [_jsx("a", { className: "skip-link", href: skipTo, children: "Skip to main content" }), _jsx(Header, { brand: brand, applicationName: applicationName, expanded: expanded, onToggle: handleToggle, collapseControls: contentId }), contextSwitcher ? (
|
|
80
|
+
// Own plain <div> region — a select-like widget is not navigation,
|
|
81
|
+
// so it sits outside the <nav> landmark. Hidden when collapsed:
|
|
82
|
+
// its rows are label-driven, unviable icon-only (the collapsed CSS
|
|
83
|
+
// hides the region via the root's data-expanded, so the region
|
|
84
|
+
// carries no state of its own).
|
|
85
|
+
_jsx("div", { className: "ds side-navigation-context-switcher-region", children: _jsx(ContextSwitcher, { ...contextSwitcher }) })) : null, _jsx(Content, { id: contentId, root: root, LinkComponent: LinkComponent, currentUrl: currentUrl, "aria-label": ariaLabel ?? "Main navigation" }), footerRoot ? (_jsx(Footer, { root: footerRoot, LinkComponent: LinkComponent, currentUrl: currentUrl })) : null] }));
|
|
44
86
|
};
|
|
45
87
|
export default SideNavigation;
|
|
46
88
|
//# sourceMappingURL=SideNavigation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideNavigation.js","sourceRoot":"","sources":["../../../../src/lib/SideNavigation/SideNavigation.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SideNavigation.js","sourceRoot":"","sources":["../../../../src/lib/SideNavigation/SideNavigation.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,cAAc,GAAG,CAAC,EACtB,SAAS,EACT,KAAK,EACL,eAAe,EACf,IAAI,EACJ,eAAe,EACf,UAAU,EACV,aAAa,GAAG,GAAG,EACnB,UAAU,EACV,MAAM,GAAG,eAAe;AACxB,yCAAyC;AACzC,0BAA0B;AAC1B,eAAe,EAAE,mBAAmB;AACpC,oBAAoB;AACpB,gBAAgB,GAAG,IAAI,EACvB,YAAY,EAAE,SAAS,EACvB,GAAG,KAAK,EACY,EAAsB,EAAE;IAC5C,MAAM,SAAS,GAAG,KA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EACtB,gBAAgB,EAAE,SAAS,GAC3B,EACD,eAAe,CAAC,CAAC,CAAC;YACjB,mEAAmE;YACnE,gEAAgE;YAChE,mEAAmE;YACnE,+DAA+D;YAC/D,gCAAgC;YAChC,cAAK,SAAS,EAAC,4CAA4C,YACzD,KAAC,eAAe,OAAK,eAAe,GAAI,GACpC,CACP,CAAC,CAAC,CAAC,IAAI,EACR,KAAC,OAAO,IACN,EAAE,EAAE,SAAS,EACb,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,gBACV,SAAS,IAAI,iBAAiB,GAC1C,EACD,UAAU,CAAC,CAAC,CAAC,CACZ,KAAC,MAAM,IACL,IAAI,EAAE,UAAU,EAChB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,GACtB,CACH,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Icon } from "@canonical/react-ds-global";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon, TooltipEngine } from "@canonical/react-ds-global";
|
|
3
3
|
import "./styles.css";
|
|
4
4
|
const componentCssClassName = "ds collapse-toggle";
|
|
5
|
+
const CollapseToggleButton = ({ className, expanded = true, "aria-label": ariaLabel, ...props }) => {
|
|
6
|
+
return (_jsxs("button", { className: [componentCssClassName, className].filter(Boolean).join(" "), "aria-expanded": expanded, "aria-label": ariaLabel ?? (expanded ? "Collapse navigation" : "Expand navigation"), ...props, type: "button", children: [_jsx(Icon, { icon: expanded ? "collapse-side-nav" : "expand-side-nav" }), _jsx("span", { className: "p", children: expanded ? "Close menu" : "Menu" })] }));
|
|
7
|
+
};
|
|
5
8
|
/**
|
|
6
9
|
* SideNavigation.CollapseToggle — icon-only button that expands or collapses
|
|
7
10
|
* the navigation rail. Carries the disclosure ARIA contract: `aria-expanded`
|
|
8
11
|
* reflects the current state and `aria-controls` should point at the id of the
|
|
9
|
-
* navigation region it toggles.
|
|
12
|
+
* navigation region it toggles. Hovering for 1s shows a tooltip naming the
|
|
13
|
+
* action ("Collapse"/"Expand"); the `<button>`'s own
|
|
14
|
+
* `aria-label` carries the fuller "Collapse/Expand navigation" text.
|
|
15
|
+
*
|
|
16
|
+
* Rendered through `TooltipEngine` (not `withTooltip`) so the tooltip's
|
|
17
|
+
* message follows the `expanded` prop as a live prop: one stable element
|
|
18
|
+
* type across state changes, so the button — and with it keyboard focus
|
|
19
|
+
* and hover state — survives every toggle instead of remounting.
|
|
10
20
|
*
|
|
11
21
|
* @implements ds:apps.subcomponent.side-navigation-collapse-toggle
|
|
12
22
|
*/
|
|
13
|
-
const CollapseToggle = ({
|
|
14
|
-
return (_jsx("button", { type: "button", className: [componentCssClassName, className].filter(Boolean).join(" "), "aria-expanded": expanded, "aria-label": ariaLabel ?? (expanded ? "Collapse navigation" : "Expand navigation"), ...props, children: _jsx(Icon, { icon: expanded ? "collapse-side-nav" : "expand-side-nav" }) }));
|
|
15
|
-
};
|
|
23
|
+
const CollapseToggle = ({ expanded = true, ...props }) => (_jsx(TooltipEngine, { Message: expanded ? "Collapse" : "Expand", activateDelay: 1000, children: _jsx(CollapseToggleButton, { expanded: expanded, ...props }) }));
|
|
16
24
|
export default CollapseToggle;
|
|
17
25
|
//# sourceMappingURL=CollapseToggle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollapseToggle.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/CollapseToggle/CollapseToggle.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"CollapseToggle.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/CollapseToggle/CollapseToggle.tsx"],"names":[],"m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cascade layers"). */
|
|
3
|
-
|
|
4
3
|
@layer ds.components.apps {
|
|
5
4
|
.ds.collapse-toggle {
|
|
6
|
-
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
|
|
9
|
+
/* size matches collapse icons */
|
|
10
|
+
inline-size: calc(var(--dimension-400) + var(--dimension-050));
|
|
11
|
+
block-size: var(--dimension-400);
|
|
12
|
+
|
|
13
|
+
border: none;
|
|
14
|
+
border-radius: var(--dimension-radius-small);
|
|
15
|
+
background: transparent;
|
|
16
|
+
color: var(--color-icon);
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
|
|
19
|
+
/* The hover/press background swap is instant by design — no
|
|
20
|
+
`transition` property here. */
|
|
21
|
+
&:hover {
|
|
22
|
+
background: var(--sidenav-row-background-hover);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&:active {
|
|
26
|
+
background: var(--sidenav-row-background-active);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Icon (desktop) vs "Menu"/"Close menu" text (mobile) — plain CSS-toggled
|
|
30
|
+
siblings, not a JS media-query read, so the choice needs no client-only
|
|
31
|
+
branch and stays SSR-identical. The button's only two children are the
|
|
32
|
+
icon svg and the label span, so the two select directly. */
|
|
33
|
+
& span {
|
|
34
|
+
display: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Vanilla's "small" breakpoint — $breakpoint-small, 620px. */
|
|
38
|
+
@media (width < 620px) {
|
|
39
|
+
& svg {
|
|
40
|
+
display: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
& span {
|
|
44
|
+
display: inline;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* No longer an icon-only square — a text button sized to its content. */
|
|
48
|
+
inline-size: auto;
|
|
49
|
+
block-size: auto;
|
|
50
|
+
padding-block: var(--sidenav-icon-gap); /* 0.5rem */
|
|
51
|
+
padding-inline: var(--sidenav-inset-inline); /* 0.5rem */
|
|
52
|
+
}
|
|
7
53
|
}
|
|
8
54
|
}
|
|
@@ -3,14 +3,18 @@ import { NavTree } from "../NavTree/index.js";
|
|
|
3
3
|
import "./styles.css";
|
|
4
4
|
const componentCssClassName = "ds content";
|
|
5
5
|
/**
|
|
6
|
-
* SideNavigation.Content — main
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* SideNavigation.Content — the component's main `<nav>` landmark, and the
|
|
7
|
+
* only one: navigation rows are links and expandable items exclusively
|
|
8
|
+
* (actions are Footer's job). Data-only — rows render exclusively from the
|
|
9
|
+
* `root` tree (row components are private; there is no children escape
|
|
10
|
+
* hatch into the landmark). `aria-label` defaults to `"Main navigation"`
|
|
11
|
+
* and may be overridden by the consumer; with no `root`, the landmark
|
|
12
|
+
* renders empty (the landmark contract stays stable).
|
|
9
13
|
*
|
|
10
14
|
* @implements ds:apps.subcomponent.side-navigation-content
|
|
11
15
|
*/
|
|
12
|
-
const Content = ({ className, root, LinkComponent = "a", currentUrl,
|
|
13
|
-
return (_jsx("
|
|
16
|
+
const Content = ({ className, root, LinkComponent = "a", currentUrl, ...props }) => {
|
|
17
|
+
return (_jsx("nav", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: root ? (_jsx(NavTree, { root: root, currentUrl: currentUrl, LinkComponent: LinkComponent })) : null }));
|
|
14
18
|
};
|
|
15
19
|
export default Content;
|
|
16
20
|
//# sourceMappingURL=Content.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Content.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Content/Content.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAE3C
|
|
1
|
+
{"version":3,"file":"Content.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Content/Content.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,GAAG,CAAC,EACf,SAAS,EACT,IAAI,EACJ,aAAa,GAAG,GAAG,EACnB,UAAU,EACV,GAAG,KAAK,EACK,EAAsB,EAAE;IACrC,OAAO,CACL,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,YAER,IAAI,CAAC,CAAC,CAAC,CACN,KAAC,OAAO,IACN,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,GAC5B,CACH,CAAC,CAAC,CAAC,IAAI,GACJ,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1,36 +1,60 @@
|
|
|
1
1
|
/* Generated by @canonical/summon-component:react v0.1.0
|
|
2
2
|
* Layer: ds.components.apps (@canonical/styles README, "Cascade layers"). */
|
|
3
|
-
|
|
4
3
|
@layer ds.components.apps {
|
|
5
4
|
.ds.content {
|
|
6
5
|
position: relative;
|
|
7
6
|
flex: 1;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
never horizontal (long labels must not cause sideways scroll). */
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
gap: var(--dimension-100);
|
|
12
10
|
min-height: 0;
|
|
13
11
|
overflow: hidden auto;
|
|
12
|
+
container-type: scroll-state;
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
& .nav-tree > .group:last-child > .list {
|
|
19
|
-
padding-block-end: var(--overflow-gradient-height);
|
|
14
|
+
scrollbar-width: none;
|
|
15
|
+
&::-webkit-scrollbar {
|
|
16
|
+
display: none;
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
painting the surface-aware gradient over content scrolling underneath. */
|
|
19
|
+
&::before,
|
|
24
20
|
&::after {
|
|
25
|
-
content:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
content: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@container scroll-state(scrollable: top) {
|
|
25
|
+
&::before {
|
|
26
|
+
content: "";
|
|
27
|
+
position: sticky;
|
|
28
|
+
top: 0;
|
|
29
|
+
display: block;
|
|
30
|
+
block-size: var(--overflow-gradient-height);
|
|
31
|
+
margin-block-end: calc(-1 * var(--overflow-gradient-height));
|
|
32
|
+
background: linear-gradient(
|
|
33
|
+
to bottom,
|
|
34
|
+
var(--color-foreground-navigation-primary),
|
|
35
|
+
transparent
|
|
36
|
+
);
|
|
37
|
+
pointer-events: none;
|
|
38
|
+
flex: 0 0 auto;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@container scroll-state(scrollable: bottom) {
|
|
43
|
+
&::after {
|
|
44
|
+
content: "";
|
|
45
|
+
position: sticky;
|
|
46
|
+
bottom: 0;
|
|
47
|
+
display: block;
|
|
48
|
+
block-size: var(--overflow-gradient-height);
|
|
49
|
+
margin-block-start: calc(-1 * var(--overflow-gradient-height));
|
|
50
|
+
background: linear-gradient(
|
|
51
|
+
to bottom,
|
|
52
|
+
transparent,
|
|
53
|
+
var(--color-foreground-navigation-primary)
|
|
54
|
+
);
|
|
55
|
+
pointer-events: none;
|
|
56
|
+
flex: 0 0 auto;
|
|
57
|
+
}
|
|
34
58
|
}
|
|
35
59
|
}
|
|
36
60
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ContextualMenu, Icon } from "@canonical/react-ds-global";
|
|
3
|
+
import { GroupHeader } from "../GroupHeader/index.js";
|
|
4
|
+
import "./styles.css";
|
|
5
|
+
const componentCssClassName = "ds side-navigation-context-switcher";
|
|
6
|
+
/**
|
|
7
|
+
* A context or "create context" entry — see {@link ContextMenuItem}.
|
|
8
|
+
*/
|
|
9
|
+
const ContextItemContent = ({ item, }) => {
|
|
10
|
+
const { description, badge, isCurrent, renderLabel } = item;
|
|
11
|
+
// The "create context" action: a plain icon + label row.
|
|
12
|
+
if (renderLabel != null) {
|
|
13
|
+
return (_jsxs("span", { className: "create-context", children: [_jsx(Icon, { icon: "plus" }), _jsx("span", { className: "label", children: renderLabel })] }));
|
|
14
|
+
}
|
|
15
|
+
return (_jsxs("span", { className: ["content", isCurrent && "current"].filter(Boolean).join(" "), children: [_jsx("span", { className: "name", children: item.label }), description ? _jsx("span", { className: "description", children: description }) : null, badge ? _jsx("span", { className: "badge", children: badge }) : null] }));
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* SideNavigation.ContextSwitcher — a dropdown for products that divide
|
|
19
|
+
* into contexts, projects, users, or similar. Renders via
|
|
20
|
+
* `ContextualMenu`: a real `<button>` trigger
|
|
21
|
+
* (`aria-haspopup="menu"`/`aria-expanded`) and a `role="menu"` popup with
|
|
22
|
+
* full roving-focus keyboard navigation. `title`, when given, renders via
|
|
23
|
+
* `SideNavigation.GroupHeader` as a sibling above the dropdown field.
|
|
24
|
+
*
|
|
25
|
+
* Not part of the `NavRoot`/`NavGroup` content-tree data model — its
|
|
26
|
+
* position is content-defined: compose this component directly where
|
|
27
|
+
* the consumer wants it. See SPEC.md's known issues.
|
|
28
|
+
*
|
|
29
|
+
* @implements ds:apps.subcomponent.side-navigation-context-switcher
|
|
30
|
+
*/
|
|
31
|
+
const ContextSwitcher = ({ title, currentContext, contexts, onContextChange, onCreateContext, createContextLabel = "Create context", className, open, onOpenChange, preferredDirections, distance, gutter, maxWidth, autoFit, ...props }) => {
|
|
32
|
+
const contextItems = contexts.map((context) => ({
|
|
33
|
+
key: context.key,
|
|
34
|
+
label: context.name,
|
|
35
|
+
description: context.description,
|
|
36
|
+
badge: context.badge,
|
|
37
|
+
isCurrent: context.key === currentContext.key,
|
|
38
|
+
displayItemsType: "custom",
|
|
39
|
+
Component: ContextItemContent,
|
|
40
|
+
}));
|
|
41
|
+
const items = contextItems;
|
|
42
|
+
if (onCreateContext) {
|
|
43
|
+
const createContextItem = {
|
|
44
|
+
key: "create-context",
|
|
45
|
+
// A plain string for type-ahead bookkeeping — the visible (possibly
|
|
46
|
+
// rich) content renders via `renderLabel` in ContextItemContent.
|
|
47
|
+
label: typeof createContextLabel === "string"
|
|
48
|
+
? createContextLabel
|
|
49
|
+
: "Create context",
|
|
50
|
+
renderLabel: createContextLabel,
|
|
51
|
+
displayItemsType: "custom",
|
|
52
|
+
Component: ContextItemContent,
|
|
53
|
+
};
|
|
54
|
+
items.push({ type: "separator", key: "create-context-separator" });
|
|
55
|
+
items.push(createContextItem);
|
|
56
|
+
}
|
|
57
|
+
const handleSelect = (item) => {
|
|
58
|
+
if (item.key === "create-context") {
|
|
59
|
+
onCreateContext?.();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const context = contexts.find((candidate) => candidate.key === item.key);
|
|
63
|
+
if (context)
|
|
64
|
+
onContextChange?.(context);
|
|
65
|
+
};
|
|
66
|
+
return (_jsxs("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: [title != null && _jsx(GroupHeader, { children: title }), _jsx(ContextualMenu, { open: open, onOpenChange: onOpenChange, preferredDirections: preferredDirections, distance: distance, gutter: gutter, maxWidth: maxWidth ??
|
|
67
|
+
"calc(var(--sidenav-rail-inline-size) - 2 * var(--sidenav-inset-inline))", autoFit: autoFit, items: items, onSelect: handleSelect, children: _jsxs("span", { className: "row", children: [_jsx("span", { className: "label", children: currentContext.name }), _jsx(Icon, { icon: "chevron-down", className: "end caret" })] }) })] }));
|
|
68
|
+
};
|
|
69
|
+
export default ContextSwitcher;
|
|
70
|
+
//# sourceMappingURL=ContextSwitcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextSwitcher.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/ContextSwitcher/ContextSwitcher.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,qCAAqC,CAAC;AAiBpE;;GAEG;AACH,MAAM,kBAAkB,GAAG,CAAC,EAC1B,IAAI,GAGL,EAAsB,EAAE;IACvB,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,GAClD,IAAuB,CAAC;IAE1B,yDAAyD;IACzD,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;QACxB,OAAO,CACL,gBAAM,SAAS,EAAC,gBAAgB,aAC9B,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,EACpB,eAAM,SAAS,EAAC,OAAO,YAAE,WAAW,GAAQ,IACvC,CACR,CAAC;IACJ,CAAC;IAED,OAAO,CACL,gBACE,SAAS,EAAE,CAAC,SAAS,EAAE,SAAS,IAAI,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,aAExE,eAAM,SAAS,EAAC,MAAM,YAAE,IAAI,CAAC,KAAK,GAAQ,EACzC,WAAW,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,aAAa,YAAE,WAAW,GAAQ,CAAC,CAAC,CAAC,IAAI,EACvE,KAAK,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,OAAO,YAAE,KAAK,GAAQ,CAAC,CAAC,CAAC,IAAI,IACjD,CACR,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,eAAe,GAAG,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AAC;YACpB,OAAO;QACT,CAAC;QACD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC;QACzE,IAAI,OAAO;YAAE,eAAe,EAAE,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC,CAAC;IAEF,OAAO,CACL,eACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,aAER,KAAK,IAAI,IAAI,IAAI,KAAC,WAAW,cAAE,KAAK,GAAe,EACpD,KAAC,cAAc,IACb,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,mBAAmB,EAAE,mBAAmB,EACxC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EACN,QAAQ;oBACR,yEAAyE,EAE3E,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,YAAY,YAEtB,gBAAM,SAAS,EAAC,KAAK,aACnB,eAAM,SAAS,EAAC,OAAO,YAAE,cAAc,CAAC,IAAI,GAAQ,EACpD,KAAC,IAAI,IAAC,IAAI,EAAC,cAAc,EAAC,SAAS,EAAC,WAAW,GAAG,IAC7C,GACQ,IACb,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/ContextSwitcher/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* Generated by @canonical/summon-component:react v0.1.0
|
|
2
|
+
* Layer: ds.components.apps (@canonical/styles README, "Cascade layers"). */
|
|
3
|
+
@layer ds.components.apps {
|
|
4
|
+
.ds.side-navigation-context-switcher {
|
|
5
|
+
display: block;
|
|
6
|
+
|
|
7
|
+
/* ContextualMenu's own root — the dropdown field fills the wrapper
|
|
8
|
+
(its inline-block default is for inline placements; the rail is a
|
|
9
|
+
block column). */
|
|
10
|
+
& > .ds.contextual-menu {
|
|
11
|
+
display: block;
|
|
12
|
+
height: var(--dimension-400);
|
|
13
|
+
|
|
14
|
+
& > .trigger {
|
|
15
|
+
height: 100%;
|
|
16
|
+
display: grid;
|
|
17
|
+
grid-template-columns: 1fr auto;
|
|
18
|
+
align-items: center;
|
|
19
|
+
width: 100%;
|
|
20
|
+
padding-block: var(--sidenav-icon-gap);
|
|
21
|
+
padding-inline: var(--sidenav-icon-gap);
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
color: var(--color-text);
|
|
24
|
+
background: var(--color-foreground-input);
|
|
25
|
+
border: none;
|
|
26
|
+
border-block-end: var(--dimension-stroke-thickness-medium) solid
|
|
27
|
+
var(--color-border);
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
|
|
30
|
+
&:hover {
|
|
31
|
+
background: var(--color-foreground-input-hover);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
& > .row {
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: space-between;
|
|
38
|
+
gap: var(--sidenav-icon-gap);
|
|
39
|
+
width: 100%;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
& .label {
|
|
45
|
+
min-width: 0;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
text-overflow: ellipsis;
|
|
48
|
+
white-space: nowrap;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
& .end.caret {
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
color: var(--color-icon);
|
|
55
|
+
flex-shrink: 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.ds.contextual-menu-item {
|
|
60
|
+
/* The portaled menu items are styled structurally — this sheet's layer
|
|
61
|
+
(ds.components.apps) outranks the item's own (ds.components.global)
|
|
62
|
+
at equal specificity. Both classes are emitted only by this
|
|
63
|
+
component's renderer, so no other ContextualMenu on the page is
|
|
64
|
+
affected. */
|
|
65
|
+
/* A context: name + optional description + optional badge. */
|
|
66
|
+
& .content {
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
align-items: flex-start;
|
|
70
|
+
width: 100%;
|
|
71
|
+
gap: var(--dimension-025);
|
|
72
|
+
|
|
73
|
+
& .description {
|
|
74
|
+
color: var(--color-text-muted);
|
|
75
|
+
font-size: var(--typography-text-secondary-font-size);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
& .badge {
|
|
79
|
+
position: absolute;
|
|
80
|
+
align-self: flex-end;
|
|
81
|
+
}
|
|
82
|
+
&.current .name {
|
|
83
|
+
font-weight: var(--typography-weight-medium);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* The "create context" action: an icon + label row. */
|
|
88
|
+
& .create-context {
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
gap: var(--dimension-100);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/ContextSwitcher/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,16 +1,56 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Item } from "../Item/index.js";
|
|
3
|
+
import { ItemButton } from "../ItemButton/index.js";
|
|
4
|
+
import { ItemExpandable } from "../ItemExpandable/index.js";
|
|
3
5
|
import "./styles.css";
|
|
4
6
|
const componentCssClassName = "ds footer";
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* `
|
|
8
|
+
* Renders one footer leaf row. The Footer is the one place a navigation row
|
|
9
|
+
* may be a button. Three-way dispatch: a navigable item (`url` set,
|
|
10
|
+
* `control` not `"button"`) renders as `Item` (a link via `LinkComponent`,
|
|
11
|
+
* active when current); an action item (`control: "button"`, or `onClick`
|
|
12
|
+
* with no `url`) renders as `ItemButton`; anything else — a label-only row
|
|
13
|
+
* like a logged-in username — renders as `Item`'s plain label row, NOT an
|
|
14
|
+
* inert `<button>` announced as an action that does nothing. Explicit
|
|
15
|
+
* `control` always wins over the `url`-presence inference, so an action
|
|
16
|
+
* item may carry a `url` yet render as a button. Toggle-style rows compose
|
|
17
|
+
* `ItemButton` plus a `slot` — there is no dedicated switch.
|
|
18
|
+
*/
|
|
19
|
+
const renderFooterItem = (item, currentUrl, LinkComponent) => {
|
|
20
|
+
// `label` is the row's identity (required on LeafFooterItem), so it is
|
|
21
|
+
// the element key — reordering the authored list preserves each row's
|
|
22
|
+
// state. Two same-labelled rows in one footer collide; that's ambiguous
|
|
23
|
+
// UI, left to the consumer to avoid.
|
|
24
|
+
if (item.control !== "button" && item.url) {
|
|
25
|
+
const active = item.url === currentUrl;
|
|
26
|
+
return (_jsx(Item, { url: item.url, icon: item.icon, slot: item.slot, LinkComponent: LinkComponent, active: active, children: item.label }, item.label));
|
|
27
|
+
}
|
|
28
|
+
if (item.control === "button" || item.onClick) {
|
|
29
|
+
return (_jsx(ItemButton, { icon: item.icon, slot: item.slot, onClick: item.onClick, children: item.label }, item.label));
|
|
30
|
+
}
|
|
31
|
+
return (_jsx(Item, { icon: item.icon, slot: item.slot, children: item.label }, item.label));
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* SideNavigation.Footer — optional region pinned to the bottom, reserved
|
|
35
|
+
* for user-related content. Data-only: `root` is the footer's only data
|
|
36
|
+
* surface — free-form leaves (`LeafFooterItem`, buttons via
|
|
37
|
+
* `control`/`onClick`) and depth-1 expandables (`ExpandableFooterItem`,
|
|
38
|
+
* whose children disclose through the same native `<details>` disclosure
|
|
39
|
+
* the content tree uses). A certificate-user application, for instance,
|
|
40
|
+
* composes the `certificate` icon and omits the logout item itself.
|
|
9
41
|
*
|
|
10
42
|
* @implements ds:apps.subcomponent.side-navigation-footer
|
|
11
43
|
*/
|
|
12
|
-
const Footer = ({ className, root, LinkComponent = "a", currentUrl,
|
|
13
|
-
|
|
44
|
+
const Footer = ({ className, root, LinkComponent = "a", currentUrl, ...props }) => {
|
|
45
|
+
const list = root?.items ?? [];
|
|
46
|
+
return (_jsx("footer", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: list.length > 0 ? (_jsx("ul", { className: "list", children: list.map((entry) => "items" in entry && entry.items.length > 0 ? (_jsx(ItemExpandable, { heading: entry.label, icon: entry.icon, collapseOnChildClick: true,
|
|
47
|
+
// Seed from whether a child row is the current location;
|
|
48
|
+
// the disclosure's one-way sync re-opens it on navigation.
|
|
49
|
+
// The `url !== undefined` guard matters: without it, a
|
|
50
|
+
// label-only child (no `url`) matches an unset `currentUrl`
|
|
51
|
+
// (`undefined === undefined`) and the disclosure seeds open
|
|
52
|
+
// whenever `currentUrl` isn't wired.
|
|
53
|
+
defaultExpanded: entry.items.some((child) => child.url !== undefined && child.url === currentUrl), children: entry.items.map((child) => renderFooterItem(child, currentUrl, LinkComponent)) }, entry.label)) : (renderFooterItem(entry, currentUrl, LinkComponent))) })) : null }));
|
|
14
54
|
};
|
|
15
55
|
export default Footer;
|
|
16
56
|
//# sourceMappingURL=Footer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Footer.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Footer/Footer.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Footer.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Footer/Footer.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,E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AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
/* Generated by @canonical/summon-component:react v0.1.0
|
|
2
2
|
* Layer: ds.components.apps (@canonical/styles README, "Cascade layers"). */
|
|
3
|
-
|
|
4
3
|
@layer ds.components.apps {
|
|
5
4
|
.ds.footer {
|
|
6
|
-
/*
|
|
7
|
-
|
|
5
|
+
/* 0.5rem of bottom spacing. */
|
|
6
|
+
padding-block-end: var(--dimension-100);
|
|
7
|
+
|
|
8
|
+
/* Flat list reset — the footer's rows are always a flat list (leaves and
|
|
9
|
+
depth-1 expandables; no groups), so this owns the structure reset
|
|
10
|
+
directly. */
|
|
11
|
+
& > .list {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
list-style: none;
|
|
15
|
+
margin: 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
}
|
|
8
18
|
}
|
|
9
19
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { GroupHeader } from "../GroupHeader/index.js";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
const componentCssClassName = "ds side-navigation-group";
|
|
5
|
+
/**
|
|
6
|
+
* SideNavigation.Group — a named collection of navigation entries, with an
|
|
7
|
+
* optional SideNavigation.GroupHeader. One of NavTree's direct content
|
|
8
|
+
* entries.
|
|
9
|
+
*
|
|
10
|
+
* @implements ds:apps.subcomponent.side-navigation-group
|
|
11
|
+
*/
|
|
12
|
+
const Group = ({ label, children, className, ...props }) => (_jsxs("section", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: [label != null && _jsx(GroupHeader, { children: label }), _jsx("ul", { className: "list", children: children })] }));
|
|
13
|
+
export default Group;
|
|
14
|
+
//# sourceMappingURL=Group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Group.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Group/Group.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,KAAK,GAAG,CAAC,EACb,KAAK,EACL,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACG,EAAsB,EAAE,CAAC,CACpC,mBACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,aAER,KAAK,IAAI,IAAI,IAAI,KAAC,WAAW,cAAE,KAAK,GAAe,EACpD,aAAI,SAAS,EAAC,MAAM,YAAE,QAAQ,GAAM,IAC5B,CACX,CAAC;AAEF,eAAe,KAAK,CAAC"}
|