shelving 1.238.0 → 1.239.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/package.json +1 -1
- package/ui/block/Panel.d.ts +6 -5
- package/ui/block/Panel.js +6 -5
- package/ui/block/Panel.module.css +4 -4
- package/ui/block/Panel.tsx +7 -5
- package/ui/docs/DocumentationHomePage.d.ts +15 -0
- package/ui/docs/DocumentationHomePage.js +24 -0
- package/ui/docs/DocumentationHomePage.md +42 -0
- package/ui/docs/DocumentationHomePage.test.tsx +35 -0
- package/ui/docs/DocumentationHomePage.tsx +46 -0
- package/ui/docs/index.d.ts +1 -0
- package/ui/docs/index.js +1 -0
- package/ui/docs/index.ts +1 -0
package/package.json
CHANGED
package/ui/block/Panel.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import { type ColorVariants } from "../style/Color.js";
|
|
3
|
+
import { type PaddingVariants } from "../style/Padding.js";
|
|
3
4
|
import { type StatusVariants } from "../style/Status.js";
|
|
4
5
|
import { type TypographyVariants } from "../style/Typography.js";
|
|
5
6
|
import type { OptionalChildProps } from "../util/props.js";
|
|
@@ -14,20 +15,20 @@ export type PanelElement = "section" | "header" | "footer" | "nav" | "aside" | "
|
|
|
14
15
|
*
|
|
15
16
|
* @see https://dhoulb.github.io/shelving/ui/block/Panel/PanelProps
|
|
16
17
|
*/
|
|
17
|
-
export interface PanelProps extends ColorVariants, StatusVariants, TypographyVariants, OptionalChildProps {
|
|
18
|
+
export interface PanelProps extends ColorVariants, PaddingVariants, StatusVariants, TypographyVariants, OptionalChildProps {
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* Full-width vertical region that paints the current surface colour. Use to break a page into stacked
|
|
21
|
-
* sections. Has zero block-space (Panels butt against each other)
|
|
22
|
-
*
|
|
22
|
+
* sections. Has zero block-space (Panels butt against each other); set its vertical breathing room
|
|
23
|
+
* with the `padding` variant (`<Panel padding="large">`, `<Panel padding="xxlarge">` etc.).
|
|
23
24
|
*
|
|
24
25
|
* Renders as a `<section>` by default; pass `as="header"` etc. for other semantic elements.
|
|
25
26
|
*
|
|
26
27
|
* @kind component
|
|
27
|
-
* @param props Colour, status, and typography variants plus `children`.
|
|
28
|
+
* @param props Colour, padding, status, and typography variants plus `children`.
|
|
28
29
|
* @returns Rendered full-width panel region.
|
|
29
30
|
* @example <Panel><Block narrow><Title>Welcome</Title></Block></Panel>
|
|
30
|
-
* @example <Panel
|
|
31
|
+
* @example <Panel padding="xlarge" color="primary"><Title>Welcome</Title></Panel>
|
|
31
32
|
* @see https://dhoulb.github.io/shelving/ui/block/Panel/Panel
|
|
32
33
|
*/
|
|
33
34
|
export declare function Panel({ children, ...props }: PanelProps): ReactElement;
|
package/ui/block/Panel.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getColorClass } from "../style/Color.js";
|
|
3
|
+
import { getPaddingClass } from "../style/Padding.js";
|
|
3
4
|
import { getStatusClass } from "../style/Status.js";
|
|
4
5
|
import { getTypographyClass } from "../style/Typography.js";
|
|
5
6
|
import { getClass, getModuleClass } from "../util/css.js";
|
|
@@ -7,19 +8,19 @@ import PANEL_CSS from "./Panel.module.css";
|
|
|
7
8
|
const PANEL_CLASS = getModuleClass(PANEL_CSS, "panel");
|
|
8
9
|
/**
|
|
9
10
|
* Full-width vertical region that paints the current surface colour. Use to break a page into stacked
|
|
10
|
-
* sections. Has zero block-space (Panels butt against each other)
|
|
11
|
-
*
|
|
11
|
+
* sections. Has zero block-space (Panels butt against each other); set its vertical breathing room
|
|
12
|
+
* with the `padding` variant (`<Panel padding="large">`, `<Panel padding="xxlarge">` etc.).
|
|
12
13
|
*
|
|
13
14
|
* Renders as a `<section>` by default; pass `as="header"` etc. for other semantic elements.
|
|
14
15
|
*
|
|
15
16
|
* @kind component
|
|
16
|
-
* @param props Colour, status, and typography variants plus `children`.
|
|
17
|
+
* @param props Colour, padding, status, and typography variants plus `children`.
|
|
17
18
|
* @returns Rendered full-width panel region.
|
|
18
19
|
* @example <Panel><Block narrow><Title>Welcome</Title></Block></Panel>
|
|
19
|
-
* @example <Panel
|
|
20
|
+
* @example <Panel padding="xlarge" color="primary"><Title>Welcome</Title></Panel>
|
|
20
21
|
* @see https://dhoulb.github.io/shelving/ui/block/Panel/Panel
|
|
21
22
|
*/
|
|
22
23
|
export function Panel({ children, ...props }) {
|
|
23
24
|
return (_jsx("div", { className: getClass(PANEL_CLASS, //
|
|
24
|
-
getStatusClass(props), getColorClass(props), getTypographyClass(props)), children: children }));
|
|
25
|
+
getStatusClass(props), getColorClass(props), getPaddingClass(props), getTypographyClass(props)), children: children }));
|
|
25
26
|
}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
* Full-width vertical region that paints the current surface. Panels always have zero block-space
|
|
7
|
-
* (they butt up against each other vertically to create stacked page sections)
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* inside a wide panel, compose a `<Block narrow>` (or `<Block wide>`) inside it.
|
|
7
|
+
* (they butt up against each other vertically to create stacked page sections). Vertical breathing
|
|
8
|
+
* room comes from the shared `padding` variant (`.large`, `.xxlarge`, etc. from `style/Padding`);
|
|
9
|
+
* with no `padding` the block padding is zero and the inner `<Section>` margins provide the spacing.
|
|
10
|
+
* For narrower content inside a wide panel, compose a `<Block narrow>` (or `<Block wide>`) inside it.
|
|
11
11
|
*/
|
|
12
12
|
@layer components {
|
|
13
13
|
.panel {
|
package/ui/block/Panel.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import { type ColorVariants, getColorClass } from "../style/Color.js";
|
|
3
|
+
import { getPaddingClass, type PaddingVariants } from "../style/Padding.js";
|
|
3
4
|
import { getStatusClass, type StatusVariants } from "../style/Status.js";
|
|
4
5
|
import { getTypographyClass, type TypographyVariants } from "../style/Typography.js";
|
|
5
6
|
import { getClass, getModuleClass } from "../util/css.js";
|
|
@@ -20,20 +21,20 @@ export type PanelElement = "section" | "header" | "footer" | "nav" | "aside" | "
|
|
|
20
21
|
*
|
|
21
22
|
* @see https://dhoulb.github.io/shelving/ui/block/Panel/PanelProps
|
|
22
23
|
*/
|
|
23
|
-
export interface PanelProps extends ColorVariants, StatusVariants, TypographyVariants, OptionalChildProps {}
|
|
24
|
+
export interface PanelProps extends ColorVariants, PaddingVariants, StatusVariants, TypographyVariants, OptionalChildProps {}
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Full-width vertical region that paints the current surface colour. Use to break a page into stacked
|
|
27
|
-
* sections. Has zero block-space (Panels butt against each other)
|
|
28
|
-
*
|
|
28
|
+
* sections. Has zero block-space (Panels butt against each other); set its vertical breathing room
|
|
29
|
+
* with the `padding` variant (`<Panel padding="large">`, `<Panel padding="xxlarge">` etc.).
|
|
29
30
|
*
|
|
30
31
|
* Renders as a `<section>` by default; pass `as="header"` etc. for other semantic elements.
|
|
31
32
|
*
|
|
32
33
|
* @kind component
|
|
33
|
-
* @param props Colour, status, and typography variants plus `children`.
|
|
34
|
+
* @param props Colour, padding, status, and typography variants plus `children`.
|
|
34
35
|
* @returns Rendered full-width panel region.
|
|
35
36
|
* @example <Panel><Block narrow><Title>Welcome</Title></Block></Panel>
|
|
36
|
-
* @example <Panel
|
|
37
|
+
* @example <Panel padding="xlarge" color="primary"><Title>Welcome</Title></Panel>
|
|
37
38
|
* @see https://dhoulb.github.io/shelving/ui/block/Panel/Panel
|
|
38
39
|
*/
|
|
39
40
|
export function Panel({ children, ...props }: PanelProps): ReactElement {
|
|
@@ -43,6 +44,7 @@ export function Panel({ children, ...props }: PanelProps): ReactElement {
|
|
|
43
44
|
PANEL_CLASS, //
|
|
44
45
|
getStatusClass(props),
|
|
45
46
|
getColorClass(props),
|
|
47
|
+
getPaddingClass(props),
|
|
46
48
|
getTypographyClass(props),
|
|
47
49
|
)}
|
|
48
50
|
>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { TreeElementProps } from "../../util/tree.js";
|
|
3
|
+
/**
|
|
4
|
+
* Page renderer for the documentation site's home page — a bold coloured hero panel over the module listing.
|
|
5
|
+
* - The whole page sits in a single `color="red"` `<Block>`, so the hero panel, prose, and child cards all pick up the red tint.
|
|
6
|
+
* - The hero is a full-padding `<Panel>` with the package name centred as a large `<Title>`.
|
|
7
|
+
* - Below the hero it renders any absorbed prose content, then the root's children (the modules) as a stack of cards.
|
|
8
|
+
*
|
|
9
|
+
* @kind component
|
|
10
|
+
* @param props The root tree element props (`title`, `name`, `description`, `content`, `children`).
|
|
11
|
+
* @returns A `<Page>` with a coloured hero panel followed by the module listing.
|
|
12
|
+
* @example <DocumentationHomePage {...root.props} />
|
|
13
|
+
* @see https://dhoulb.github.io/shelving/ui/docs/DocumentationHomePage/DocumentationHomePage
|
|
14
|
+
*/
|
|
15
|
+
export declare function DocumentationHomePage({ title, name, description, content, children }: TreeElementProps): ReactNode;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Block } from "../block/Block.js";
|
|
3
|
+
import { Panel } from "../block/Panel.js";
|
|
4
|
+
import { Prose } from "../block/Prose.js";
|
|
5
|
+
import { Section } from "../block/Section.js";
|
|
6
|
+
import { Title } from "../block/Title.js";
|
|
7
|
+
import { Markup } from "../misc/Markup.js";
|
|
8
|
+
import { Page } from "../page/Page.js";
|
|
9
|
+
import { TreeCards } from "../tree/TreeCards.js";
|
|
10
|
+
/**
|
|
11
|
+
* Page renderer for the documentation site's home page — a bold coloured hero panel over the module listing.
|
|
12
|
+
* - The whole page sits in a single `color="red"` `<Block>`, so the hero panel, prose, and child cards all pick up the red tint.
|
|
13
|
+
* - The hero is a full-padding `<Panel>` with the package name centred as a large `<Title>`.
|
|
14
|
+
* - Below the hero it renders any absorbed prose content, then the root's children (the modules) as a stack of cards.
|
|
15
|
+
*
|
|
16
|
+
* @kind component
|
|
17
|
+
* @param props The root tree element props (`title`, `name`, `description`, `content`, `children`).
|
|
18
|
+
* @returns A `<Page>` with a coloured hero panel followed by the module listing.
|
|
19
|
+
* @example <DocumentationHomePage {...root.props} />
|
|
20
|
+
* @see https://dhoulb.github.io/shelving/ui/docs/DocumentationHomePage/DocumentationHomePage
|
|
21
|
+
*/
|
|
22
|
+
export function DocumentationHomePage({ title, name, description, content, children }) {
|
|
23
|
+
return (_jsx(Page, { title: title ?? name, description: description, children: _jsxs(Block, { color: "red", children: [_jsx(Panel, { padding: "xxlarge", children: _jsx(Title, { center: true, size: "xxlarge", children: title ?? name }) }), content && (_jsx(Section, { wide: true, children: _jsx(Prose, { children: _jsx(Markup, { children: content }) }) })), _jsx(Section, { wide: true, children: _jsx(TreeCards, { children: children }) })] }) }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# DocumentationHomePage
|
|
2
|
+
|
|
3
|
+
The landing page for a documentation site — a bold coloured hero panel with the package name, sitting above the listing of every module. Swap it in for the root element via [`TreeRouterMapping`](/ui/TreeRouter) so the home route (`/`) renders this instead of the generic [`TreePage`](/ui/TreePage).
|
|
4
|
+
|
|
5
|
+
**Things to know:**
|
|
6
|
+
|
|
7
|
+
- The whole page sits inside one `color="red"` [`Block`](/ui/Block), so the hero [`Panel`](/ui/Panel), prose, and child [`DocumentationCard`](/ui/DocumentationCard)s all inherit the red tint and re-derive together.
|
|
8
|
+
- The hero is a `padding="xxlarge"` [`Panel`](/ui/Panel) with the package name centred as a large [`Title`](/ui/Title) (`center`, `size="xxlarge"`).
|
|
9
|
+
- Below the hero it renders any absorbed README prose, then the root's children (the modules) as a stack of cards via [`TreeCards`](/ui/TreeCards).
|
|
10
|
+
- It consumes the same [`TreeElementProps`](/util/tree) as [`TreePage`](/ui/TreePage), so it's a drop-in replacement for the `tree-element` renderer.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
Wire it in as the renderer for the root `tree-element` so the home route uses it:
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { DocumentationHomePage, TreeApp, TreeRouterMapping } from "shelving/ui";
|
|
18
|
+
|
|
19
|
+
<TreeRouterMapping mapping={{ "tree-element": DocumentationHomePage }}>
|
|
20
|
+
<TreeApp tree={tree} />
|
|
21
|
+
</TreeRouterMapping>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or render a single page manually by spreading the root element's props:
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { DocumentationHomePage } from "shelving/ui";
|
|
28
|
+
|
|
29
|
+
<DocumentationHomePage {...root.props} />
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Styling
|
|
33
|
+
|
|
34
|
+
`DocumentationHomePage` has no own CSS hooks — it composes [`Page`](/ui/Page), [`Block`](/ui/Block), [`Panel`](/ui/Panel), [`Title`](/ui/Title), [`Section`](/ui/Section), and [`TreeCards`](/ui/TreeCards), which carry their own themeable surfaces. Retheme through those, or change the hero colour via the `color=` on the wrapping `Block`.
|
|
35
|
+
|
|
36
|
+
## See also
|
|
37
|
+
|
|
38
|
+
- [`TreePage`](/ui/TreePage) — the generic `tree-element` renderer this replaces for the home route.
|
|
39
|
+
- [`DocumentationPage`](/ui/DocumentationPage) — the per-symbol detail page that uses the same coloured-panel hero pattern.
|
|
40
|
+
- [`Panel`](/ui/Panel) — the full-width hero band, here with `padding="xxlarge"`.
|
|
41
|
+
- [`TreeCards`](/ui/TreeCards) — the module card listing rendered below the hero.
|
|
42
|
+
- [`TreeApp`](/ui/TreeApp) — wires renderers into a complete site.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
4
|
+
import type { DocumentationElement } from "../../util/tree.js";
|
|
5
|
+
import { MetaContext } from "../misc/MetaContext.js";
|
|
6
|
+
import { createMeta } from "../util/meta.js";
|
|
7
|
+
import { DocumentationHomePage } from "./DocumentationHomePage.js";
|
|
8
|
+
|
|
9
|
+
/** Make a minimal `kind: "module"` child element. */
|
|
10
|
+
function mod(name: string): DocumentationElement {
|
|
11
|
+
return { type: "tree-documentation", key: name, props: { name, kind: "module" } };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Render inside a `MetaContext` — the child cards read the current URL from it. */
|
|
15
|
+
function render(node: ReactNode, url = "./"): string {
|
|
16
|
+
return renderToStaticMarkup(<MetaContext value={createMeta({ root: "http://x.com/", url })}>{node}</MetaContext>);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
describe("DocumentationHomePage", () => {
|
|
20
|
+
test("renders the title as a hero and lists the modules", () => {
|
|
21
|
+
const html = render(
|
|
22
|
+
<DocumentationHomePage name="shelving" title="shelving">
|
|
23
|
+
{[mod("util"), mod("schema")]}
|
|
24
|
+
</DocumentationHomePage>,
|
|
25
|
+
);
|
|
26
|
+
expect(html).toContain("shelving");
|
|
27
|
+
expect(html).toContain("util");
|
|
28
|
+
expect(html).toContain("schema");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("falls back to `name` when no `title` is set", () => {
|
|
32
|
+
const html = render(<DocumentationHomePage name="shelving">{[mod("util")]}</DocumentationHomePage>);
|
|
33
|
+
expect(html).toContain("shelving");
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { TreeElementProps } from "../../util/tree.js";
|
|
3
|
+
import { Block } from "../block/Block.js";
|
|
4
|
+
import { Panel } from "../block/Panel.js";
|
|
5
|
+
import { Prose } from "../block/Prose.js";
|
|
6
|
+
import { Section } from "../block/Section.js";
|
|
7
|
+
import { Title } from "../block/Title.js";
|
|
8
|
+
import { Markup } from "../misc/Markup.js";
|
|
9
|
+
import { Page } from "../page/Page.js";
|
|
10
|
+
import { TreeCards } from "../tree/TreeCards.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Page renderer for the documentation site's home page — a bold coloured hero panel over the module listing.
|
|
14
|
+
* - The whole page sits in a single `color="red"` `<Block>`, so the hero panel, prose, and child cards all pick up the red tint.
|
|
15
|
+
* - The hero is a full-padding `<Panel>` with the package name centred as a large `<Title>`.
|
|
16
|
+
* - Below the hero it renders any absorbed prose content, then the root's children (the modules) as a stack of cards.
|
|
17
|
+
*
|
|
18
|
+
* @kind component
|
|
19
|
+
* @param props The root tree element props (`title`, `name`, `description`, `content`, `children`).
|
|
20
|
+
* @returns A `<Page>` with a coloured hero panel followed by the module listing.
|
|
21
|
+
* @example <DocumentationHomePage {...root.props} />
|
|
22
|
+
* @see https://dhoulb.github.io/shelving/ui/docs/DocumentationHomePage/DocumentationHomePage
|
|
23
|
+
*/
|
|
24
|
+
export function DocumentationHomePage({ title, name, description, content, children }: TreeElementProps): ReactNode {
|
|
25
|
+
return (
|
|
26
|
+
<Page title={title ?? name} description={description}>
|
|
27
|
+
<Block color="red">
|
|
28
|
+
<Panel padding="xxlarge">
|
|
29
|
+
<Title center size="xxlarge">
|
|
30
|
+
{title ?? name}
|
|
31
|
+
</Title>
|
|
32
|
+
</Panel>
|
|
33
|
+
{content && (
|
|
34
|
+
<Section wide>
|
|
35
|
+
<Prose>
|
|
36
|
+
<Markup>{content}</Markup>
|
|
37
|
+
</Prose>
|
|
38
|
+
</Section>
|
|
39
|
+
)}
|
|
40
|
+
<Section wide>
|
|
41
|
+
<TreeCards>{children}</TreeCards>
|
|
42
|
+
</Section>
|
|
43
|
+
</Block>
|
|
44
|
+
</Page>
|
|
45
|
+
);
|
|
46
|
+
}
|
package/ui/docs/index.d.ts
CHANGED
package/ui/docs/index.js
CHANGED
package/ui/docs/index.ts
CHANGED