@iyulab/desktop-patterns 0.10.1 → 0.11.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 +5 -0
- package/dist/components/shell/dp-shell.d.ts +7 -0
- package/dist/shell.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -87,6 +87,11 @@ collapsed rail (`dp-sidebar` `collapsed`). Give the toggle `expanded` so assisti
|
|
|
87
87
|
which state it is in. The consumer owns both states — start the drawer closed, close it when the
|
|
88
88
|
shell asks (backdrop click, Escape) and when a place is picked, or a narrow window stays covered.
|
|
89
89
|
|
|
90
|
+
The shell holds the window's height, so the document never scrolls — the main content box does.
|
|
91
|
+
Anything that saves and restores where the user was reading reaches that box through
|
|
92
|
+
`shell.mainElement`; with `@iyulab/router`, hand it to the router's scroll restoration:
|
|
93
|
+
`scrollRestoration: { container: () => document.querySelector('dp-shell')?.mainElement }`.
|
|
94
|
+
|
|
90
95
|
### A list beside the item picked from it
|
|
91
96
|
|
|
92
97
|
```html
|
|
@@ -35,6 +35,13 @@ export declare class DpShell extends LitElement {
|
|
|
35
35
|
* place is picked in the drawer.
|
|
36
36
|
*/
|
|
37
37
|
sidebarOpen: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The box that scrolls the main content. The shell holds the window's height, so the document
|
|
40
|
+
* never scrolls — this box does. Code that saves and restores where the user was reading (a
|
|
41
|
+
* router's scroll restoration, for one) reads and writes its `scrollTop`. It sits in the shadow
|
|
42
|
+
* root, so this is the supported way to reach it. `null` until the first render.
|
|
43
|
+
*/
|
|
44
|
+
get mainElement(): HTMLElement | null;
|
|
38
45
|
private readonly onKeydown;
|
|
39
46
|
connectedCallback(): void;
|
|
40
47
|
disconnectedCallback(): void;
|
package/dist/shell.js
CHANGED
|
@@ -103,6 +103,9 @@ var c = class extends Event {
|
|
|
103
103
|
}
|
|
104
104
|
`;
|
|
105
105
|
}
|
|
106
|
+
get mainElement() {
|
|
107
|
+
return this.shadowRoot?.querySelector("main") ?? null;
|
|
108
|
+
}
|
|
106
109
|
connectedCallback() {
|
|
107
110
|
super.connectedCallback(), document.addEventListener("keydown", this.onKeydown);
|
|
108
111
|
}
|