shelving 1.321.0 → 1.322.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/docs/guides/building-with-shelving.md +204 -1
- package/docs/llms-full.txt +786 -114
- package/docs/ui/App.md +105 -7
- package/docs/ui/AppLayout.md +85 -0
- package/docs/ui/AppLayoutProps.md +21 -0
- package/docs/ui/Catcher.md +1 -1
- package/docs/ui/ErrorPage.md +2 -1
- package/docs/ui/FixedLayout.md +91 -0
- package/docs/ui/FixedLayoutProps.md +13 -0
- package/docs/ui/GapVariants.md +2 -2
- package/docs/ui/HeightVariant.md +30 -0
- package/docs/ui/HeightVariants.md +26 -0
- package/docs/ui/Navigation.md +20 -11
- package/docs/ui/PaddingVariants.md +2 -2
- package/docs/ui/Page.md +12 -8
- package/docs/ui/PageLoader.md +2 -1
- package/docs/ui/RouteCache.md +22 -17
- package/docs/ui/Router.md +9 -5
- package/docs/ui/Scroll.md +60 -6
- package/docs/ui/ScrollVariants.md +5 -1
- package/docs/ui/SidebarLayout.md +17 -8
- package/docs/ui/SpaceValue.md +1 -0
- package/docs/ui/TreeApp.md +1 -1
- package/docs/ui/getBlockClass.md +1 -1
- package/docs/ui/getGapClass.md +1 -1
- package/docs/ui/getHeightClass.md +64 -0
- package/docs/ui/getPaddingClass.md +1 -1
- package/docs/ui/getScrollClass.md +4 -2
- package/docs/ui/getSpaceClass.md +2 -0
- package/docs/ui.md +13 -8
- package/package.json +1 -1
- package/ui/README.md +1 -1
- package/ui/app/App.md +105 -7
- package/ui/docs/DocumentationApp.js +4 -1
- package/ui/docs/DocumentationApp.tsx +10 -1
- package/ui/layout/AppLayout.d.ts +21 -0
- package/ui/layout/AppLayout.js +18 -0
- package/ui/layout/AppLayout.md +57 -0
- package/ui/layout/AppLayout.module.css +106 -0
- package/ui/layout/AppLayout.tsx +36 -0
- package/ui/layout/FixedLayout.d.ts +18 -0
- package/ui/layout/FixedLayout.js +15 -0
- package/ui/layout/FixedLayout.md +65 -0
- package/ui/layout/FixedLayout.module.css +55 -0
- package/ui/layout/FixedLayout.tsx +25 -0
- package/ui/layout/SidebarLayout.d.ts +2 -2
- package/ui/layout/SidebarLayout.js +3 -4
- package/ui/layout/SidebarLayout.md +15 -6
- package/ui/layout/SidebarLayout.module.css +11 -16
- package/ui/layout/SidebarLayout.tsx +10 -13
- package/ui/layout/index.d.ts +2 -1
- package/ui/layout/index.js +2 -1
- package/ui/layout/index.tsx +2 -1
- package/ui/misc/Catcher.d.ts +2 -1
- package/ui/misc/Catcher.js +4 -3
- package/ui/misc/Catcher.md +1 -1
- package/ui/misc/Catcher.tsx +5 -4
- package/ui/misc/Loader.d.ts +1 -0
- package/ui/misc/Loader.js +6 -2
- package/ui/misc/Loader.tsx +11 -2
- package/ui/page/Page.md +12 -8
- package/ui/router/Navigation.md +20 -11
- package/ui/router/RouteCache.d.ts +2 -1
- package/ui/router/RouteCache.js +2 -1
- package/ui/router/RouteCache.md +20 -16
- package/ui/router/RouteCache.tsx +2 -1
- package/ui/router/Router.md +9 -5
- package/ui/style/Block.d.ts +3 -2
- package/ui/style/Block.js +3 -2
- package/ui/style/Block.tsx +4 -2
- package/ui/style/Gap.d.ts +1 -1
- package/ui/style/Gap.tsx +1 -1
- package/ui/style/Height.d.ts +32 -0
- package/ui/style/Height.js +13 -0
- package/ui/style/Height.module.css +88 -0
- package/ui/style/Height.tsx +61 -0
- package/ui/style/Padding.d.ts +1 -1
- package/ui/style/Padding.tsx +1 -1
- package/ui/style/Scroll.d.ts +9 -5
- package/ui/style/Scroll.js +6 -4
- package/ui/style/Scroll.md +59 -0
- package/ui/style/Scroll.module.css +13 -1
- package/ui/style/Scroll.tsx +13 -5
- package/ui/style/Space.d.ts +1 -1
- package/ui/style/Space.module.css +12 -0
- package/ui/style/Space.tsx +1 -0
- package/ui/style/getHeightClass.md +30 -0
- package/ui/style/getSpaceClass.md +2 -0
- package/ui/style/index.d.ts +1 -0
- package/ui/style/index.js +1 -0
- package/ui/style/index.ts +1 -0
- package/ui/tree/TreeApp.d.ts +1 -1
- package/ui/tree/TreeApp.js +5 -2
- package/ui/tree/TreeApp.tsx +11 -2
- package/docs/ui/CenteredLayout.md +0 -66
- package/docs/ui/CenteredLayoutProps.md +0 -14
- package/ui/layout/CenteredLayout.d.ts +0 -21
- package/ui/layout/CenteredLayout.js +0 -28
- package/ui/layout/CenteredLayout.md +0 -41
- package/ui/layout/CenteredLayout.module.css +0 -72
- package/ui/layout/CenteredLayout.tsx +0 -56
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { ReactElement } from "react";
|
|
2
|
-
import { type IndentVariants } from "../style/Indent.js";
|
|
3
|
-
import { type PaddingVariants } from "../style/Padding.js";
|
|
4
|
-
import { type WidthVariants } from "../style/Width.js";
|
|
5
|
-
import type { OptionalChildProps } from "../util/props.js";
|
|
6
|
-
/**
|
|
7
|
-
* Props for `<CenteredLayout>` — optional `children` plus `width` (of the centred column) and `padding` / `indent`
|
|
8
|
-
* (block / inline padding of the scroll area) variants.
|
|
9
|
-
*
|
|
10
|
-
* @see https://shelving.cc/ui/CenteredLayoutProps
|
|
11
|
-
*/
|
|
12
|
-
export interface CenteredLayoutProps extends WidthVariants, PaddingVariants, IndentVariants, OptionalChildProps {
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Layout that centres its content with no header/footer and a narrow max-width.
|
|
16
|
-
* - Used for e.g. login/register/error/form pages where the content is the only focus.
|
|
17
|
-
*
|
|
18
|
-
* @kind component
|
|
19
|
-
* @see https://shelving.cc/ui/CenteredLayout
|
|
20
|
-
*/
|
|
21
|
-
export declare function CenteredLayout({ children, ...props }: CenteredLayoutProps): ReactElement;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { RouteCache } from "../router/RouteCache.js";
|
|
3
|
-
import { getIndentClass } from "../style/Indent.js";
|
|
4
|
-
import { getPaddingClass } from "../style/Padding.js";
|
|
5
|
-
import { getWidthClass } from "../style/Width.js";
|
|
6
|
-
import { getClass, getModuleClass } from "../util/css.js";
|
|
7
|
-
import LAYOUT_CSS from "./CenteredLayout.module.css";
|
|
8
|
-
const LAYOUT_MAIN_CLASS = getModuleClass(LAYOUT_CSS, "main");
|
|
9
|
-
const LAYOUT_INNER_CLASS = getModuleClass(LAYOUT_CSS, "inner");
|
|
10
|
-
/**
|
|
11
|
-
* Layout that centres its content with no header/footer and a narrow max-width.
|
|
12
|
-
* - Used for e.g. login/register/error/form pages where the content is the only focus.
|
|
13
|
-
*
|
|
14
|
-
* @kind component
|
|
15
|
-
* @see https://shelving.cc/ui/CenteredLayout
|
|
16
|
-
*/
|
|
17
|
-
export function CenteredLayout({ children, ...props }) {
|
|
18
|
-
// Wrap the scrolling `<main>` in `<RouteCache>` so recently-visited pages stay mounted but hidden,
|
|
19
|
-
// keeping their scroll position and state intact across back/forward navigation.
|
|
20
|
-
//
|
|
21
|
-
// The `padding` / `indent` variants set the scroll area's block / inline padding on `<main>`, while the `width`
|
|
22
|
-
// variant sizes the centred `.inner` column. The column stays free of variant/block classes so its `margin: auto`
|
|
23
|
-
// (which does the vertical + horizontal centring) is never zeroed by the `:first-child` / `:last-child` margin
|
|
24
|
-
// collapses that `.block` carries in `@layer overrides`.
|
|
25
|
-
return (_jsx(RouteCache, { children: _jsx("main", { className: getClass(LAYOUT_MAIN_CLASS, //
|
|
26
|
-
getPaddingClass(props), getIndentClass(props)), children: _jsx("div", { className: getClass(LAYOUT_INNER_CLASS, //
|
|
27
|
-
getWidthClass(props)), children: children }) }) }));
|
|
28
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# CenteredLayout
|
|
2
|
-
|
|
3
|
-
A full-viewport layout that centres its content — vertically and horizontally — inside a narrow max-width column. Good for login, registration, error, and other focused single-purpose pages where the content is the only thing on screen. When the content is taller than the viewport it scrolls vertically, pinned to the top so nothing is clipped.
|
|
4
|
-
|
|
5
|
-
**Things to know:**
|
|
6
|
-
|
|
7
|
-
- Pass the `width` variant to resize the centred column (e.g. `width="normal"`, `width="wide"`, or `width="full"` to fill the available width).
|
|
8
|
-
- Pass the `padding` (block / top + bottom) and `indent` (inline / left + right) variants to change the space around the content.
|
|
9
|
-
- Like the other full-viewport layouts it owns scroll, padding, and safe-area insets so individual pages don't have to.
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```tsx
|
|
14
|
-
import { CenteredLayout, Section } from "shelving/ui";
|
|
15
|
-
|
|
16
|
-
function LoginPage() {
|
|
17
|
-
return (
|
|
18
|
-
<CenteredLayout width="narrow">
|
|
19
|
-
<Section>
|
|
20
|
-
<LoginForm/>
|
|
21
|
-
</Section>
|
|
22
|
-
</CenteredLayout>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Layouts compose naturally as `<Router>` route values — wrap a group of routes in a shared layout, then route further inside it.
|
|
28
|
-
|
|
29
|
-
## Styling
|
|
30
|
-
|
|
31
|
-
| Variable | Styles | Default |
|
|
32
|
-
|---|---|---|
|
|
33
|
-
| `--centered-layout-width` | Width of the centred column (capped at 100%) | `var(--width-narrow)` |
|
|
34
|
-
| `--centered-layout-padding` | Block (top/bottom) padding of the scroll area | `var(--space-normal)` |
|
|
35
|
-
| `--centered-layout-indent` | Inline (left/right) padding of the scroll area | `var(--space-normal)` |
|
|
36
|
-
| `--centered-layout-background` | Page background while the layout is mounted | `var(--tint-100)` (white) |
|
|
37
|
-
| `--centered-layout-color` | Text colour for the layout | `var(--tint-00)` (black) |
|
|
38
|
-
|
|
39
|
-
The column width and the scroll-area padding can also be set per-instance via the `width`, `padding`, and `indent` variant props. The outer element owns its scroll, padding, and safe-area behaviour directly — safe-area insets are applied as transparent borders so they stack with (rather than replace) the padding.
|
|
40
|
-
|
|
41
|
-
**Global tokens it reads** — `--width-narrow`, `--space-normal`, `--tint-100`, and `--tint-00`.
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
@import url("../style/layers.css");
|
|
2
|
-
@import url("../style/Space.module.css");
|
|
3
|
-
@import url("../style/Tint.module.css");
|
|
4
|
-
@import url("../style/Width.module.css");
|
|
5
|
-
|
|
6
|
-
@layer components {
|
|
7
|
-
/*
|
|
8
|
-
* Lock the document and let `.main` own the page scroll.
|
|
9
|
-
* - <html> and <body> are pinned to the viewport (no rubber-band on iOS).
|
|
10
|
-
* - <body> stacks its children vertically (flex column).
|
|
11
|
-
* - The `.main` element grows to fill the body and is the only scroll container.
|
|
12
|
-
*/
|
|
13
|
-
html:has(.main) {
|
|
14
|
-
/* Box */
|
|
15
|
-
margin: 0;
|
|
16
|
-
padding: 0;
|
|
17
|
-
height: 100vh;
|
|
18
|
-
height: 100dvh; /* Make the height dynamically expand/contract as the address bar shows/hides on iOS. */
|
|
19
|
-
width: 100vw;
|
|
20
|
-
width: 100dvw;
|
|
21
|
-
|
|
22
|
-
/* Contents */
|
|
23
|
-
overflow: hidden;
|
|
24
|
-
overflow-wrap: break-word; /* Break overlong words only as a last resort. */
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
body:has(.main) {
|
|
28
|
-
/* Box */
|
|
29
|
-
margin: 0;
|
|
30
|
-
padding: 0;
|
|
31
|
-
display: flex;
|
|
32
|
-
flex-direction: column;
|
|
33
|
-
|
|
34
|
-
/* Lock body to prevent iOS Safari triggering viewport scrolling on focus change. */
|
|
35
|
-
position: fixed;
|
|
36
|
-
inset: 0;
|
|
37
|
-
|
|
38
|
-
/* Page background + text colour; fall back to the themed page defaults (--tint-100 / --tint-00) when the hooks are unset. */
|
|
39
|
-
background: var(--centered-layout-background, var(--tint-100));
|
|
40
|
-
color: var(--centered-layout-color, var(--tint-00));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.main {
|
|
44
|
-
/* Box */
|
|
45
|
-
border-top: env(safe-area-inset-top, 0) solid transparent;
|
|
46
|
-
border-bottom: env(safe-area-inset-bottom, 0) solid transparent;
|
|
47
|
-
border-left: env(safe-area-inset-left, 0) solid transparent;
|
|
48
|
-
border-right: env(safe-area-inset-right, 0) solid transparent;
|
|
49
|
-
padding-block: var(--centered-layout-padding, var(--space-normal));
|
|
50
|
-
padding-inline: var(--centered-layout-indent, var(--space-normal));
|
|
51
|
-
|
|
52
|
-
/* Grow to fill the body. */
|
|
53
|
-
flex: 1;
|
|
54
|
-
|
|
55
|
-
/* Content — a flex column whose inner column centres itself with `margin: auto` (both axes). */
|
|
56
|
-
display: flex;
|
|
57
|
-
flex-direction: column;
|
|
58
|
-
align-items: center;
|
|
59
|
-
justify-content: start;
|
|
60
|
-
|
|
61
|
-
/* Scrolling */
|
|
62
|
-
overflow: hidden auto;
|
|
63
|
-
overscroll-behavior: auto contain;
|
|
64
|
-
scroll-behavior: smooth;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.inner {
|
|
68
|
-
width: var(--centered-layout-width, var(--width-narrow));
|
|
69
|
-
max-width: 100%;
|
|
70
|
-
margin: auto;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { ReactElement } from "react";
|
|
2
|
-
import { RouteCache } from "../router/RouteCache.js";
|
|
3
|
-
import { getIndentClass, type IndentVariants } from "../style/Indent.js";
|
|
4
|
-
import { getPaddingClass, type PaddingVariants } from "../style/Padding.js";
|
|
5
|
-
import { getWidthClass, type WidthVariants } from "../style/Width.js";
|
|
6
|
-
import { getClass, getModuleClass } from "../util/css.js";
|
|
7
|
-
import type { OptionalChildProps } from "../util/props.js";
|
|
8
|
-
import LAYOUT_CSS from "./CenteredLayout.module.css";
|
|
9
|
-
|
|
10
|
-
const LAYOUT_MAIN_CLASS = getModuleClass(LAYOUT_CSS, "main");
|
|
11
|
-
const LAYOUT_INNER_CLASS = getModuleClass(LAYOUT_CSS, "inner");
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Props for `<CenteredLayout>` — optional `children` plus `width` (of the centred column) and `padding` / `indent`
|
|
15
|
-
* (block / inline padding of the scroll area) variants.
|
|
16
|
-
*
|
|
17
|
-
* @see https://shelving.cc/ui/CenteredLayoutProps
|
|
18
|
-
*/
|
|
19
|
-
export interface CenteredLayoutProps extends WidthVariants, PaddingVariants, IndentVariants, OptionalChildProps {}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Layout that centres its content with no header/footer and a narrow max-width.
|
|
23
|
-
* - Used for e.g. login/register/error/form pages where the content is the only focus.
|
|
24
|
-
*
|
|
25
|
-
* @kind component
|
|
26
|
-
* @see https://shelving.cc/ui/CenteredLayout
|
|
27
|
-
*/
|
|
28
|
-
export function CenteredLayout({ children, ...props }: CenteredLayoutProps): ReactElement {
|
|
29
|
-
// Wrap the scrolling `<main>` in `<RouteCache>` so recently-visited pages stay mounted but hidden,
|
|
30
|
-
// keeping their scroll position and state intact across back/forward navigation.
|
|
31
|
-
//
|
|
32
|
-
// The `padding` / `indent` variants set the scroll area's block / inline padding on `<main>`, while the `width`
|
|
33
|
-
// variant sizes the centred `.inner` column. The column stays free of variant/block classes so its `margin: auto`
|
|
34
|
-
// (which does the vertical + horizontal centring) is never zeroed by the `:first-child` / `:last-child` margin
|
|
35
|
-
// collapses that `.block` carries in `@layer overrides`.
|
|
36
|
-
return (
|
|
37
|
-
<RouteCache>
|
|
38
|
-
<main
|
|
39
|
-
className={getClass(
|
|
40
|
-
LAYOUT_MAIN_CLASS, //
|
|
41
|
-
getPaddingClass(props),
|
|
42
|
-
getIndentClass(props),
|
|
43
|
-
)}
|
|
44
|
-
>
|
|
45
|
-
<div
|
|
46
|
-
className={getClass(
|
|
47
|
-
LAYOUT_INNER_CLASS, //
|
|
48
|
-
getWidthClass(props),
|
|
49
|
-
)}
|
|
50
|
-
>
|
|
51
|
-
{children}
|
|
52
|
-
</div>
|
|
53
|
-
</main>
|
|
54
|
-
</RouteCache>
|
|
55
|
-
);
|
|
56
|
-
}
|