shelving 1.292.2 → 1.293.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/Card.module.css +2 -1
- package/ui/docs/DocumentationApp.js +1 -1
- package/ui/docs/DocumentationApp.tsx +1 -1
- package/ui/menu/Menu.d.ts +8 -2
- package/ui/menu/Menu.js +7 -4
- package/ui/menu/Menu.md +6 -4
- package/ui/menu/Menu.module.css +32 -6
- package/ui/menu/Menu.tsx +13 -3
- package/ui/menu/MenuItem.md +27 -3
- package/ui/tree/TreeSidebar.d.ts +1 -0
- package/ui/tree/TreeSidebar.js +2 -1
- package/ui/tree/TreeSidebar.tsx +3 -2
package/package.json
CHANGED
package/ui/block/Card.module.css
CHANGED
|
@@ -9,6 +9,6 @@ import { DocumentationSearchPage } from "./DocumentationSearchPage.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export function DocumentationApp({ tree, routes = {
|
|
11
11
|
"/search": DocumentationSearchPage,
|
|
12
|
-
}, sidebar = (_jsx(TreeSidebar, { children: _jsx(Menu, { children: _jsx(MenuItem, { href: "/search", children: "Search" }) }) })), ...meta }) {
|
|
12
|
+
}, sidebar = (_jsx(TreeSidebar, { children: _jsx(Menu, { small: true, children: _jsx(MenuItem, { href: "/search", children: "Search" }) }) })), ...meta }) {
|
|
13
13
|
return _jsx(TreeApp, { tree: tree, routes: routes, sidebar: sidebar, ...meta });
|
|
14
14
|
}
|
package/ui/menu/Menu.d.ts
CHANGED
|
@@ -8,16 +8,19 @@ import type { ClassProps, OptionalChildProps } from "../util/props.js";
|
|
|
8
8
|
* @see https://shelving.cc/ui/MenuProps
|
|
9
9
|
*/
|
|
10
10
|
export interface MenuProps extends BlockVariants, OptionalChildProps, ClassProps {
|
|
11
|
+
/** Make every item in the menu (and in any nested menu) small, as if each `<MenuItem>` had `small`. */
|
|
12
|
+
readonly small?: boolean | undefined;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* A `<menu>` list of `<MenuItem>` children.
|
|
14
16
|
* - Renders as a bare `<menu>` element — semantically equivalent to `<ul>` per HTML spec but more meaningful for menu contexts. Place inside a `<nav>` (or use the sidebar-style nav at the layout level) if a navigation landmark is needed.
|
|
15
17
|
* - Nested `<Menu>` instances (typically inside a `<MenuItem>`) get indented via the `.menu .menu` CSS rule.
|
|
18
|
+
* - Pass `small` to make every item smaller, for example in a dense sidebar.
|
|
16
19
|
*
|
|
17
20
|
* @kind component
|
|
18
21
|
* @see https://shelving.cc/ui/Menu
|
|
19
22
|
*/
|
|
20
|
-
export declare function Menu({ children, className, ...props }: MenuProps): ReactNode;
|
|
23
|
+
export declare function Menu({ children, small, className, ...props }: MenuProps): ReactNode;
|
|
21
24
|
/**
|
|
22
25
|
* Props for `<MenuItem>` — `<Clickable>` props plus `children` whose first node is the label and the rest the submenu.
|
|
23
26
|
*
|
|
@@ -29,13 +32,16 @@ export interface MenuItemProps extends ClickableProps, ClassProps {
|
|
|
29
32
|
* - Any additional children form the submenu — only rendered when this item is "proud" (an ancestor of the current page). The caller is responsible for wrapping the submenu in a nested `<Menu>` if it wants the CSS `.menu .menu` descendant rules to apply.
|
|
30
33
|
*/
|
|
31
34
|
readonly children: ReactNode | readonly [ReactNode, ...ReactNode[]];
|
|
35
|
+
/** Make the item smaller: less padding and no minimum height. By default an item is as tall as a `<Button>`, so it is easy to tap. */
|
|
36
|
+
readonly small?: boolean | undefined;
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* A `<li>` containing an `<a>` link, plus optional submenu content shown when this item is "proud".
|
|
35
40
|
* - Reads the current page URL from `<Meta>` and computes `active` / `proud` against its own `href`.
|
|
36
41
|
* - Splits `children` into `[label, ...after]`: label goes inside the `<a>`; `after` is rendered as siblings below it, only when proud.
|
|
42
|
+
* - As tall as a `<Button>` by default, so it is easy to tap. Pass `small` for a denser item.
|
|
37
43
|
*
|
|
38
44
|
* @kind component
|
|
39
45
|
* @see https://shelving.cc/ui/MenuItem
|
|
40
46
|
*/
|
|
41
|
-
export declare function MenuItem({ href, children, className, ...props }: MenuItemProps): ReactNode;
|
|
47
|
+
export declare function MenuItem({ href, children, small, className, ...props }: MenuItemProps): ReactNode;
|
package/ui/menu/Menu.js
CHANGED
|
@@ -11,32 +11,35 @@ const MENU_ITEM_CLASS = getModuleClass(MENU_CSS, "item");
|
|
|
11
11
|
const MENU_LINK_CLASS = getModuleClass(MENU_CSS, "link");
|
|
12
12
|
const MENU_PROUD_CLASS = getModuleClass(MENU_CSS, "proud");
|
|
13
13
|
const MENU_ACTIVE_CLASS = getModuleClass(MENU_CSS, "active");
|
|
14
|
+
const MENU_SMALL_CLASS = getModuleClass(MENU_CSS, "small");
|
|
14
15
|
/**
|
|
15
16
|
* A `<menu>` list of `<MenuItem>` children.
|
|
16
17
|
* - Renders as a bare `<menu>` element — semantically equivalent to `<ul>` per HTML spec but more meaningful for menu contexts. Place inside a `<nav>` (or use the sidebar-style nav at the layout level) if a navigation landmark is needed.
|
|
17
18
|
* - Nested `<Menu>` instances (typically inside a `<MenuItem>`) get indented via the `.menu .menu` CSS rule.
|
|
19
|
+
* - Pass `small` to make every item smaller, for example in a dense sidebar.
|
|
18
20
|
*
|
|
19
21
|
* @kind component
|
|
20
22
|
* @see https://shelving.cc/ui/Menu
|
|
21
23
|
*/
|
|
22
|
-
export function Menu({ children, className, ...props }) {
|
|
24
|
+
export function Menu({ children, small, className, ...props }) {
|
|
23
25
|
return (_jsx("menu", { className: getClass(MENU_CLASS, //
|
|
24
|
-
getBlockClass(props), className), children: children }));
|
|
26
|
+
small && MENU_SMALL_CLASS, getBlockClass(props), className), children: children }));
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
29
|
* A `<li>` containing an `<a>` link, plus optional submenu content shown when this item is "proud".
|
|
28
30
|
* - Reads the current page URL from `<Meta>` and computes `active` / `proud` against its own `href`.
|
|
29
31
|
* - Splits `children` into `[label, ...after]`: label goes inside the `<a>`; `after` is rendered as siblings below it, only when proud.
|
|
32
|
+
* - As tall as a `<Button>` by default, so it is easy to tap. Pass `small` for a denser item.
|
|
30
33
|
*
|
|
31
34
|
* @kind component
|
|
32
35
|
* @see https://shelving.cc/ui/MenuItem
|
|
33
36
|
*/
|
|
34
|
-
export function MenuItem({ href, children, className, ...props }) {
|
|
37
|
+
export function MenuItem({ href, children, small, className, ...props }) {
|
|
35
38
|
const { url, root } = requireMeta();
|
|
36
39
|
const link = getLink(href, url, root);
|
|
37
40
|
const proud = isURLProud(url, link);
|
|
38
41
|
const active = isURLActive(url, link);
|
|
39
42
|
const [label, ...after] = isArray(children) ? children : [children];
|
|
40
43
|
return (_jsxs("li", { className: getClass(MENU_ITEM_CLASS, className), children: [_jsx(Clickable, { href: href, ...props, className: getClass(MENU_LINK_CLASS, //
|
|
41
|
-
proud && MENU_PROUD_CLASS, active && MENU_ACTIVE_CLASS), children: label }), proud && after] }));
|
|
44
|
+
small && MENU_SMALL_CLASS, proud && MENU_PROUD_CLASS, active && MENU_ACTIVE_CLASS), children: label }), proud && after] }));
|
|
42
45
|
}
|
package/ui/menu/Menu.md
CHANGED
|
@@ -6,6 +6,7 @@ A `<menu>` list of `<MenuItem>` children — the container for URL-aware navigat
|
|
|
6
6
|
|
|
7
7
|
- Renders as a bare `<menu>` element (semantically equivalent to `<ul>` but more meaningful for menus). Place it inside a `<nav>` — or a `<SidebarLayout>` sidebar, which is already a `<nav>` landmark — if a navigation landmark is needed.
|
|
8
8
|
- Nesting a `<Menu>` inside a `<MenuItem>` gets indented automatically via the `.menu .menu` descendant rule.
|
|
9
|
+
- Pass `small` to make every item inside it small, including items in nested menus. See `<MenuItem>`.
|
|
9
10
|
|
|
10
11
|
## Usage
|
|
11
12
|
|
|
@@ -35,12 +36,13 @@ import { Menu, MenuItem } from "shelving/ui";
|
|
|
35
36
|
| `--menu-leading` | Line height | `var(--leading)` |
|
|
36
37
|
| `--menu-color` | Text colour | `var(--tint-00)` |
|
|
37
38
|
| `--menu-nested-space` | Block margin around a nested submenu | `var(--space-xxsmall)` |
|
|
38
|
-
| `--menu-padding` | Item link top and bottom padding (one length) | `var(--space-
|
|
39
|
-
| `--menu-indent` | Item link left and right padding (one length; also insets the nested border) | `var(--space-
|
|
39
|
+
| `--menu-padding` | Item link top and bottom padding (one length) | `var(--space-small)` |
|
|
40
|
+
| `--menu-indent` | Item link left and right padding (one length; with `--menu-stroke`, also insets the nested border) | `var(--space-small)` |
|
|
41
|
+
| `--menu-small-indent` | Small item link left and right padding (one length; also insets the nested border of a small item) | `var(--space-xsmall)` |
|
|
40
42
|
| `--menu-nested-border` | Nested submenu left-border width | `var(--stroke-focus)` |
|
|
41
43
|
| `--menu-nested-color-border` | Nested submenu left-border colour | `var(--tint-50)` |
|
|
42
44
|
| `--menu-nested-indent` | Nested submenu left padding | `var(--space-xsmall)` |
|
|
43
45
|
|
|
44
|
-
Item-state hooks (`--menu-hover-*`, `--menu-proud-*`, `--menu-active-*`, `--menu-radius`, `--menu-focus-border`) are documented on `<MenuItem>`.
|
|
46
|
+
Item-size and item-state hooks (`--menu-stroke`, `--menu-height`, `--menu-small-*`, `--menu-hover-*`, `--menu-proud-*`, `--menu-active-*`, `--menu-radius`, `--menu-focus-border`) are documented on `<MenuItem>`.
|
|
45
47
|
|
|
46
|
-
**Global tokens it reads** — the tint ladder `--tint-00` / `--tint-50`, plus `--space-xxsmall` / `--space-xsmall`, `--font-body`, `--size-normal`, `--leading`, and `--stroke-focus`.
|
|
48
|
+
**Global tokens it reads** — the tint ladder `--tint-00` / `--tint-50`, plus `--space-xxsmall` / `--space-xsmall` / `--space-small`, `--stroke-normal`, `--font-body`, `--size-normal`, `--leading`, and `--stroke-focus`.
|
package/ui/menu/Menu.module.css
CHANGED
|
@@ -25,11 +25,17 @@
|
|
|
25
25
|
.menu {
|
|
26
26
|
margin-block: var(--menu-nested-space, var(--space-xxsmall));
|
|
27
27
|
|
|
28
|
-
/* Inset the border by the link's inline padding so it lines up with the parent item's label. */
|
|
29
|
-
margin-inline-start: var(--menu-indent, var(--space-
|
|
28
|
+
/* Inset the border by the link's border and inline padding so it lines up with the parent item's label. */
|
|
29
|
+
margin-inline-start: calc(var(--menu-stroke, var(--stroke-normal)) + var(--menu-indent, var(--space-small)));
|
|
30
30
|
border-inline-start: var(--menu-nested-border, var(--stroke-focus)) solid var(--menu-nested-color-border, var(--tint-50));
|
|
31
31
|
padding-inline-start: var(--menu-nested-indent, var(--space-xsmall));
|
|
32
32
|
}
|
|
33
|
+
|
|
34
|
+
/* A small parent item has no border and a smaller indent. */
|
|
35
|
+
&.small .menu,
|
|
36
|
+
.link.small ~ .menu {
|
|
37
|
+
margin-inline-start: var(--menu-small-indent, var(--space-xsmall));
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
.item {
|
|
@@ -41,11 +47,23 @@
|
|
|
41
47
|
display: block;
|
|
42
48
|
box-sizing: border-box;
|
|
43
49
|
inline-size: 100%;
|
|
44
|
-
padding-block: var(--menu-padding, var(--space-
|
|
45
|
-
padding-inline: var(--menu-indent, var(--space-
|
|
46
|
-
border:
|
|
50
|
+
padding-block: var(--menu-padding, var(--space-small));
|
|
51
|
+
padding-inline: var(--menu-indent, var(--space-small));
|
|
52
|
+
border: var(--menu-stroke, var(--stroke-normal)) solid transparent;
|
|
47
53
|
border-radius: var(--menu-radius, var(--radius-xsmall));
|
|
48
54
|
|
|
55
|
+
/* Match `--button-height` and `--input-height`, so an item is as easy to tap as a button. */
|
|
56
|
+
min-block-size: var(
|
|
57
|
+
--menu-height,
|
|
58
|
+
calc(
|
|
59
|
+
var(--menu-icon-size, var(--size-icon)) +
|
|
60
|
+
2 *
|
|
61
|
+
var(--menu-padding, var(--space-small)) +
|
|
62
|
+
2 *
|
|
63
|
+
var(--menu-stroke, var(--stroke-normal))
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
|
|
49
67
|
/* Style — `background`, `font`, `text-align` and `cursor` reset the native button look. */
|
|
50
68
|
background: none;
|
|
51
69
|
color: inherit;
|
|
@@ -68,7 +86,15 @@
|
|
|
68
86
|
outline-color: transparent;
|
|
69
87
|
}
|
|
70
88
|
|
|
71
|
-
/* Variants */
|
|
89
|
+
/* Variants — `small` applies to one item, or to every item inside a small `<Menu>`. */
|
|
90
|
+
&.small,
|
|
91
|
+
:where(.menu.small) & {
|
|
92
|
+
padding-block: var(--menu-small-padding, var(--space-xsmall));
|
|
93
|
+
padding-inline: var(--menu-small-indent, var(--space-xsmall));
|
|
94
|
+
border: none;
|
|
95
|
+
min-block-size: var(--menu-small-height, 0);
|
|
96
|
+
}
|
|
97
|
+
|
|
72
98
|
&.proud {
|
|
73
99
|
background: var(--menu-proud-background, transparent);
|
|
74
100
|
color: var(--menu-proud, var(--tint-00));
|
package/ui/menu/Menu.tsx
CHANGED
|
@@ -13,27 +13,33 @@ const MENU_ITEM_CLASS = getModuleClass(MENU_CSS, "item");
|
|
|
13
13
|
const MENU_LINK_CLASS = getModuleClass(MENU_CSS, "link");
|
|
14
14
|
const MENU_PROUD_CLASS = getModuleClass(MENU_CSS, "proud");
|
|
15
15
|
const MENU_ACTIVE_CLASS = getModuleClass(MENU_CSS, "active");
|
|
16
|
+
const MENU_SMALL_CLASS = getModuleClass(MENU_CSS, "small");
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Props for `<Menu>` — optional `<MenuItem>` `children`.
|
|
19
20
|
*
|
|
20
21
|
* @see https://shelving.cc/ui/MenuProps
|
|
21
22
|
*/
|
|
22
|
-
export interface MenuProps extends BlockVariants, OptionalChildProps, ClassProps {
|
|
23
|
+
export interface MenuProps extends BlockVariants, OptionalChildProps, ClassProps {
|
|
24
|
+
/** Make every item in the menu (and in any nested menu) small, as if each `<MenuItem>` had `small`. */
|
|
25
|
+
readonly small?: boolean | undefined;
|
|
26
|
+
}
|
|
23
27
|
|
|
24
28
|
/**
|
|
25
29
|
* A `<menu>` list of `<MenuItem>` children.
|
|
26
30
|
* - Renders as a bare `<menu>` element — semantically equivalent to `<ul>` per HTML spec but more meaningful for menu contexts. Place inside a `<nav>` (or use the sidebar-style nav at the layout level) if a navigation landmark is needed.
|
|
27
31
|
* - Nested `<Menu>` instances (typically inside a `<MenuItem>`) get indented via the `.menu .menu` CSS rule.
|
|
32
|
+
* - Pass `small` to make every item smaller, for example in a dense sidebar.
|
|
28
33
|
*
|
|
29
34
|
* @kind component
|
|
30
35
|
* @see https://shelving.cc/ui/Menu
|
|
31
36
|
*/
|
|
32
|
-
export function Menu({ children, className, ...props }: MenuProps): ReactNode {
|
|
37
|
+
export function Menu({ children, small, className, ...props }: MenuProps): ReactNode {
|
|
33
38
|
return (
|
|
34
39
|
<menu
|
|
35
40
|
className={getClass(
|
|
36
41
|
MENU_CLASS, //
|
|
42
|
+
small && MENU_SMALL_CLASS,
|
|
37
43
|
getBlockClass(props),
|
|
38
44
|
className,
|
|
39
45
|
)}
|
|
@@ -54,17 +60,20 @@ export interface MenuItemProps extends ClickableProps, ClassProps {
|
|
|
54
60
|
* - Any additional children form the submenu — only rendered when this item is "proud" (an ancestor of the current page). The caller is responsible for wrapping the submenu in a nested `<Menu>` if it wants the CSS `.menu .menu` descendant rules to apply.
|
|
55
61
|
*/
|
|
56
62
|
readonly children: ReactNode | readonly [ReactNode, ...ReactNode[]];
|
|
63
|
+
/** Make the item smaller: less padding and no minimum height. By default an item is as tall as a `<Button>`, so it is easy to tap. */
|
|
64
|
+
readonly small?: boolean | undefined;
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
/**
|
|
60
68
|
* A `<li>` containing an `<a>` link, plus optional submenu content shown when this item is "proud".
|
|
61
69
|
* - Reads the current page URL from `<Meta>` and computes `active` / `proud` against its own `href`.
|
|
62
70
|
* - Splits `children` into `[label, ...after]`: label goes inside the `<a>`; `after` is rendered as siblings below it, only when proud.
|
|
71
|
+
* - As tall as a `<Button>` by default, so it is easy to tap. Pass `small` for a denser item.
|
|
63
72
|
*
|
|
64
73
|
* @kind component
|
|
65
74
|
* @see https://shelving.cc/ui/MenuItem
|
|
66
75
|
*/
|
|
67
|
-
export function MenuItem({ href, children, className, ...props }: MenuItemProps): ReactNode {
|
|
76
|
+
export function MenuItem({ href, children, small, className, ...props }: MenuItemProps): ReactNode {
|
|
68
77
|
const { url, root } = requireMeta();
|
|
69
78
|
const link = getLink(href, url, root);
|
|
70
79
|
const proud = isURLProud(url, link);
|
|
@@ -77,6 +86,7 @@ export function MenuItem({ href, children, className, ...props }: MenuItemProps)
|
|
|
77
86
|
{...props}
|
|
78
87
|
className={getClass(
|
|
79
88
|
MENU_LINK_CLASS, //
|
|
89
|
+
small && MENU_SMALL_CLASS,
|
|
80
90
|
proud && MENU_PROUD_CLASS,
|
|
81
91
|
active && MENU_ACTIVE_CLASS,
|
|
82
92
|
)}
|
package/ui/menu/MenuItem.md
CHANGED
|
@@ -7,6 +7,7 @@ A single `<li>` link entry inside a `<Menu>`. It reads the current page URL from
|
|
|
7
7
|
- The first child is the link label (rendered inside the `<a>`). Any additional children form the submenu and are rendered only when the item is proud (the current URL starts with the item's `href`). Wrap that submenu in a nested `<Menu>` to get the `.menu .menu` indentation.
|
|
8
8
|
- It forwards all `ClickableProps` — `href`, `onClick`, `disabled`, and so on — to the underlying `<Clickable>`.
|
|
9
9
|
- `active` and `proud` are computed against the URL from `<Router>` / `<Navigation>` context.
|
|
10
|
+
- By default an item is as tall as a `<Button>` or an `<Input>`, so it is easy to tap. Pass `small` for a denser item (the size before this change). Pass `small` to `<Menu>` to make all of its items small.
|
|
10
11
|
|
|
11
12
|
## Usage
|
|
12
13
|
|
|
@@ -25,14 +26,37 @@ import { Menu, MenuItem } from "shelving/ui";
|
|
|
25
26
|
</Menu>
|
|
26
27
|
```
|
|
27
28
|
|
|
29
|
+
### Small items
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { Menu, MenuItem } from "shelving/ui";
|
|
33
|
+
|
|
34
|
+
// One small item.
|
|
35
|
+
<Menu>
|
|
36
|
+
<MenuItem href="/help" small>Help</MenuItem>
|
|
37
|
+
</Menu>
|
|
38
|
+
|
|
39
|
+
// Every item small, including nested menus.
|
|
40
|
+
<Menu small>
|
|
41
|
+
<MenuItem href="/users">Users</MenuItem>
|
|
42
|
+
<MenuItem href="/settings">Settings</MenuItem>
|
|
43
|
+
</Menu>
|
|
44
|
+
```
|
|
45
|
+
|
|
28
46
|
## Styling
|
|
29
47
|
|
|
30
48
|
The item link's hooks (defined in `Menu.module.css`):
|
|
31
49
|
|
|
32
50
|
| Variable | Styles | Default |
|
|
33
51
|
|---|---|---|
|
|
34
|
-
| `--menu-padding` | Link top and bottom padding (one length) | `var(--space-
|
|
35
|
-
| `--menu-indent` | Link left and right padding (one length) | `var(--space-
|
|
52
|
+
| `--menu-padding` | Link top and bottom padding (one length) | `var(--space-small)` |
|
|
53
|
+
| `--menu-indent` | Link left and right padding (one length) | `var(--space-small)` |
|
|
54
|
+
| `--menu-stroke` | Link transparent border width (one length) | `var(--stroke-normal)` |
|
|
55
|
+
| `--menu-icon-size` | Content height used for the minimum height (one length) | `var(--size-icon)` |
|
|
56
|
+
| `--menu-height` | Link minimum height | `--menu-icon-size` + 2 × `--menu-padding` + 2 × `--menu-stroke`, the same as `--button-height` |
|
|
57
|
+
| `--menu-small-padding` | Small link top and bottom padding (one length) | `var(--space-xsmall)` |
|
|
58
|
+
| `--menu-small-indent` | Small link left and right padding (one length) | `var(--space-xsmall)` |
|
|
59
|
+
| `--menu-small-height` | Small link minimum height | `0` |
|
|
36
60
|
| `--menu-radius` | Link corner radius | `var(--radius-xsmall)` |
|
|
37
61
|
| `--menu-focus-border` | Focus outline | `var(--stroke-focus) solid var(--color-focus)` |
|
|
38
62
|
| `--menu-hover-background` | Link fill on hover/focus | `var(--tint-90)` |
|
|
@@ -46,4 +70,4 @@ The item link's hooks (defined in `Menu.module.css`):
|
|
|
46
70
|
|
|
47
71
|
List-level hooks (`--menu-gap`, `--menu-color`, the nested-submenu hooks, etc.) are documented on `<Menu>`.
|
|
48
72
|
|
|
49
|
-
**Global tokens it reads** — the tint ladder `--tint-00` / `--tint-90` / `--tint-100`, plus `--space-xsmall`, `--radius-xsmall`, `--stroke-focus`, `--color-focus`, and `--weight-strong`.
|
|
73
|
+
**Global tokens it reads** — the tint ladder `--tint-00` / `--tint-90` / `--tint-100`, plus `--space-small`, `--space-xsmall`, `--size-icon`, `--radius-xsmall`, `--stroke-normal`, `--stroke-focus`, `--color-focus`, and `--weight-strong`.
|
package/ui/tree/TreeSidebar.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface TreeSidebarProps extends OptionalChildProps {
|
|
|
12
12
|
*
|
|
13
13
|
* - **Middle:** a `<TextInput>` search-as-you-type filter.
|
|
14
14
|
* - **Bottom:** the root's children as a `<TreeMenuMapper>` — swapped for a flat ranked list of results (capped at 20) while the search holds a query.
|
|
15
|
+
* - Both menus are `small`, so the long list of pages stays dense.
|
|
15
16
|
*
|
|
16
17
|
* Reads the flattened tree from the surrounding `<TreeProvider>` (`useTreeMap().get("/")`), so child and result hrefs use each element's stamped canonical `path`. To customise child renderers wrap in `<TreeMenuMapping mapping={…}>` (same context as `<TreeMenu>`).
|
|
17
18
|
*
|
package/ui/tree/TreeSidebar.js
CHANGED
|
@@ -12,6 +12,7 @@ import { matchMenuElement, TreeMenuMapper } from "./TreeMenu.js";
|
|
|
12
12
|
*
|
|
13
13
|
* - **Middle:** a `<TextInput>` search-as-you-type filter.
|
|
14
14
|
* - **Bottom:** the root's children as a `<TreeMenuMapper>` — swapped for a flat ranked list of results (capped at 20) while the search holds a query.
|
|
15
|
+
* - Both menus are `small`, so the long list of pages stays dense.
|
|
15
16
|
*
|
|
16
17
|
* Reads the flattened tree from the surrounding `<TreeProvider>` (`useTreeMap().get("/")`), so child and result hrefs use each element's stamped canonical `path`. To customise child renderers wrap in `<TreeMenuMapping mapping={…}>` (same context as `<TreeMenu>`).
|
|
17
18
|
*
|
|
@@ -24,5 +25,5 @@ export function TreeSidebar({ children }) {
|
|
|
24
25
|
// The flattened root from context — its children (and descendants) already carry their canonical `path` and unique `key`.
|
|
25
26
|
const root = useTreeMap().get("/");
|
|
26
27
|
const results = root && trimmed ? searchTree(root, trimmed, { limit: 20 }) : null;
|
|
27
|
-
return (_jsxs(_Fragment, { children: [_jsx(Menu, { children: _jsx(MenuItem, { href: "/", children: "Home" }) }), children, _jsx(Divider, {}), _jsx(TextInput, { name: "search", title: "Search", placeholder: "Search\u2026", value: query, onValue: v => setQuery(v ?? "") }), _jsx(Divider, {}), _jsx(Menu, { children: results ? (results.map(el => (_jsx(MenuItem, { href: el.props.path ?? "/", children: el.props.title ?? el.props.name }, el.key)))) : (_jsx(TreeMenuMapper, { children: filterElements(root?.props.children, matchMenuElement) })) })] }));
|
|
28
|
+
return (_jsxs(_Fragment, { children: [_jsx(Menu, { small: true, children: _jsx(MenuItem, { href: "/", children: "Home" }) }), children, _jsx(Divider, {}), _jsx(TextInput, { name: "search", title: "Search", placeholder: "Search\u2026", value: query, onValue: v => setQuery(v ?? "") }), _jsx(Divider, {}), _jsx(Menu, { small: true, children: results ? (results.map(el => (_jsx(MenuItem, { href: el.props.path ?? "/", children: el.props.title ?? el.props.name }, el.key)))) : (_jsx(TreeMenuMapper, { children: filterElements(root?.props.children, matchMenuElement) })) })] }));
|
|
28
29
|
}
|
package/ui/tree/TreeSidebar.tsx
CHANGED
|
@@ -20,6 +20,7 @@ export interface TreeSidebarProps extends OptionalChildProps {}
|
|
|
20
20
|
*
|
|
21
21
|
* - **Middle:** a `<TextInput>` search-as-you-type filter.
|
|
22
22
|
* - **Bottom:** the root's children as a `<TreeMenuMapper>` — swapped for a flat ranked list of results (capped at 20) while the search holds a query.
|
|
23
|
+
* - Both menus are `small`, so the long list of pages stays dense.
|
|
23
24
|
*
|
|
24
25
|
* Reads the flattened tree from the surrounding `<TreeProvider>` (`useTreeMap().get("/")`), so child and result hrefs use each element's stamped canonical `path`. To customise child renderers wrap in `<TreeMenuMapping mapping={…}>` (same context as `<TreeMenu>`).
|
|
25
26
|
*
|
|
@@ -36,14 +37,14 @@ export function TreeSidebar({ children }: TreeSidebarProps): ReactNode {
|
|
|
36
37
|
|
|
37
38
|
return (
|
|
38
39
|
<>
|
|
39
|
-
<Menu>
|
|
40
|
+
<Menu small>
|
|
40
41
|
<MenuItem href="/">Home</MenuItem>
|
|
41
42
|
</Menu>
|
|
42
43
|
{children}
|
|
43
44
|
<Divider />
|
|
44
45
|
<TextInput name="search" title="Search" placeholder="Search…" value={query} onValue={v => setQuery(v ?? "")} />
|
|
45
46
|
<Divider />
|
|
46
|
-
<Menu>
|
|
47
|
+
<Menu small>
|
|
47
48
|
{results ? (
|
|
48
49
|
results.map(el => (
|
|
49
50
|
<MenuItem key={el.key} href={el.props.path ?? "/"}>
|