@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Group/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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-group {
|
|
5
|
+
/* Vertical rhythm between groups is owned by the scroller, not the group:
|
|
6
|
+
Content's flex `gap: 0.5rem` spaces adjacent Groups (and GroupHeader
|
|
7
|
+
carries its own top padding for the gap above a group's first item),
|
|
8
|
+
so this rule declares no spacing of its own. */
|
|
9
|
+
|
|
10
|
+
> .list {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
list-style: none;
|
|
14
|
+
margin: 0;
|
|
15
|
+
padding: 0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Group/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
const componentCssClassName = "ds side-navigation-group-header";
|
|
4
|
+
/**
|
|
5
|
+
* SideNavigation.GroupHeader — the optional label above a
|
|
6
|
+
* SideNavigation.Group's entries. Purely presentational; rendered by Group
|
|
7
|
+
* when its `label` is set.
|
|
8
|
+
*
|
|
9
|
+
* @implements ds:apps.subcomponent.side-navigation-group-header
|
|
10
|
+
*/
|
|
11
|
+
const GroupHeader = ({ children, className, ...props }) => (_jsx("span", { className: [componentCssClassName, className].filter(Boolean).join(" "),
|
|
12
|
+
// `title` — native tooltip fallback for a truncated header.
|
|
13
|
+
// Only meaningful when the header is plain text
|
|
14
|
+
// (the common case — Group always passes its string `label` here).
|
|
15
|
+
title: typeof children === "string" ? children : undefined, ...props, children: children }));
|
|
16
|
+
export default GroupHeader;
|
|
17
|
+
//# sourceMappingURL=GroupHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GroupHeader.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/GroupHeader/GroupHeader.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,iCAAiC,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,WAAW,GAAG,CAAC,EACnB,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACS,EAAsB,EAAE,CAAC,CAC1C,eACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;IACvE,4DAA4D;IAC5D,gDAAgD;IAChD,mEAAmE;IACnE,KAAK,EAAE,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,KACtD,KAAK,YAER,QAAQ,GACJ,CACR,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/GroupHeader/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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-group-header {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: baseline;
|
|
7
|
+
color: var(--color-text-muted);
|
|
8
|
+
font-family: var(--typography-text-tertiary-bold-font-family);
|
|
9
|
+
font-size: var(--typography-text-tertiary-bold-font-size);
|
|
10
|
+
font-weight: var(--typography-text-tertiary-bold-font-weight);
|
|
11
|
+
line-height: var(--typography-text-tertiary-bold-line-height);
|
|
12
|
+
letter-spacing: var(--typography-text-tertiary-bold-letter-spacing);
|
|
13
|
+
padding-top: var(--sidenav-icon-gap);
|
|
14
|
+
padding-inline: var(--sidenav-inset-inline); /* 0.5 rem */
|
|
15
|
+
/* Figma's group-heading component sets its text style's case to `UPPER`
|
|
16
|
+
(a literal transform of the authored string, confirmed against the
|
|
17
|
+
source file — not a font feature): "Header" renders as "HEADER", not
|
|
18
|
+
via small-caps. `typography.heading.5` supplies the
|
|
19
|
+
size/weight/line-height/letter-spacing but is a `font-variant:
|
|
20
|
+
small-caps` treatment, which (for a mixed-case label like "Hardware")
|
|
21
|
+
renders differently — only the leading capital stays full-height, the
|
|
22
|
+
rest becomes reduced-height caps — not uniform block capitals. Layering
|
|
23
|
+
`text-transform: uppercase` here reproduces the spec's literal case
|
|
24
|
+
without revisiting which token supplies the rest of the type scale. */
|
|
25
|
+
text-transform: uppercase;
|
|
26
|
+
/* Group headers are single-line and truncate. */
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
text-overflow: ellipsis;
|
|
29
|
+
white-space: nowrap;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/GroupHeader/types.ts"],"names":[],"mappings":""}
|
|
@@ -5,12 +5,14 @@ const componentCssClassName = "ds side-navigation-header";
|
|
|
5
5
|
/**
|
|
6
6
|
* SideNavigation.Header — top region holding the brand (the `brand` node, at the
|
|
7
7
|
* start) and the collapse toggle (at the end). The toggle is omitted when no
|
|
8
|
-
* `onToggle` handler is provided.
|
|
8
|
+
* `onToggle` handler is provided. Collapsed: the layout
|
|
9
|
+
* switches to a centred column — the toggle relocates below the logo rather
|
|
10
|
+
* than beside it — driven by `data-expanded` on the root.
|
|
9
11
|
*
|
|
10
12
|
* @implements ds:apps.subcomponent.side-navigation-header
|
|
11
13
|
*/
|
|
12
14
|
const Header = ({ className, brand, applicationName, expanded, onToggle, collapseControls, ...props }) => {
|
|
13
|
-
return (_jsxs("header", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: [_jsx("div", { className: "brand", children: brand }), applicationName != null && (_jsx("
|
|
15
|
+
return (_jsxs("header", { className: [componentCssClassName, className].filter(Boolean).join(" "), "data-expanded": expanded, ...props, children: [_jsxs("div", { className: "brand-container", children: [_jsx("div", { className: "brand", children: brand }), applicationName != null && (_jsx("h1", { className: "title", children: applicationName }))] }), onToggle && (_jsx(CollapseToggle, { expanded: expanded, "aria-controls": collapseControls, onClick: onToggle }))] }));
|
|
14
16
|
};
|
|
15
17
|
export default Header;
|
|
16
18
|
//# sourceMappingURL=Header.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Header/Header.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAE1D
|
|
1
|
+
{"version":3,"file":"Header.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Header/Header.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAE1D;;;;;;;;GAQG;AACH,MAAM,MAAM,GAAG,CAAC,EACd,SAAS,EACT,KAAK,EACL,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,GAAG,KAAK,EACI,EAAsB,EAAE;IACpC,OAAO,CACL,kBACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,mBACxD,QAAQ,KACnB,KAAK,aAET,eAAK,SAAS,EAAC,iBAAiB,aAC9B,cAAK,SAAS,EAAC,OAAO,YAAE,KAAK,GAAO,EAInC,eAAe,IAAI,IAAI,IAAI,CAC1B,aAAI,SAAS,EAAC,OAAO,YAAE,eAAe,GAAM,CAC7C,IACG,EACL,QAAQ,IAAI,CACX,KAAC,cAAc,IACb,QAAQ,EAAE,QAAQ,mBACH,gBAAgB,EAC/B,OAAO,EAAE,QAAQ,GACjB,CACH,IACM,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -1,40 +1,78 @@
|
|
|
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.side-navigation-header {
|
|
6
|
-
/*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/* Pin each part to its column explicitly so the toggle stays in the end
|
|
19
|
-
column even when the optional title is absent. */
|
|
20
|
-
.brand {
|
|
21
|
-
/* Start column, aligned with the item icons below. Tops-align with the rest
|
|
22
|
-
of the row (align-items: start); the brand's own margin/padding handles
|
|
23
|
-
its vertical placement, not a stretched cell. */
|
|
24
|
-
grid-column: 1;
|
|
5
|
+
/* Logo at the start, collapse toggle at the end. Both top-align at the
|
|
6
|
+
same 0.5rem inset so the collapse icon lines up with the logo and,
|
|
7
|
+
below it, every item's leading icon. */
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: baseline;
|
|
10
|
+
justify-content: space-between;
|
|
11
|
+
/* 0.5rem — deliberate deviation from the upstream 24.04 design's 1rem
|
|
12
|
+
to the right of the collapse button, keeping the header reading tight
|
|
13
|
+
like the rest of the rail. */
|
|
14
|
+
gap: var(--dimension-100);
|
|
15
|
+
|
|
16
|
+
.brand-container {
|
|
25
17
|
display: flex;
|
|
26
|
-
align-items:
|
|
18
|
+
align-items: baseline;
|
|
19
|
+
gap: var(--dimension-050);
|
|
20
|
+
padding-inline: var(--sidenav-inset-inline);
|
|
21
|
+
|
|
22
|
+
.brand {
|
|
23
|
+
block-size: var(--sidenav-logo-block-size);
|
|
24
|
+
inline-size: var(--sidenav-logo-inline-size);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* `.title` (the <h1> beside the logo) is a sibling of `.brand`, not its
|
|
28
|
+
descendant — the collapsed-state `[data-expanded="false"] .title`
|
|
29
|
+
override below needs to reach the same specificity family, or the
|
|
30
|
+
cascade order between them isn't guaranteed. Single-line, truncating:
|
|
31
|
+
a long application name must not wrap and push the header taller
|
|
32
|
+
than its baseline. Its line-height is the logo's box height so the
|
|
33
|
+
row stays exactly as tall as the logo. */
|
|
34
|
+
.title {
|
|
35
|
+
min-width: 0;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
white-space: nowrap;
|
|
38
|
+
text-overflow: ellipsis;
|
|
39
|
+
line-height: var(--sidenav-logo-block-size);
|
|
40
|
+
}
|
|
27
41
|
}
|
|
28
42
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
43
|
+
/* Collapsed: a centred column — logo on top, the collapse
|
|
44
|
+
toggle relocates below it rather than beside it. DOM order already
|
|
45
|
+
places the toggle last, so switching the axis alone moves it there; no
|
|
46
|
+
title has room, so it's dropped entirely rather than left to overflow
|
|
47
|
+
a rail this narrow. The rearrangement is instant by design — no
|
|
48
|
+
`transition` property here. */
|
|
49
|
+
&[data-expanded="false"] {
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
align-items: flex-start;
|
|
52
|
+
justify-content: flex-start;
|
|
53
|
+
|
|
54
|
+
.title {
|
|
55
|
+
display: none;
|
|
56
|
+
}
|
|
33
57
|
}
|
|
34
58
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
59
|
+
/* Responsive: the header keeps its normal
|
|
60
|
+
row layout on mobile — collapsed there means "menu closed", not "narrow
|
|
61
|
+
icon rail", so the centred-column rearrangement above doesn't apply. */
|
|
62
|
+
@media (width < 620px) {
|
|
63
|
+
align-items: flex-start;
|
|
64
|
+
padding-inline-end: 0;
|
|
65
|
+
|
|
66
|
+
&[data-expanded="false"] {
|
|
67
|
+
flex-direction: row;
|
|
68
|
+
align-items: stretch;
|
|
69
|
+
justify-content: space-between;
|
|
70
|
+
padding-block-end: var(--dimension-100);
|
|
71
|
+
|
|
72
|
+
.title {
|
|
73
|
+
display: block;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
38
76
|
}
|
|
39
77
|
}
|
|
40
78
|
}
|
|
@@ -5,24 +5,20 @@ const componentCssClassName = "ds side-navigation-item";
|
|
|
5
5
|
/**
|
|
6
6
|
* SideNavigation.Item — the default renderer for a single navigation item.
|
|
7
7
|
*
|
|
8
|
-
* A flat leaf row, NOT recursive
|
|
9
|
-
*
|
|
8
|
+
* A flat leaf row, NOT recursive — an entry with children is a
|
|
9
|
+
* SideNavigation.ItemExpandable instead. The row is
|
|
10
|
+
* `[icon] [content] [end]` over a shared grid template (so the icon aligns
|
|
10
11
|
* with the header logo). An item with a `url` renders as a link via
|
|
11
|
-
* `LinkComponent` (default `"a"`); otherwise a non-navigable label.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* behaviour is deferred);
|
|
16
|
-
* - leaf → the optional `slot` (a badge, count, …), or nothing.
|
|
12
|
+
* `LinkComponent` (default `"a"`); otherwise a non-navigable label. The end
|
|
13
|
+
* slot is the optional `slot` (a badge, count, …), or nothing. Content is
|
|
14
|
+
* composed via `children`, matching `Button`'s own convention — pass
|
|
15
|
+
* anything, not only text.
|
|
17
16
|
*
|
|
18
17
|
* @implements ds:apps.subcomponent.side-navigation-item
|
|
19
18
|
*/
|
|
20
|
-
const Item = ({ url,
|
|
21
|
-
// NavItem fields not spread to the DOM.
|
|
22
|
-
key: _key, items, className, ...props }) => {
|
|
19
|
+
const Item = ({ url, children, icon, slot, disabled = false, active = false, LinkComponent = "a", className, ...props }) => {
|
|
23
20
|
const Link = LinkComponent;
|
|
24
|
-
const
|
|
25
|
-
const content = (_jsxs(_Fragment, { children: [_jsx("span", { className: "start p", children: icon ? _jsx(Icon, { icon: icon }) : null }), _jsx("span", { className: "label p", children: label }), hasSubitems ? (_jsx(Icon, { icon: "chevron-down", className: "end caret" })) : slot ? (_jsx("span", { className: "end slot", children: slot })) : null] }));
|
|
21
|
+
const content = (_jsxs(_Fragment, { children: [_jsx("span", { className: "start", children: icon ? _jsx(Icon, { width: 16, height: 16, icon: icon }) : null }), _jsx("span", { className: "label", title: typeof children === "string" ? children : undefined, children: children }), slot ? _jsx("span", { className: "end slot", children: slot }) : null] }));
|
|
26
22
|
return (_jsx("li", { className: [componentCssClassName, className].filter(Boolean).join(" "), "data-disabled": disabled || undefined, "data-active": active || undefined, ...props, children: url ? (_jsx(Link, { className: "row", href: disabled ? undefined : url, "aria-current": active ? "page" : undefined, children: content })) : (_jsx("span", { className: "row", "aria-current": active ? "page" : undefined, children: content })) }));
|
|
27
23
|
};
|
|
28
24
|
export default Item;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Item/Item.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAExD
|
|
1
|
+
{"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Item/Item.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,MAAM,IAAI,GAAG,CAAC,EACZ,GAAG,EACH,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,QAAQ,GAAG,KAAK,EAChB,MAAM,GAAG,KAAK,EACd,aAAa,GAAG,GAAG,EACnB,SAAS,EACT,GAAG,KAAK,EACE,EAAsB,EAAE;IAClC,MAAM,IAAI,GAAG,aAAa,CAAC;IAE3B,MAAM,OAAO,GAAG,CACd,8BAGE,eAAM,SAAS,EAAC,OAAO,YACpB,IAAI,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,GAAI,CAAC,CAAC,CAAC,IAAI,GACrD,EAIP,eACE,SAAS,EAAC,OAAO,EACjB,KAAK,EAAE,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,YAEzD,QAAQ,GACJ,EACN,IAAI,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,UAAU,YAAE,IAAI,GAAQ,CAAC,CAAC,CAAC,IAAI,IACtD,CACJ,CAAC;IAEF,OAAO,CACL,aACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,mBACxD,QAAQ,IAAI,SAAS,iBACvB,MAAM,IAAI,SAAS,KAC5B,KAAK,YAER,GAAG,CAAC,CAAC,CAAC,CACL,KAAC,IAAI,IACH,SAAS,EAAC,KAAK,EACf,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,kBAClB,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,YAExC,OAAO,GACH,CACR,CAAC,CAAC,CAAC,CACF,eAAM,SAAS,EAAC,KAAK,kBAAe,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,YAC5D,OAAO,GACH,CACR,GACE,CACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,59 +1,94 @@
|
|
|
1
|
-
/* Generated by @canonical/summon-component:react v0.1.0
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* PR1: structural layout only. Colour/visual state (hover/active fills,
|
|
5
|
-
* text/icon colour) is deferred to PR2 (token pairings). A bare focus outline
|
|
6
|
-
* is included for keyboard focus visibility.
|
|
7
|
-
*
|
|
8
|
-
* Layer: ds.components.apps (@canonical/styles README, "Cascade layers").
|
|
9
|
-
*/
|
|
10
|
-
|
|
1
|
+
/* Generated by @canonical/summon-component:react v0.1.0
|
|
2
|
+
* Layer: ds.components.apps (@canonical/styles README, "Cascade layers"). */
|
|
11
3
|
@layer ds.components.apps {
|
|
12
4
|
.ds.side-navigation-item {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
13
8
|
list-style: none;
|
|
9
|
+
height: var(--dimension-400);
|
|
14
10
|
|
|
15
|
-
/* The row: link or label.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
baselines line up on the grid. No block padding — the fixed height owns it. */
|
|
11
|
+
/* The row: link or label. [icon] [label] [end], 0.5rem gap, 0.5rem inset —
|
|
12
|
+
shares --sidenav-inset-inline/--sidenav-icon-gap with the header so the
|
|
13
|
+
leading icon lines up with the logo above it. Fixed row height
|
|
14
|
+
(`--dimension-400`, 2rem) — reverses the intrinsic, padding-driven
|
|
15
|
+
height this file previously read. */
|
|
21
16
|
& > .row {
|
|
22
17
|
display: grid;
|
|
23
|
-
grid-template-columns: var(--sidenav-
|
|
24
|
-
align-items:
|
|
25
|
-
gap: var(--
|
|
18
|
+
grid-template-columns: var(--sidenav-icon-column-inline-size) 1fr auto;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: var(--sidenav-icon-gap); /* 0.5rem */
|
|
26
21
|
width: 100%;
|
|
27
|
-
|
|
22
|
+
height: 100%;
|
|
23
|
+
padding-inline: var(--sidenav-inset-inline); /* 0.5rem */
|
|
28
24
|
box-sizing: border-box;
|
|
29
|
-
padding-block: 0;
|
|
30
25
|
text-decoration: none;
|
|
26
|
+
color: var(--color-text);
|
|
27
|
+
background: var(--sidenav-row-background);
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
/*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
/* Hover changes the background only — text/icon colour stays constant
|
|
31
|
+
across states. Disabled items never hover/press. */
|
|
32
|
+
&:not([data-disabled]) > .row {
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
|
|
35
|
+
&:hover {
|
|
36
|
+
background: var(--sidenav-row-background-hover);
|
|
37
|
+
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
&:active {
|
|
40
|
+
background: var(--sidenav-row-background-active);
|
|
40
41
|
}
|
|
42
|
+
|
|
43
|
+
&:focus-visible {
|
|
44
|
+
outline: 2px solid currentColor;
|
|
45
|
+
outline-offset: -2px;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&[data-active] > .row {
|
|
50
|
+
background: var(--sidenav-row-background-active);
|
|
51
|
+
box-shadow: inset var(--dimension-stroke-thickness-medium) 0 0 0
|
|
52
|
+
var(--color-icon);
|
|
41
53
|
}
|
|
42
54
|
|
|
43
|
-
/*
|
|
55
|
+
/* Declared after [data-active] so a disabled+active item (edge case) still
|
|
56
|
+
reads as disabled. */
|
|
57
|
+
&[data-disabled] > .row {
|
|
58
|
+
color: var(--color-text-disabled);
|
|
59
|
+
background: var(--sidenav-row-background-disabled);
|
|
60
|
+
cursor: default;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Leading icon slot — always reserved (empty when absent) so labels align
|
|
64
|
+
whether or not a row has an icon. */
|
|
65
|
+
& .start {
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
color: var(--color-icon);
|
|
70
|
+
width: var(--dimension-250);
|
|
71
|
+
height: var(--dimension-250);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&[data-disabled] .start {
|
|
75
|
+
color: var(--color-icon-disabled);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* Label → middle (1fr) column. */
|
|
79
|
+
/* Item labels are single-line and truncate. */
|
|
44
80
|
& .label {
|
|
45
81
|
min-width: 0;
|
|
82
|
+
overflow: hidden;
|
|
83
|
+
text-overflow: ellipsis;
|
|
84
|
+
white-space: nowrap;
|
|
46
85
|
}
|
|
47
86
|
|
|
48
|
-
/* Trailing
|
|
87
|
+
/* Trailing slot (e.g. a badge) → end (auto) column. */
|
|
49
88
|
& .end {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/* Keyboard focus visibility (structural a11y; styling refined in PR2). */
|
|
54
|
-
& > .row:focus-visible {
|
|
55
|
-
outline: 2px solid currentColor;
|
|
56
|
-
outline-offset: -2px;
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
justify-content: center;
|
|
57
92
|
}
|
|
58
93
|
}
|
|
59
94
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from "@canonical/react-ds-global";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
const componentCssClassName = "ds side-navigation-item-button";
|
|
5
|
+
/**
|
|
6
|
+
* SideNavigation.ItemButton — a navigation row that performs an action
|
|
7
|
+
* instead of navigating (e.g. "Log out", "Create context"). Buttons are a
|
|
8
|
+
* Footer-only row kind: the content tree accepts links and plain labels,
|
|
9
|
+
* so an `ItemButton` belongs in a `SideNavigation.Footer` — rendered from
|
|
10
|
+
* a `control: "button"` footer item or composed via the Footer's
|
|
11
|
+
* `children`. Content is composed via `children`,
|
|
12
|
+
* matching `Button`'s own convention.
|
|
13
|
+
*
|
|
14
|
+
* @implements ds:apps.subcomponent.side-navigation-item-button
|
|
15
|
+
*/
|
|
16
|
+
const ItemButton = ({ children, icon, slot, className, ...props }) => (_jsx("li", { className: [componentCssClassName, className].filter(Boolean).join(" "), children: _jsxs("button", { className: "row", ...props, type: "button", children: [_jsx("span", { className: "start", children: icon ? _jsx(Icon, { width: 16, height: 16, icon: icon }) : null }), _jsx("span", { className: "label", title: typeof children === "string" ? children : undefined, children: children }), slot ? _jsx("span", { className: "end slot", children: slot }) : null] }) }));
|
|
17
|
+
export default ItemButton;
|
|
18
|
+
//# sourceMappingURL=ItemButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemButton.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/ItemButton/ItemButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,gCAAgC,CAAC;AAE/D;;;;;;;;;;GAUG;AACH,MAAM,UAAU,GAAG,CAAC,EAClB,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,GAAG,KAAK,EACQ,EAAsB,EAAE,CAAC,CACzC,aAAI,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YACzE,kBAAQ,SAAS,EAAC,KAAK,KAAK,KAAK,EAAE,IAAI,EAAC,QAAQ,aAG9C,eAAM,SAAS,EAAC,OAAO,YACpB,IAAI,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,GAAI,CAAC,CAAC,CAAC,IAAI,GACrD,EAEP,eACE,SAAS,EAAC,OAAO,EACjB,KAAK,EAAE,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,YAEzD,QAAQ,GACJ,EACN,IAAI,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,UAAU,YAAE,IAAI,GAAQ,CAAC,CAAC,CAAC,IAAI,IAChD,GACN,CACN,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/ItemButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
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-item-button {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
list-style: none;
|
|
9
|
+
height: var(--dimension-400);
|
|
10
|
+
|
|
11
|
+
/* The row: identical geometry to SideNavigation.Item's row (shares the
|
|
12
|
+
insets/gap/icon-column tokens so icons line up down the rail), but a
|
|
13
|
+
real <button> — native `:disabled`/`:hover`/`:active` apply directly,
|
|
14
|
+
no `data-disabled` attribute needed (cs:css.component.states: native
|
|
15
|
+
states via attribute/pseudo-class selectors). */
|
|
16
|
+
& > .row {
|
|
17
|
+
display: grid;
|
|
18
|
+
grid-template-columns: var(--sidenav-icon-column-inline-size) 1fr auto;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: var(--sidenav-icon-gap); /* 0.5rem */
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
padding-inline: var(--sidenav-inset-inline); /* 0.5rem */
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
border: none;
|
|
26
|
+
background: var(--sidenav-row-background);
|
|
27
|
+
color: var(--color-text);
|
|
28
|
+
font: inherit;
|
|
29
|
+
text-align: start;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
|
|
32
|
+
&:hover {
|
|
33
|
+
background: var(--sidenav-row-background-hover);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&:active {
|
|
37
|
+
background: var(--sidenav-row-background-active);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&:focus-visible {
|
|
41
|
+
outline: 2px solid currentColor;
|
|
42
|
+
outline-offset: -2px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&:disabled {
|
|
46
|
+
color: var(--color-text-disabled);
|
|
47
|
+
background: var(--sidenav-row-background-disabled);
|
|
48
|
+
cursor: default;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
& .start {
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
justify-content: center;
|
|
56
|
+
color: var(--color-icon);
|
|
57
|
+
width: var(--dimension-250);
|
|
58
|
+
height: var(--dimension-250);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
& > .row:disabled .start {
|
|
62
|
+
color: var(--color-icon-disabled);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Item labels are single-line and truncate. */
|
|
66
|
+
& .label {
|
|
67
|
+
min-width: 0;
|
|
68
|
+
overflow: hidden;
|
|
69
|
+
text-overflow: ellipsis;
|
|
70
|
+
white-space: nowrap;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
& .end {
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/ItemButton/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from "@canonical/react-ds-global";
|
|
3
|
+
import { useCallback, useEffect, useId, useRef } from "react";
|
|
4
|
+
import "./styles.css";
|
|
5
|
+
const componentCssClassName = "ds side-navigation-item-expandable";
|
|
6
|
+
/**
|
|
7
|
+
* SideNavigation.ItemExpandable — a collapsible row that discloses its own
|
|
8
|
+
* (always-leaf) children instead of navigating. Native
|
|
9
|
+
* `<details>`/`<summary>` — no `role`/`aria-expanded` authored, per
|
|
10
|
+
* `cs:ui_blocks.nojs.disclosure`; the element owns its own open state.
|
|
11
|
+
* `heading` and `children` are composed, not string props — matching
|
|
12
|
+
* `Accordion.Item`'s own split.
|
|
13
|
+
*
|
|
14
|
+
* `defaultExpanded` seeds the initial state (NavTree supplies it from the
|
|
15
|
+
* tree's own state: whether this node's branch is the selected one) and is
|
|
16
|
+
* live in one direction only: when it turns `true` on navigation the
|
|
17
|
+
* disclosure re-opens — a manual collapse stays collapsed and the
|
|
18
|
+
* disclosure never auto-closes.
|
|
19
|
+
*
|
|
20
|
+
* `collapseOnChildClick` is the Footer's opt-in: activating a leaf row
|
|
21
|
+
* among the `children` collapses the disclosure. The content tree does not
|
|
22
|
+
* opt in: its branch stays open so the active row remains visible.
|
|
23
|
+
*
|
|
24
|
+
* @implements ds:apps.subcomponent.side-navigation-item-expandable
|
|
25
|
+
*/
|
|
26
|
+
const ItemExpandable = ({ heading, icon, disabled = false, defaultExpanded = false, collapseOnChildClick = false, children, className, ...props }) => {
|
|
27
|
+
// Uncontrolled: the <details> owns its open state and React never
|
|
28
|
+
// re-asserts it. The attribute is seeded from a mount-only snapshot of
|
|
29
|
+
// `defaultExpanded` — not the live prop, so a seed flipping back to false
|
|
30
|
+
// never force-closes an open disclosure — and the two imperative
|
|
31
|
+
// behaviours below reach the DOM through the ref.
|
|
32
|
+
const detailsRef = useRef(null);
|
|
33
|
+
const initialExpanded = useRef(defaultExpanded).current;
|
|
34
|
+
// One-way re-open: navigation making this branch the selected one flips
|
|
35
|
+
// the seed true, and the disclosure re-opens. Manual collapses stay
|
|
36
|
+
// collapsed; the disclosure never auto-closes.
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
const details = detailsRef.current;
|
|
39
|
+
if (defaultExpanded && details && !details.open) {
|
|
40
|
+
details.open = true;
|
|
41
|
+
}
|
|
42
|
+
}, [defaultExpanded]);
|
|
43
|
+
// Guards the CLICK, not the toggle: the native `toggle` event isn't
|
|
44
|
+
// cancelable, and preventing the summary's default stops the disclosure
|
|
45
|
+
// toggling at all.
|
|
46
|
+
const handleSummaryClick = useCallback((event) => {
|
|
47
|
+
if (disabled)
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
}, [disabled]);
|
|
50
|
+
// Footer opt-in (`collapseOnChildClick`): activating a child link or
|
|
51
|
+
// button row collapses the disclosure (the summary has neither, so it is
|
|
52
|
+
// excluded by the closest() check). Delegated on the list so the row
|
|
53
|
+
// components stay unaware of their disclosure parent.
|
|
54
|
+
const handleChildrenClick = useCallback((event) => {
|
|
55
|
+
const details = detailsRef.current;
|
|
56
|
+
if (collapseOnChildClick &&
|
|
57
|
+
details &&
|
|
58
|
+
event.target.closest("a, button")) {
|
|
59
|
+
details.open = false;
|
|
60
|
+
}
|
|
61
|
+
}, [collapseOnChildClick]);
|
|
62
|
+
// Unique per instance and ident-safe (useId may contain ":" on older
|
|
63
|
+
// React). Wires the collapsed-rail popover's CSS anchor positioning: the
|
|
64
|
+
// summary anchors, the panel positions against it, and the browser flips
|
|
65
|
+
// it on overflow (`position-try-fallbacks` in styles.css) — no
|
|
66
|
+
// measurement JS.
|
|
67
|
+
const anchorName = `--sidenav-expandable-${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
68
|
+
return (_jsx("li", { className: [componentCssClassName, className].filter(Boolean).join(" "), "data-disabled": disabled || undefined, ...props, children: _jsxs("details", { className: "details", ref: detailsRef, open: initialExpanded || undefined, children: [_jsxs("summary", { className: "row", onClick: handleSummaryClick, style: { anchorName }, children: [_jsx("span", { className: "start", children: icon ? _jsx(Icon, { width: 16, height: 16, icon: icon }) : null }), _jsx("span", { className: "label", title: typeof heading === "string" ? heading : undefined, children: heading }), _jsx(Icon, { icon: "chevron-down", className: "end caret" })] }), _jsx("ul", { className: "children", onClick: handleChildrenClick, style: { positionAnchor: anchorName }, children: children })] }) }));
|
|
69
|
+
};
|
|
70
|
+
export default ItemExpandable;
|
|
71
|
+
//# sourceMappingURL=ItemExpandable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemExpandable.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/ItemExpandable/ItemExpandable.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,oCAAoC,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,cAAc,GAAG,CAAC,EACtB,OAAO,EACP,IAAI,EACJ,QAAQ,GAAG,KAAK,EAChB,eAAe,GAAG,KAAK,EACvB,oBAAoB,GAAG,KAAK,EAC5B,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACY,EAAsB,EAAE;IAC5C,kEAAkE;IAClE,uEAAuE;IACvE,0EAA0E;IAC1E,iEAAiE;IACjE,kDAAkD;IAClD,MAAM,UAAU,GAAG,MAAM,CAAqB,IAAI,CAAC,CAAC;IACpD,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC;IAExD,wEAAwE;IACxE,oEAAoE;IACpE,+CAA+C;IAC/C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QACnC,IAAI,eAAe,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAChD,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QACtB,CAAC;IACH,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;IAEtB,oEAAoE;IACpE,wEAAwE;IACxE,mBAAmB;IACnB,MAAM,kBAAkB,GAAG,WAAW,CACpC,CAAC,KAAoC,EAAE,EAAE;QACvC,IAAI,QAAQ;YAAE,KAAK,CAAC,cAAc,EAAE,CAAC;IACvC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,qEAAqE;IACrE,yEAAyE;IACzE,qEAAqE;IACrE,sDAAsD;IACtD,MAAM,mBAAmB,GAAG,WAAW,CACrC,CAAC,KAAyC,EAAE,EAAE;QAC5C,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QACnC,IACE,oBAAoB;YACpB,OAAO;YACN,KAAK,CAAC,MAAkB,CAAC,OAAO,CAAC,WAAW,CAAC,EAC9C,CAAC;YACD,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;QACvB,CAAC;IACH,CAAC,EACD,CAAC,oBAAoB,CAAC,CACvB,CAAC;IAEF,qEAAqE;IACrE,yEAAyE;IACzE,yEAAyE;IACzE,+DAA+D;IAC/D,kBAAkB;IAClB,MAAM,UAAU,GAAG,wBAAwB,KAAK,EAAE,CAAC,OAAO,CACxD,eAAe,EACf,EAAE,CACH,EAAE,CAAC;IAEJ,OAAO,CACL,aACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,mBACxD,QAAQ,IAAI,SAAS,KAChC,KAAK,YAET,mBACE,SAAS,EAAC,SAAS,EACnB,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,eAAe,IAAI,SAAS,aAGlC,mBACE,SAAS,EAAC,KAAK,EACf,OAAO,EAAE,kBAAkB,EAC3B,KAAK,EAAE,EAAE,UAAU,EAAE,aAIrB,eAAM,SAAS,EAAC,OAAO,YACpB,IAAI,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,GAAI,CAAC,CAAC,CAAC,IAAI,GACrD,EAEP,eACE,SAAS,EAAC,OAAO,EACjB,KAAK,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,YAEvD,OAAO,GACH,EACP,KAAC,IAAI,IAAC,IAAI,EAAC,cAAc,EAAC,SAAS,EAAC,WAAW,GAAG,IAC1C,EAIV,aACE,SAAS,EAAC,UAAU,EACpB,OAAO,EAAE,mBAAmB,EAC5B,KAAK,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE,YAEpC,QAAQ,GACN,IACG,GACP,CACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/ItemExpandable/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|