shelving 1.265.0 → 1.267.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.
@@ -3,6 +3,7 @@
3
3
  * - `#` 1-6 hashes, then one or more spaces, then the title.
4
4
  * - `#` must be the first character on the line.
5
5
  * - Markdown's underline syntax is not supported (for simplification).
6
+ * - Each heading gets a `getSlug()` `id` derived from its text, so same-page `#anchor` links resolve to it (e.g. `## React integration` becomes `id="react-integration"`). An all-punctuation heading that slugs to nothing gets no `id`.
6
7
  *
7
8
  * @example new MarkupParser({ rules: [HEADING_RULE] }).parse("# Title")
8
9
  * @see https://shelving.cc/markup/HEADING_RULE
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { getSlug } from "../../util/string.js";
2
3
  import { createMarkupRule } from "../MarkupRule.js";
3
4
  import { createLineRegExp, LINE_CONTENT_REGEXP, LINE_SPACE_REGEXP } from "../util/regexp.js";
4
5
  /**
@@ -6,6 +7,7 @@ import { createLineRegExp, LINE_CONTENT_REGEXP, LINE_SPACE_REGEXP } from "../uti
6
7
  * - `#` 1-6 hashes, then one or more spaces, then the title.
7
8
  * - `#` must be the first character on the line.
8
9
  * - Markdown's underline syntax is not supported (for simplification).
10
+ * - Each heading gets a `getSlug()` `id` derived from its text, so same-page `#anchor` links resolve to it (e.g. `## React integration` becomes `id="react-integration"`). An all-punctuation heading that slugs to nothing gets no `id`.
9
11
  *
10
12
  * @example new MarkupParser({ rules: [HEADING_RULE] }).parse("# Title")
11
13
  * @see https://shelving.cc/markup/HEADING_RULE
@@ -13,5 +15,7 @@ import { createLineRegExp, LINE_CONTENT_REGEXP, LINE_SPACE_REGEXP } from "../uti
13
15
  export const HEADING_RULE = createMarkupRule(createLineRegExp(`(?<prefix>#{1,6})(?:${LINE_SPACE_REGEXP}+(?<heading>${LINE_CONTENT_REGEXP}))?`), (key, { prefix, heading = "" }, parser) => {
14
16
  // The hash count picks the heading level; cast the dynamic tag to the known `h1`–`h6` set.
15
17
  const Heading = `h${prefix.length}`;
16
- return _jsx(Heading, { children: parser.parse(heading.trim(), "inline") }, key);
18
+ const title = heading.trim();
19
+ // Slug the raw title (before inline parsing) for the `id`, so `#anchor` fragment links land on the heading.
20
+ return (_jsx(Heading, { id: getSlug(title), children: parser.parse(title, "inline") }, key));
17
21
  }, ["block"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shelving",
3
- "version": "1.265.0",
3
+ "version": "1.267.0",
4
4
  "author": "Dave Houlbrooke <dave@shax.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,8 +33,9 @@ Layouts compose naturally as `<Router>` route values — wrap a group of routes
33
33
  | `--centered-layout-width` | Width of the centred column (capped at 100%) | `var(--width-narrow)` |
34
34
  | `--centered-layout-padding` | Block (top/bottom) padding of the scroll area | `var(--space-normal)` |
35
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 | Unset — the `body` default from `Typography.module.css` shows |
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) |
37
38
 
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.
39
40
 
40
- **Global tokens it reads** — `--width-narrow` and `--space-normal`.
41
+ **Global tokens it reads** — `--width-narrow`, `--space-normal`, `--tint-100`, and `--tint-00`.
@@ -1,5 +1,6 @@
1
1
  @import "../style/layers.css";
2
2
  @import "../style/Space.module.css";
3
+ @import "../style/Tint.module.css";
3
4
  @import "../style/Width.module.css";
4
5
 
5
6
  @layer components {
@@ -34,8 +35,9 @@
34
35
  position: fixed;
35
36
  inset: 0;
36
37
 
37
- /* Deliberately no fallback: when the hook is unset this declaration fails and the body default from Typography.module.css shows. */
38
- background: var(--centered-layout-background);
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));
39
41
  }
40
42
 
41
43
  .main {
@@ -48,11 +48,12 @@ useEffect(useSafeKeyboardArea, []);
48
48
  | Variable | Styles | Default |
49
49
  |---|---|---|
50
50
  | `--sidebar-layout-width` | Width of the side column (and drawer) | `17.5rem` |
51
- | `--sidebar-layout-background` | Page background while the layout is mounted | Unset the `body` default from `Typography.module.css` shows |
52
- | `--sidebar-layout-sidebar-background` | Sidebar column fill | Unset the page background shows |
53
- | `--sidebar-layout-content-background` | Main content column fill | Unset the page background shows |
51
+ | `--sidebar-layout-background` | Page background while the layout is mounted (also fills the content column) | `var(--tint-100)` (white) |
52
+ | `--sidebar-layout-color` | Text colour for the layout (set on `body`, inherited by the content column) | `var(--tint-00)` (black) |
53
+ | `--sidebar-layout-sidebar-background` | Sidebar column fill | `var(--tint-90)` (one shade darker than the page) |
54
+ | `--sidebar-layout-sidebar-color` | Sidebar column text colour | `var(--tint-00)` (black) |
54
55
  | `--sidebar-layout-border` | Divider between sidebar and content | `var(--stroke-normal) solid var(--tint-80)` |
55
56
 
56
57
  The sidebar and content columns own their own scroll behaviour directly (this layout no longer composes a shared `.layout` class). `useSafeKeyboardArea()` still writes `--layout-inset-bottom` for layouts that pad to the safe area.
57
58
 
58
- **Global tokens it reads** — `--tint-80`, plus `--space-normal`, `--stroke-normal`, `--duration-normal`, and `--color-shadow`.
59
+ **Global tokens it reads** — `--tint-00` / `--tint-80` / `--tint-90` / `--tint-100`, plus `--space-normal`, `--stroke-normal`, `--duration-normal`, and `--color-shadow`.
@@ -50,8 +50,10 @@
50
50
  inset: 0;
51
51
 
52
52
  /* Style */
53
- /* Deliberately no fallback: when the hook is unset this declaration fails and the body default from Typography.module.css shows. */
54
- background: var(--sidebar-layout-background);
53
+ /* Page background + text colour; fall back to the themed page defaults (--tint-100 / --tint-00) when the hooks are unset.
54
+ * `color` inherits, so this one rule sets the text colour for the whole layout (including `.content`). */
55
+ background: var(--sidebar-layout-background, var(--tint-100));
56
+ color: var(--sidebar-layout-color, var(--tint-00));
55
57
  }
56
58
 
57
59
  .main {
@@ -75,8 +77,10 @@
75
77
  padding: var(--space-normal);
76
78
 
77
79
  /* Style */
78
- /* Deliberately no fallback: when the hook is unset this declaration fails and the page background shows. */
79
- background: var(--sidebar-layout-sidebar-background);
80
+ /* Sidebar fill + text colour; fall back to the themed defaults (--tint-90 / --tint-00) when the hooks are unset.
81
+ * The sidebar defaults one shade darker than the page (--tint-90 vs --tint-100) so it reads as a distinct column. */
82
+ background: var(--sidebar-layout-sidebar-background, var(--tint-90));
83
+ color: var(--sidebar-layout-sidebar-color, var(--tint-00));
80
84
  }
81
85
 
82
86
  .content {
@@ -93,8 +97,8 @@
93
97
  scroll-behavior: smooth;
94
98
 
95
99
  /* Style */
96
- /* Deliberately no fallback: when the hook is unset this declaration fails and the page background shows. */
97
- background: var(--sidebar-layout-content-background);
100
+ /* Shares the page background hook; text colour is inherited from the `body` rule above (no `color` here on purpose). */
101
+ background: var(--sidebar-layout-background, var(--tint-100));
98
102
  }
99
103
 
100
104
  /* Wrapper for the menu toggle button — hidden on wide viewports, shown on narrow ones (see media query). */