@canonical/react-ds-app 0.40.0 → 0.43.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/README.md +9 -3
- package/dist/esm/lib/ContentLayout/styles.css +1 -1
- package/dist/esm/lib/SideNavigation/SideNavigation.js +1 -7
- package/dist/esm/lib/SideNavigation/SideNavigation.js.map +1 -1
- package/dist/esm/lib/SideNavigation/common/Item/Item.js +1 -1
- package/dist/esm/lib/SideNavigation/helpItem.js.map +1 -1
- package/dist/esm/lib/SidePanel/Context.js +12 -0
- package/dist/esm/lib/SidePanel/Context.js.map +1 -0
- package/dist/esm/lib/SidePanel/Provider.js +90 -0
- package/dist/esm/lib/SidePanel/Provider.js.map +1 -0
- package/dist/esm/lib/SidePanel/common/Content/Content.js +26 -0
- package/dist/esm/lib/SidePanel/common/Content/Content.js.map +1 -0
- package/dist/esm/lib/SidePanel/common/Content/index.js +2 -0
- package/dist/esm/lib/SidePanel/common/Content/index.js.map +1 -0
- package/dist/esm/lib/SidePanel/common/Content/styles.css +49 -0
- package/dist/esm/lib/SidePanel/common/Content/types.js +2 -0
- package/dist/esm/lib/SidePanel/common/Content/types.js.map +1 -0
- package/dist/esm/lib/SidePanel/common/Footer/Footer.js +19 -0
- package/dist/esm/lib/SidePanel/common/Footer/Footer.js.map +1 -0
- package/dist/esm/lib/SidePanel/common/Footer/index.js +2 -0
- package/dist/esm/lib/SidePanel/common/Footer/index.js.map +1 -0
- package/dist/esm/lib/SidePanel/common/Footer/styles.css +36 -0
- package/dist/esm/lib/SidePanel/common/Footer/types.js +2 -0
- package/dist/esm/lib/SidePanel/common/Footer/types.js.map +1 -0
- package/dist/esm/lib/SidePanel/common/Header/Header.js +39 -0
- package/dist/esm/lib/SidePanel/common/Header/Header.js.map +1 -0
- package/dist/esm/lib/SidePanel/common/Header/index.js +2 -0
- package/dist/esm/lib/SidePanel/common/Header/index.js.map +1 -0
- package/dist/esm/lib/SidePanel/common/Header/styles.css +94 -0
- package/dist/esm/lib/SidePanel/common/Header/types.js +2 -0
- package/dist/esm/lib/SidePanel/common/Header/types.js.map +1 -0
- package/dist/esm/lib/SidePanel/common/index.js +4 -0
- package/dist/esm/lib/SidePanel/common/index.js.map +1 -0
- package/dist/esm/lib/SidePanel/hooks/index.js +4 -0
- package/dist/esm/lib/SidePanel/hooks/index.js.map +1 -0
- package/dist/esm/lib/SidePanel/hooks/types.js +2 -0
- package/dist/esm/lib/SidePanel/hooks/types.js.map +1 -0
- package/dist/esm/lib/SidePanel/hooks/useSidePanelContext.js +9 -0
- package/dist/esm/lib/SidePanel/hooks/useSidePanelContext.js.map +1 -0
- package/dist/esm/lib/SidePanel/hooks/useSidePanelDialog.js +134 -0
- package/dist/esm/lib/SidePanel/hooks/useSidePanelDialog.js.map +1 -0
- package/dist/esm/lib/SidePanel/index.js +4 -0
- package/dist/esm/lib/SidePanel/index.js.map +1 -0
- package/dist/esm/lib/SidePanel/styles.css +192 -0
- package/dist/esm/lib/SidePanel/types.js +2 -0
- package/dist/esm/lib/SidePanel/types.js.map +1 -0
- package/dist/esm/lib/SidePanel/withSidePanel.js +98 -0
- package/dist/esm/lib/SidePanel/withSidePanel.js.map +1 -0
- package/dist/esm/lib/index.js +1 -0
- package/dist/esm/lib/index.js.map +1 -1
- package/dist/types/lib/ApplicationLayout/ApplicationLayout.d.ts.map +1 -1
- package/dist/types/lib/ContentLayout/ContentLayout.d.ts.map +1 -1
- package/dist/types/lib/ContentLayout/types.d.ts +1 -1
- package/dist/types/lib/SideNavigation/SideNavigation.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/CollapseToggle/CollapseToggle.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Content/Content.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/ContextSwitcher/ContextSwitcher.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Footer/Footer.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Group/Group.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/GroupHeader/GroupHeader.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Header/Header.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Item/Item.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/ItemButton/ItemButton.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/ItemExpandable/ItemExpandable.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/helpItem.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/hooks/useCollapseShortcut/useCollapseShortcut.d.ts.map +1 -1
- package/dist/types/lib/SidePanel/Context.d.ts +12 -0
- package/dist/types/lib/SidePanel/Context.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/Provider.d.ts +13 -0
- package/dist/types/lib/SidePanel/Provider.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/common/Content/Content.d.ts +9 -0
- package/dist/types/lib/SidePanel/common/Content/Content.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/common/Content/index.d.ts +3 -0
- package/dist/types/lib/SidePanel/common/Content/index.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/common/Content/types.d.ts +21 -0
- package/dist/types/lib/SidePanel/common/Content/types.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/common/Footer/Footer.d.ts +9 -0
- package/dist/types/lib/SidePanel/common/Footer/Footer.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/common/Footer/index.d.ts +3 -0
- package/dist/types/lib/SidePanel/common/Footer/index.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/common/Footer/types.d.ts +14 -0
- package/dist/types/lib/SidePanel/common/Footer/types.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/common/Header/Header.d.ts +9 -0
- package/dist/types/lib/SidePanel/common/Header/Header.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/common/Header/index.d.ts +3 -0
- package/dist/types/lib/SidePanel/common/Header/index.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/common/Header/types.d.ts +35 -0
- package/dist/types/lib/SidePanel/common/Header/types.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/common/index.d.ts +4 -0
- package/dist/types/lib/SidePanel/common/index.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/hooks/index.d.ts +4 -0
- package/dist/types/lib/SidePanel/hooks/index.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/hooks/types.d.ts +28 -0
- package/dist/types/lib/SidePanel/hooks/types.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/hooks/useSidePanelContext.d.ts +8 -0
- package/dist/types/lib/SidePanel/hooks/useSidePanelContext.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/hooks/useSidePanelDialog.d.ts +12 -0
- package/dist/types/lib/SidePanel/hooks/useSidePanelDialog.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/index.d.ts +4 -0
- package/dist/types/lib/SidePanel/index.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/types.d.ts +97 -0
- package/dist/types/lib/SidePanel/types.d.ts.map +1 -0
- package/dist/types/lib/SidePanel/withSidePanel.d.ts +76 -0
- package/dist/types/lib/SidePanel/withSidePanel.d.ts.map +1 -0
- package/dist/types/lib/ViewLayout/ViewLayout.d.ts.map +1 -1
- package/dist/types/lib/index.d.ts +1 -0
- package/dist/types/lib/index.d.ts.map +1 -1
- package/package.json +28 -27
package/README.md
CHANGED
|
@@ -9,10 +9,16 @@ Application-level UI components for the Pragma design system. This package provi
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
bun add @canonical/react-ds-app
|
|
12
|
+
bun add @canonical/react-ds-app @canonical/styles
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Import the design system's styles **first** in your application's entry, before anything that imports a component:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import "@canonical/styles";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Each component brings its own stylesheet when you import it.
|
|
16
22
|
|
|
17
23
|
## Usage
|
|
18
24
|
|
|
@@ -52,7 +58,7 @@ The component layers follow the design system's tier tree, flat, one name per ti
|
|
|
52
58
|
|
|
53
59
|
Once both are layered, no selector this package declares is also declared by `@canonical/react-ds-global`, so nothing changes hands. What the layer buys is the answer to the next collision, and that answer is fixed rather than emitted: today specificity settles the `.application-layout` near-miss, one seat apart; a global rule written at the same seat as this package's would have been settled by whichever bundle a loader emitted last, and is now settled by layer, in this package's favour, whatever the emit order and without a longer selector or an `!important`.
|
|
54
60
|
|
|
55
|
-
The guarantee needs `@canonical/styles` on the page, and needs its statement first. An order statement is what fixes the relative order of two sublayers; without it they fall back to the order they first appear in, and a bundle that emits this package before `@canonical/react-ds-global` hands the win back to the global tier.
|
|
61
|
+
The guarantee needs `@canonical/styles` on the page, and needs its statement first. An order statement is what fixes the relative order of two sublayers; without it they fall back to the order they first appear in, and a bundle that emits this package before `@canonical/react-ds-global` hands the win back to the global tier. The statement names `ds.components.apps` above `ds.components.global`, so with the statement on the page this package beats `@canonical/react-ds-global` in both emit orders. Nothing under `src/lib` imports `@canonical/styles` — an application imports it once, as the installation instructions above say.
|
|
56
62
|
|
|
57
63
|
An application's own **unlayered** CSS now beats every rule in this package, whatever the selectors on either side, because an unlayered author rule outranks every layered one. That is CSS working as designed, and it is the deliberate escape hatch: an application that needs to override a component writes a plain rule and it wins. An application that does *not* want to win by accident puts its CSS in `@layer app`.
|
|
58
64
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
@layer ds.components.apps {
|
|
5
5
|
.ds.content-layout {
|
|
6
6
|
/* Column templates and gaps come from the .grid presets in
|
|
7
|
-
@canonical/styles (.responsive: breakpoint-driven 4/8/
|
|
7
|
+
@canonical/styles (.responsive: breakpoint-driven 4/8/16 columns;
|
|
8
8
|
.intrinsic: fluid auto-fill groups of four minmax(--grid-col-min, 1fr)
|
|
9
9
|
columns). Knobs: --grid-gap (or per-axis --grid-row-gap /
|
|
10
10
|
--grid-column-gap), --grid-col-min for the intrinsic mode. */
|
|
@@ -76,13 +76,7 @@ keyboardShortcut = true, "aria-label": ariaLabel, ...props }) => {
|
|
|
76
76
|
// onExpandedChange?.(next);
|
|
77
77
|
// }, [expanded, isControlled, onExpandedChange]);
|
|
78
78
|
// -------------------------------------------------------------------------
|
|
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] }));
|
|
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 ? (_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] }));
|
|
86
80
|
};
|
|
87
81
|
export default SideNavigation;
|
|
88
82
|
//# 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,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,KAAK,EAAE,CAAC;IAE1B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,mBAAmB,IAAI,IAAI,CAAC,CAAC;IAEtE,+CAA+C;IAC/C,2EAA2E;IAC3E,0EAA0E;IAC1E,qEAAqE;IACrE,2EAA2E;IAC3E,wEAAwE;IACxE,qEAAqE;IACrE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,mBAAmB,KAAK,SAAS;YAAE,OAAO;QAC9C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AS,EAAE,YAAY,EAAE,CAAC,CAAC;IAE9E,4EAA4E;IAC5E,0DAA0D;IAC1D,+BAA+B;IAC/B,mDAAmD;IACnD,uEAAuE;IACvE,EAAE;IACF,2CAA2C;IAC3C,4BAA4B;IAC5B,sDAAsD;IACtD,8BAA8B;IAC9B,kDAAkD;IAClD,4EAA4E;IAE5E,OAAO,CACL,eACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,mBACxD,QAAQ,KACnB,KAAK,aAIT,YAAG,SAAS,EAAC,WAAW,EAAC,IAAI,EAAE,MAAM,qCAEjC,EACJ,KAAC,MAAM,IACL,KAAK,EAAE,KAAK,EACZ,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,YAAY,EACtB,gBAAgB,EAAE,SAAS,GAC3B,EACD,eAAe,CAAC,CAAC,CAAC,CAMjB,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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Icon } from "@canonical/react-ds-global";
|
|
3
3
|
import "./styles.css";
|
|
4
4
|
const componentCssClassName = "ds side-navigation-item";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpItem.js","sourceRoot":"","sources":["../../../../src/lib/SideNavigation/helpItem.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,QAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"helpItem.js","sourceRoot":"","sources":["../../../../src/lib/SideNavigation/helpItem.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,QAAgB,EAChB,OAAO,GAGH,EAAE,EACa,EAAE,CAAC,CAAC;IACvB,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE;QACL;YACE,GAAG,EAAE,YAAY;YACjB,GAAG,EAAE,QAAQ;YACb,KAAK,EAAE,OAAO,CAAC,UAAU,IAAI,mBAAmB;YAChD,IAAI,EAAE,eAAe;SACtB;QACD,GAAG,CAAC,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC;KACnC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The shared side panel API threaded to the composed subcomponents. There is
|
|
4
|
+
* ONE panel instance per dialog — the subcomponents are render-only and read
|
|
5
|
+
* this context rather than being handed props, so a composed `SidePanel.Header`
|
|
6
|
+
* names the panel and closes it without the consumer wiring either by hand.
|
|
7
|
+
* Defaults to `null` so a part rendered outside a panel degrades rather than
|
|
8
|
+
* throws.
|
|
9
|
+
*/
|
|
10
|
+
const Context = createContext(null);
|
|
11
|
+
export default Context;
|
|
12
|
+
//# sourceMappingURL=Context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../../../src/lib/SidePanel/Context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC;;;;;;;GAOG;AACH,MAAM,OAAO,GAAG,aAAa,CAA+B,IAAI,CAAC,CAAC;AAElE,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Children, isValidElement, useId, useMemo } from "react";
|
|
3
|
+
import Context from "./Context.js";
|
|
4
|
+
import { Content, Footer, Header } from "./common/index.js";
|
|
5
|
+
import { useSidePanelDialog } from "./hooks/index.js";
|
|
6
|
+
import "./styles.css";
|
|
7
|
+
const componentCssClassName = "ds side-panel";
|
|
8
|
+
/**
|
|
9
|
+
* A panel docked to the inline-end edge of the viewport, for work that
|
|
10
|
+
* accompanies the current view rather than interrupting it.
|
|
11
|
+
*
|
|
12
|
+
* Structurally, the component is a context provider that renders the panel's
|
|
13
|
+
* markup: it wraps the `<dialog>` in the context its composed parts read,
|
|
14
|
+
* and keeps every piece of panel behaviour — open/close bookkeeping, focus
|
|
15
|
+
* handoff, the imperative handle — in `useSidePanelDialog`.
|
|
16
|
+
*
|
|
17
|
+
* It renders a **non-modal** `<dialog>` opened with `show()`, so the
|
|
18
|
+
* application behind stays clickable and tabbable.
|
|
19
|
+
*
|
|
20
|
+
* The panel is controlled through its `ref`: `open()` shows it and moves focus
|
|
21
|
+
* in, `close()` hides it and hands focus back, and `toggle()` switches between
|
|
22
|
+
* those states. The ref is required, since the handle is the only way in — a
|
|
23
|
+
* panel with no ref is a panel that can never open. The dialog's native open
|
|
24
|
+
* state is the single source of truth — there is no `open` prop to mirror it.
|
|
25
|
+
*
|
|
26
|
+
* The panel forwards the native dialog `onClose`: pass your own to hear about
|
|
27
|
+
* every close, whatever caused it — the handle's `close()`, Escape, or anything else.
|
|
28
|
+
*
|
|
29
|
+
* Compose the body from `SidePanel.Header`, `SidePanel.Content` and
|
|
30
|
+
* `SidePanel.Footer`. The panel lays them out as a flex column: header and
|
|
31
|
+
* footer keep their size, and the content pane takes the rest and scrolls
|
|
32
|
+
* within it. The content pane is a tab stop, so keyboard users can scroll it;
|
|
33
|
+
* opening the panel still focuses the panel itself, so from there Tab reaches
|
|
34
|
+
* the close button, then the content, then the footer's actions.
|
|
35
|
+
*
|
|
36
|
+
* There are two consumption patterns, `withSidePanel` and `SidePanel`.
|
|
37
|
+
* `withSidePanel` is meant for static content: the call belongs at module
|
|
38
|
+
* scope, where the function it is handed can only see module-level values, so
|
|
39
|
+
* the panel it returns is the same on every render. If the panel must show
|
|
40
|
+
* data from the parent — for example a different machine's details depending
|
|
41
|
+
* on which machine is selected — compose `SidePanel` directly and drive it
|
|
42
|
+
* through its `ref`. Otherwise, use `withSidePanel`.
|
|
43
|
+
*
|
|
44
|
+
* The panel is always named by its header's title, so the header is required
|
|
45
|
+
* — a panel composed without one gets a development warning. Note the title
|
|
46
|
+
* is not a heading element: the panel is a layer on top of the page, not
|
|
47
|
+
* part of its document outline.
|
|
48
|
+
*
|
|
49
|
+
* The panel is `position: fixed` and therefore out of the document flow: an
|
|
50
|
+
* `overflow: hidden` ancestor does not clip it
|
|
51
|
+
*
|
|
52
|
+
* Because the content pane scrolls and the panel is transformed, a
|
|
53
|
+
* `position: fixed` overlay rendered inside the panel is clipped at the
|
|
54
|
+
* pane's edge and positioned relative to the panel rather than the viewport.
|
|
55
|
+
* `Popover` currently follows that pattern, so keep it within the content
|
|
56
|
+
* pane's bounds.
|
|
57
|
+
*
|
|
58
|
+
* `ContextualMenu` instead portals its surface to `document.body`, escaping
|
|
59
|
+
* this clipping. When it must overlap the panel, give its overlay layer a
|
|
60
|
+
* z-index higher than `--side-panel-z-index`.
|
|
61
|
+
*
|
|
62
|
+
* `import { SidePanel } from "@canonical/react-ds-app";`
|
|
63
|
+
*
|
|
64
|
+
* @implements ds:apps.pattern.side_panel
|
|
65
|
+
*/
|
|
66
|
+
const Provider = ({ children, ...props }) => {
|
|
67
|
+
const { className, close, dialogProps, dialogRef, handleKeyDown, handleClose, } = useSidePanelDialog(props);
|
|
68
|
+
// The header's title carries this id, and the dialog is labelled by it.
|
|
69
|
+
const titleId = useId();
|
|
70
|
+
// Memoised so the parts reading the context do not re-render every time
|
|
71
|
+
// the provider does.
|
|
72
|
+
const contextValue = useMemo(() => ({ close, titleId }), [close, titleId]);
|
|
73
|
+
// The header is required: its title is the panel's accessible name, and a
|
|
74
|
+
// panel without one cannot be named. Direct children only — a Header wrapped
|
|
75
|
+
// in a fragment escapes this check, and the warning is a nudge, not a gate.
|
|
76
|
+
if (typeof process !== "undefined" &&
|
|
77
|
+
process.env.NODE_ENV !== "production" &&
|
|
78
|
+
!Children.toArray(children).some((child) => isValidElement(child) && child.type === Header)) {
|
|
79
|
+
console.warn("SidePanel: the panel needs a SidePanel.Header — its title is the panel's accessible name.");
|
|
80
|
+
}
|
|
81
|
+
return (_jsx(Context.Provider, { value: contextValue, children: _jsx("dialog", { ref: dialogRef, className: [componentCssClassName, className].filter(Boolean).join(" "), "aria-labelledby": titleId,
|
|
82
|
+
// Focusable so that opening can place focus on the panel itself.
|
|
83
|
+
tabIndex: -1, onKeyDown: handleKeyDown, onClose: handleClose, ...dialogProps, children: children }) }));
|
|
84
|
+
};
|
|
85
|
+
Provider.Content = Content;
|
|
86
|
+
Provider.Footer = Footer;
|
|
87
|
+
Provider.Header = Header;
|
|
88
|
+
Provider.displayName = "SidePanel";
|
|
89
|
+
export default Provider;
|
|
90
|
+
//# sourceMappingURL=Provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../../src/lib/SidePanel/Provider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAA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C,qBAOtD,OAAO;YACxB,iEAAiE;YACjE,QAAQ,EAAE,CAAC,CAAC,EACZ,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,WAAW,KAChB,WAAW,YAEd,QAAQ,GACF,GACQ,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;AAC3B,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;AACzB,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;AAEzB,QAAQ,CAAC,WAAW,GAAG,WAAW,CAAC;AAEnC,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
const componentCssClassName = "ds side-panel-content";
|
|
4
|
+
/**
|
|
5
|
+
* Body of a SidePanel, and the only part of it that scrolls: however tall its
|
|
6
|
+
* children are, the header and footer stay visible.
|
|
7
|
+
*
|
|
8
|
+
* The pane is its own scroll container, so it is a tab stop: a keyboard
|
|
9
|
+
* user tabs to it and scrolls it with the arrow and page keys, even when it
|
|
10
|
+
* holds nothing focusable.
|
|
11
|
+
*
|
|
12
|
+
* @implements ds:apps.subcomponent.side_panel-content
|
|
13
|
+
*/
|
|
14
|
+
const Content = ({ children, className, fill = false, ...props }) => {
|
|
15
|
+
return (_jsx("div", { className: [componentCssClassName, fill && "fill", className]
|
|
16
|
+
.filter(Boolean)
|
|
17
|
+
.join(" "),
|
|
18
|
+
// A scroll container a keyboard user cannot focus cannot be scrolled,
|
|
19
|
+
// so the pane is a tab stop. Set before the spread, so the native prop
|
|
20
|
+
// can still take it out of the tab order.
|
|
21
|
+
// biome-ignore lint/a11y/noNoninteractiveTabindex: focus is what makes the scroll region keyboard-operable.
|
|
22
|
+
tabIndex: 0, ...props, children: children }));
|
|
23
|
+
};
|
|
24
|
+
Content.displayName = "SidePanel.Content";
|
|
25
|
+
export default Content;
|
|
26
|
+
//# sourceMappingURL=Content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Content.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Content/Content.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAEtD;;;;;;;;;GASG;AACH,MAAM,OAAO,GAAG,CAAC,EACf,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,KAAK,EACZ,GAAG,KAAK,EACK,EAAsB,EAAE;IACrC,OAAO,CACL,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,IAAI,IAAI,MAAM,EAAE,SAAS,CAAC;aAC1D,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC;QACZ,sEAAsE;QACtE,uEAAuE;QACvE,0CAA0C;QAC1C,4GAA4G;QAC5G,QAAQ,EAAE,CAAC,KACP,KAAK,YAER,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,CAAC,WAAW,GAAG,mBAAmB,CAAC;AAE1C,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Content/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* Layer: ds.components.apps (@canonical/styles README, "Cascade layers"). */
|
|
2
|
+
|
|
3
|
+
@layer ds.components.apps {
|
|
4
|
+
.ds.side-panel-content {
|
|
5
|
+
/*
|
|
6
|
+
Natural height by default: the footer follows the content, so its actions
|
|
7
|
+
stay next to the text they refer to instead of being pushed to the bottom
|
|
8
|
+
edge of a short panel. Shrinks when the content is taller than the space
|
|
9
|
+
the header and footer leave — `overflow` below drops a flex item's
|
|
10
|
+
automatic minimum size to zero, so it can shrink below its content.
|
|
11
|
+
*/
|
|
12
|
+
flex: 0 1 auto;
|
|
13
|
+
|
|
14
|
+
/* Opt-in: take the space the header and footer leave, so a short panel fills. */
|
|
15
|
+
&.fill {
|
|
16
|
+
flex-grow: 1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
The scroll region, and the only one: the header and footer sit outside it
|
|
21
|
+
in the panel's flex column, so they stay visible without sticky
|
|
22
|
+
positioning.
|
|
23
|
+
*/
|
|
24
|
+
overflow-y: auto;
|
|
25
|
+
/* Don't hand the scroll to the page behind once the content bottoms out. */
|
|
26
|
+
overscroll-behavior: contain;
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
Inline padding, not margin: the pane must span the full panel width, so
|
|
30
|
+
its scrollbar hugs the panel edge and the focus ring below reaches it,
|
|
31
|
+
while the padding keeps the text clear of both.
|
|
32
|
+
*/
|
|
33
|
+
padding-block: var(--side-panel-content-padding-block);
|
|
34
|
+
padding-inline: var(--side-panel-padding-inline);
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
Focusable (Content.tsx sets `tabIndex`) so keyboard users can scroll it.
|
|
38
|
+
The panel clips its overflow, and the pane reaches the panel edges, so an
|
|
39
|
+
outset ring would be cut off: draw it inside the pane instead. The ring is
|
|
40
|
+
declared in full, because only a known width can be inset by exactly that
|
|
41
|
+
much — the user-agent ring's width varies by browser.
|
|
42
|
+
*/
|
|
43
|
+
&:focus-visible {
|
|
44
|
+
outline: var(--side-panel-focus-ring-width) solid
|
|
45
|
+
var(--side-panel-color-focus-ring);
|
|
46
|
+
outline-offset: calc(-1 * var(--side-panel-focus-ring-width));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Content/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
const componentCssClassName = "ds side-panel-footer";
|
|
4
|
+
/**
|
|
5
|
+
* Footer for SidePanel. Never scrolls: it stays visible below
|
|
6
|
+
* `SidePanel.Content`, which scrolls on its own, so its actions are always
|
|
7
|
+
* reachable.
|
|
8
|
+
*
|
|
9
|
+
* @implements ds:apps.subcomponent.side_panel-footer
|
|
10
|
+
*/
|
|
11
|
+
const Footer = ({ children, className, ...props }) => {
|
|
12
|
+
// A <div>, not a <footer>: a <footer> inside a <dialog> is exposed as a
|
|
13
|
+
// page-level contentinfo landmark, and the panel is non-modal, so the page's
|
|
14
|
+
// own contentinfo stays reachable beside it and would be duplicated.
|
|
15
|
+
return (_jsx("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: children }));
|
|
16
|
+
};
|
|
17
|
+
Footer.displayName = "SidePanel.Footer";
|
|
18
|
+
export default Footer;
|
|
19
|
+
//# sourceMappingURL=Footer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Footer.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Footer/Footer.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,MAAM,GAAG,CAAC,EACd,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACI,EAAsB,EAAE;IACpC,wEAAwE;IACxE,6EAA6E;IAC7E,qEAAqE;IACrE,OAAO,CACL,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,YAER,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAExC,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Footer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* Layer: ds.components.apps (@canonical/styles README, "Cascade layers"). */
|
|
2
|
+
|
|
3
|
+
@layer ds.components.apps {
|
|
4
|
+
.ds.side-panel-footer {
|
|
5
|
+
/*
|
|
6
|
+
Never shrinks. It stays visible because only the content pane scrolls —
|
|
7
|
+
the footer sits beside it in the panel's flex column, not over it.
|
|
8
|
+
*/
|
|
9
|
+
flex: none;
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
Closes the scroll region, marking where the content pane ends and the
|
|
13
|
+
actions begin.
|
|
14
|
+
|
|
15
|
+
The colour is the panel's to own, and is read without a local fallback so
|
|
16
|
+
the two cannot state different defaults: `--side-panel-color-border` is
|
|
17
|
+
declared in the panel's `:root` block.
|
|
18
|
+
*/
|
|
19
|
+
border-block-start: var(--dimension-stroke-thickness-medium) solid
|
|
20
|
+
var(--side-panel-color-border);
|
|
21
|
+
/*
|
|
22
|
+
Inset by margin rather than padding: a border spans the padding box, so
|
|
23
|
+
padding would run the hairline edge to edge. The margin keeps it stopping
|
|
24
|
+
short of both panel edges, in line with the text column.
|
|
25
|
+
*/
|
|
26
|
+
margin-inline: var(--side-panel-padding-inline);
|
|
27
|
+
|
|
28
|
+
display: flex;
|
|
29
|
+
justify-content: flex-end;
|
|
30
|
+
align-items: center;
|
|
31
|
+
gap: var(--side-panel-footer-gap);
|
|
32
|
+
flex-wrap: wrap;
|
|
33
|
+
|
|
34
|
+
padding-block: var(--side-panel-footer-padding-block);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Footer/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from "@canonical/react-ds-global";
|
|
3
|
+
import { useSidePanelContext } from "../../hooks/index.js";
|
|
4
|
+
import "./styles.css";
|
|
5
|
+
const componentCssClassName = "ds side-panel-header";
|
|
6
|
+
/**
|
|
7
|
+
* Header for SidePanel. Required: its title is the panel's accessible name,
|
|
8
|
+
* so a panel is not complete without one. Never scrolls: it stays visible
|
|
9
|
+
* above `SidePanel.Content`, which scrolls on its own.
|
|
10
|
+
*
|
|
11
|
+
* Owns the title the panel is labelled by, and the close button — which is
|
|
12
|
+
* wired through context, so rendering this outside a SidePanel yields a plain
|
|
13
|
+
* title rather than an error.
|
|
14
|
+
*
|
|
15
|
+
* The title is not a heading element: headings structure the page's document
|
|
16
|
+
* outline, and a panel opens from anywhere in it, so no heading level would be
|
|
17
|
+
* right everywhere. The title names the panel through `aria-labelledby`
|
|
18
|
+
* instead, which is what a screen reader announces when the panel opens.
|
|
19
|
+
*
|
|
20
|
+
* You choose the title's content, not the element it renders in: `children`
|
|
21
|
+
* always lands inside a Header-owned `<span class="title">`, which carries the
|
|
22
|
+
* `id` the panel's `aria-labelledby` points at — so the wrapper is fixed and
|
|
23
|
+
* not replaceable.
|
|
24
|
+
*
|
|
25
|
+
* @implements ds:apps.subcomponent.side_panel-header
|
|
26
|
+
*/
|
|
27
|
+
const Header = ({ children, className, dismissLabel = "Close panel", undismissible = false, ...props }) => {
|
|
28
|
+
const context = useSidePanelContext();
|
|
29
|
+
// A <div>, not a <header>: a <header> inside a <dialog> is exposed as a
|
|
30
|
+
// page-level banner landmark, and the panel is non-modal, so the page's
|
|
31
|
+
// own banner stays reachable beside it and would be duplicated.
|
|
32
|
+
return (_jsxs("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: [_jsx("span", { className: "title p", id: context?.titleId, children: children }), context && !undismissible && (_jsx(Button, { className: "close", icon: "close", importance: "tertiary",
|
|
33
|
+
// A typeless <button> is type="submit": inside a <form> the panel
|
|
34
|
+
// would submit it. This control only closes the panel.
|
|
35
|
+
type: "button", onClick: context.close, "aria-label": dismissLabel }))] }));
|
|
36
|
+
};
|
|
37
|
+
Header.displayName = "SidePanel.Header";
|
|
38
|
+
export default Header;
|
|
39
|
+
//# sourceMappingURL=Header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Header.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Header/Header.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,GAAG,CAAC,EACd,QAAQ,EACR,SAAS,EACT,YAAY,GAAG,aAAa,EAC5B,aAAa,GAAG,KAAK,EACrB,GAAG,KAAK,EACI,EAAsB,EAAE;IACpC,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;IAEtC,wEAAwE;IACxE,wEAAwE;IACxE,gEAAgE;IAChE,OAAO,CACL,eACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,aAET,eAAM,SAAS,EAAC,SAAS,EAAC,EAAE,EAAE,OAAO,EAAE,OAAO,YAC3C,QAAQ,GACJ,EACN,OAAO,IAAI,CAAC,aAAa,IAAI,CAC5B,KAAC,MAAM,IACL,SAAS,EAAC,OAAO,EACjB,IAAI,EAAC,OAAO,EACZ,UAAU,EAAC,UAAU;gBACrB,kEAAkE;gBAClE,uDAAuD;gBACvD,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,CAAC,KAAK,gBAGV,YAAY,GACxB,CACH,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAExC,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Header/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* Layer: ds.components.apps (@canonical/styles README, "Cascade layers"). */
|
|
2
|
+
|
|
3
|
+
@layer ds.components.apps {
|
|
4
|
+
.ds.side-panel-header {
|
|
5
|
+
/*
|
|
6
|
+
Title type — heading-2 for now. The tier is provisional: to change it,
|
|
7
|
+
swap the tier in these five lines and nothing else.
|
|
8
|
+
|
|
9
|
+
Declared here, not on :root: a var() inside a custom property resolves
|
|
10
|
+
where it is declared, and the typography tokens are redefined per
|
|
11
|
+
context (.app, .site, .docs). On :root these would capture the
|
|
12
|
+
page-level tier; here they resolve inside the panel's own context.
|
|
13
|
+
*/
|
|
14
|
+
--side-panel-title-font-family: var(--typography-heading-2-font-family);
|
|
15
|
+
--side-panel-title-font-size: var(--typography-heading-2-font-size);
|
|
16
|
+
--side-panel-title-font-weight: var(--typography-heading-2-font-weight);
|
|
17
|
+
--side-panel-title-letter-spacing: var(
|
|
18
|
+
--typography-heading-2-letter-spacing
|
|
19
|
+
);
|
|
20
|
+
--side-panel-title-line-height: var(
|
|
21
|
+
--typography-heading-2-line-height-dimension
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
Never shrinks. It stays visible because only the content pane scrolls —
|
|
26
|
+
the header sits beside it in the panel's flex column, not over it.
|
|
27
|
+
*/
|
|
28
|
+
flex: none;
|
|
29
|
+
|
|
30
|
+
display: flex;
|
|
31
|
+
/*
|
|
32
|
+
Baseline-aligned: the close button sits on the title's baseline. The
|
|
33
|
+
browser lines the two baselines up itself, so nothing here needs to know
|
|
34
|
+
where the typography engine puts the title's baseline or where Button's
|
|
35
|
+
density seat puts its own.
|
|
36
|
+
*/
|
|
37
|
+
align-items: baseline;
|
|
38
|
+
gap: var(--side-panel-header-gap);
|
|
39
|
+
|
|
40
|
+
padding-block: var(--side-panel-header-padding-block);
|
|
41
|
+
/*
|
|
42
|
+
Inline padding, not margin: nothing here needs the header's box itself
|
|
43
|
+
inset, and padding keeps it full panel width. The footer is the
|
|
44
|
+
exception — its border spans the padding box, so it insets with margin
|
|
45
|
+
(see Footer/styles.css).
|
|
46
|
+
*/
|
|
47
|
+
padding-inline: var(--side-panel-padding-inline);
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
The title is heading text beside a control, not a control: its line box
|
|
51
|
+
is taller than the density seat line, so the typography engine seats it
|
|
52
|
+
rather than the density seat. It carries `.p`, the engine's class hook
|
|
53
|
+
for an element that is not `p` or `h1`–`h6`; this rule feeds the engine
|
|
54
|
+
the title's type in place of the paragraph values `.p` brings.
|
|
55
|
+
*/
|
|
56
|
+
> .title {
|
|
57
|
+
flex: 1 1 auto;
|
|
58
|
+
--font-size: var(--side-panel-title-font-size);
|
|
59
|
+
--font-weight: var(--side-panel-title-font-weight);
|
|
60
|
+
--line-height: var(--side-panel-title-line-height);
|
|
61
|
+
/* No element-owned space below, even inside an `.editorial` ancestor. */
|
|
62
|
+
--space-after: 0;
|
|
63
|
+
font-family: var(--side-panel-title-font-family);
|
|
64
|
+
letter-spacing: var(--side-panel-title-letter-spacing);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
> .close {
|
|
68
|
+
flex: 0 0 auto;
|
|
69
|
+
/*
|
|
70
|
+
Button tightens padding-inline-start when it has an icon, which suits an
|
|
71
|
+
icon+label button but leaves an icon-only one lopsided (8px vs 16px).
|
|
72
|
+
Equalise both sides through Button's own custom-property API, as
|
|
73
|
+
Modal's header does.
|
|
74
|
+
*/
|
|
75
|
+
--button-padding-inline-start: var(--dimension-100);
|
|
76
|
+
--button-padding-inline-end: var(--dimension-100);
|
|
77
|
+
|
|
78
|
+
/*
|
|
79
|
+
An icon-only button has no text, so it has no baseline of its own and
|
|
80
|
+
the browser would make one up from the icon's box. A zero-width
|
|
81
|
+
character gives it a line of text in its seat line, so its baseline
|
|
82
|
+
lands where a label's would. The pseudo-element is a flex item like the
|
|
83
|
+
icon, so the gap is cancelled to keep the button's size.
|
|
84
|
+
|
|
85
|
+
Temporary: remove once icon-only buttons carry a seated baseline of
|
|
86
|
+
their own.
|
|
87
|
+
*/
|
|
88
|
+
&::before {
|
|
89
|
+
content: "\200b";
|
|
90
|
+
margin-inline-end: calc(-1 * var(--button-gap));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Header/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/SidePanel/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/SidePanel/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/lib/SidePanel/hooks/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import Context from "../Context.js";
|
|
3
|
+
/**
|
|
4
|
+
* Read the panel API. Returns `null` outside a SidePanel so that a part can
|
|
5
|
+
* degrade — `Header` simply omits its close button — rather than throwing.
|
|
6
|
+
*/
|
|
7
|
+
export const useSidePanelContext = () => useContext(Context);
|
|
8
|
+
export default useSidePanelContext;
|
|
9
|
+
//# sourceMappingURL=useSidePanelContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSidePanelContext.js","sourceRoot":"","sources":["../../../../../src/lib/SidePanel/hooks/useSidePanelContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,OAAO,MAAM,eAAe,CAAC;AAGpC;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAiC,EAAE,CACpE,UAAU,CAAC,OAAO,CAAC,CAAC;AAEtB,eAAe,mBAAmB,CAAC"}
|