shelving 1.261.0 → 1.262.1

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.
Files changed (51) hide show
  1. package/package.json +1 -1
  2. package/react/createAPIContext.d.ts +5 -8
  3. package/react/createAPIContext.js +0 -2
  4. package/ui/README.md +1 -1
  5. package/ui/block/Definitions.d.ts +1 -2
  6. package/ui/block/Definitions.tsx +1 -2
  7. package/ui/form/Button.d.ts +1 -2
  8. package/ui/form/Button.js +1 -2
  9. package/ui/form/Button.tsx +1 -3
  10. package/ui/inline/Code.d.ts +1 -2
  11. package/ui/inline/Code.module.css +1 -1
  12. package/ui/inline/Code.tsx +1 -2
  13. package/ui/inline/Deleted.d.ts +1 -2
  14. package/ui/inline/Deleted.js +1 -2
  15. package/ui/inline/Deleted.tsx +1 -3
  16. package/ui/inline/Inserted.d.ts +1 -2
  17. package/ui/inline/Inserted.js +1 -2
  18. package/ui/inline/Inserted.tsx +1 -3
  19. package/ui/inline/Link.d.ts +1 -2
  20. package/ui/inline/Link.js +1 -2
  21. package/ui/inline/Link.tsx +1 -3
  22. package/ui/inline/Mark.module.css +2 -2
  23. package/ui/inline/Span.d.ts +19 -0
  24. package/ui/inline/Span.js +13 -0
  25. package/ui/inline/Span.md +33 -0
  26. package/ui/inline/Span.tsx +22 -0
  27. package/ui/inline/index.d.ts +1 -0
  28. package/ui/inline/index.js +1 -0
  29. package/ui/inline/index.ts +1 -0
  30. package/ui/misc/Catcher.d.ts +9 -30
  31. package/ui/misc/Catcher.js +11 -10
  32. package/ui/misc/Catcher.tsx +13 -33
  33. package/ui/misc/Icon.d.ts +1 -1
  34. package/ui/misc/Icon.js +1 -2
  35. package/ui/misc/Icon.tsx +2 -3
  36. package/ui/misc/Loader.d.ts +31 -0
  37. package/ui/misc/Loader.js +29 -0
  38. package/ui/misc/Loader.tsx +49 -0
  39. package/ui/misc/Tag.d.ts +1 -2
  40. package/ui/misc/Tag.js +1 -2
  41. package/ui/misc/Tag.tsx +1 -3
  42. package/ui/misc/index.d.ts +1 -0
  43. package/ui/misc/index.js +1 -0
  44. package/ui/misc/index.tsx +1 -0
  45. package/ui/style/Block.d.ts +1 -2
  46. package/ui/style/Block.js +1 -2
  47. package/ui/style/Block.tsx +1 -3
  48. package/ui/style/Typography.d.ts +9 -5
  49. package/ui/style/Typography.js +6 -4
  50. package/ui/style/Typography.tsx +21 -14
  51. package/ui/style/getTypographyClass.md +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shelving",
3
- "version": "1.261.0",
3
+ "version": "1.262.1",
4
4
  "author": "Dave Houlbrooke <dave@shax.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,21 +1,20 @@
1
- import { type ReactElement, type ReactNode } from "react";
1
+ import { type ReactElement } from "react";
2
2
  import type { Endpoint } from "../api/endpoint/Endpoint.js";
3
3
  import type { APIProvider } from "../api/provider/APIProvider.js";
4
4
  import type { EndpointStore } from "../api/store/EndpointStore.js";
5
+ import type { ChildProps } from "../ui/index.js";
5
6
  import type { Nullish } from "../util/null.js";
6
7
  /**
7
- * Bundle of hooks and a provider component returned by `createAPIContext()`.
8
+ * Bundle of hooks and a provider component returned by `createAPIContext()`
8
9
  *
9
10
  * @see https://shelving.cc/react/APIContext
10
11
  */
11
12
  export interface APIContext<P, R> {
12
- /** Get an `EndpointStore` for the specified endpoint/payload in the current `APIProvider` context. */
13
+ /** React hook to return an `EndpointStore` for the specified endpoint/payload in the current `APIProvider` context. */
13
14
  useAPI<PP extends P, RR extends R>(this: void, endpoint: Endpoint<PP, RR>, payload: PP): EndpointStore<PP, RR>;
14
15
  useAPI<PP extends P, RR extends R>(this: void, endpoint: Nullish<Endpoint<PP, RR>>, payload: PP): EndpointStore<PP, RR> | undefined;
15
16
  /** The `<APIContext>` wrapper to give your React components access to this API provider. */
16
- readonly APIContext: ({ children }: {
17
- children: ReactNode;
18
- }) => ReactElement;
17
+ readonly APIContext: (props: ChildProps) => ReactElement;
19
18
  }
20
19
  /**
21
20
  * Create an API context.
@@ -24,8 +23,6 @@ export interface APIContext<P, R> {
24
23
  *
25
24
  * @param provider `APIProvider` the created context resolves endpoint stores against.
26
25
  *
27
- * @todo Use and integreate our `EndpointCache` functionality and use it in this.
28
- *
29
26
  * @see https://shelving.cc/react/createAPIContext
30
27
  */
31
28
  export declare function createAPIContext<P, R>(provider: APIProvider<P, R>): APIContext<P, R>;
@@ -11,8 +11,6 @@ import { useStore } from "./useStore.js";
11
11
  *
12
12
  * @param provider `APIProvider` the created context resolves endpoint stores against.
13
13
  *
14
- * @todo Use and integreate our `EndpointCache` functionality and use it in this.
15
- *
16
14
  * @see https://shelving.cc/react/createAPIContext
17
15
  */
18
16
  export function createAPIContext(provider) {
package/ui/README.md CHANGED
@@ -25,7 +25,7 @@ The styling system lives in `style/` and has four moving parts: design tokens, t
25
25
 
26
26
  **Cascade layers.** Styles are ordered by `@layer`, lowest to highest priority: `defaults` (`:root` tokens, the tint ladder, body baseline) → `components` (the bulk of the CSS: `.card`, `.button`, …) → `variants` (cross-cutting opt-in modifiers, which always beat components) → `overrides` (top-priority structural fixes like `:first-child` / `:last-child` margin collapses). Unlayered rules beat all layered rules, so a theme should set tokens at `:root` or wrap its rules in `@layer`.
27
27
 
28
- **Styling props.** The cross-cutting visual options are props, each backed by a helper in `style/` that maps the prop to a class. Colour and status move the tint anchor — `getColorClass()` and `getStatusClass()`; font size, weight, family, and case, plus text alignment, tint, and wrapping, all come from `getTypographyClass()`; spacing, block-padding, inline-padding ("indent"), and gap from `getSpaceClass()`, `getPaddingClass()`, `getIndentClass()`, and `getGapClass()`; width constraints from `getWidthClass()`; flex layout from `getFlexClass()`; and opt-in scrolling from `getScrollClass()`. Each helper's page lists its exact prop values and what they set. A component opts into the props it wants by extending the matching `*Props` interfaces and composing the `getXxxClass(props)` calls.
28
+ **Styling props.** The cross-cutting visual options are props, each backed by a helper in `style/` that maps the prop to a class. Colour and status move the tint anchor — `getColorClass()` and `getStatusClass()`; font size, weight, family, and case, plus text alignment, tint, and wrapping, all come from `getTypographyClass()`, which extends `ColorVariants` and composes `getColorClass()` so every typographic element also accepts `color` (use `getColorClass()` directly only for colour-without-typography, e.g. `<Icon>`); spacing, block-padding, inline-padding ("indent"), and gap from `getSpaceClass()`, `getPaddingClass()`, `getIndentClass()`, and `getGapClass()`; width constraints from `getWidthClass()`; flex layout from `getFlexClass()`; and opt-in scrolling from `getScrollClass()`. Each helper's page lists its exact prop values and what they set. A component opts into the props it wants by extending the matching `*Props` interfaces and composing the `getXxxClass(props)` calls.
29
29
 
30
30
  Each painting component also exposes its own theme hooks — a single tint hook (`--card-tint`) to recolour the whole component, plus per-property hooks (`--card-background`, `--card-radius`, …) for surgical overrides. Those are documented in each component's own **Styling** section (see `<Card>` for the precedent).
31
31
 
@@ -1,5 +1,4 @@
1
1
  import type { ReactElement } from "react";
2
- import type { ColorVariants } from "../style/Color.js";
3
2
  import type { GapVariants } from "../style/Gap.js";
4
3
  import type { SpaceVariants } from "../style/Space.js";
5
4
  import type { TypographyVariants } from "../style/Typography.js";
@@ -9,7 +8,7 @@ import type { OptionalChildProps } from "../util/props.js";
9
8
  *
10
9
  * @see https://shelving.cc/ui/DefinitionsProps
11
10
  */
12
- export interface DefinitionsProps extends ColorVariants, GapVariants, SpaceVariants, TypographyVariants, OptionalChildProps {
11
+ export interface DefinitionsProps extends GapVariants, SpaceVariants, TypographyVariants, OptionalChildProps {
13
12
  }
14
13
  /**
15
14
  * Description list — a sequence of term/value pairs rendered as a `<dl>`.
@@ -1,6 +1,5 @@
1
1
  import type { ReactElement } from "react";
2
2
  import { getBlockClass } from "../style/Block.js";
3
- import type { ColorVariants } from "../style/Color.js";
4
3
  import type { GapVariants } from "../style/Gap.js";
5
4
  import type { SpaceVariants } from "../style/Space.js";
6
5
  import type { TypographyVariants } from "../style/Typography.js";
@@ -15,7 +14,7 @@ const DEFINITIONS_CLASS = getModuleClass(DEFINITIONS_CSS, "definitions");
15
14
  *
16
15
  * @see https://shelving.cc/ui/DefinitionsProps
17
16
  */
18
- export interface DefinitionsProps extends ColorVariants, GapVariants, SpaceVariants, TypographyVariants, OptionalChildProps {}
17
+ export interface DefinitionsProps extends GapVariants, SpaceVariants, TypographyVariants, OptionalChildProps {}
19
18
 
20
19
  /**
21
20
  * Description list — a sequence of term/value pairs rendered as a `<dl>`.
@@ -1,5 +1,4 @@
1
1
  import type { ReactElement } from "react";
2
- import { type ColorVariants } from "../style/Color.js";
3
2
  import { type FlexVariants } from "../style/Flex.js";
4
3
  import { type StatusVariants } from "../style/Status.js";
5
4
  import { type TypographyVariants } from "../style/Typography.js";
@@ -9,7 +8,7 @@ import { type ClickableProps } from "./Clickable.js";
9
8
  *
10
9
  * @see https://shelving.cc/ui/ButtonVariants
11
10
  */
12
- export interface ButtonVariants extends FlexVariants, ColorVariants, StatusVariants, TypographyVariants {
11
+ export interface ButtonVariants extends FlexVariants, StatusVariants, TypographyVariants {
13
12
  /** This is the default button in a form and should be displayed stronger. */
14
13
  strong?: boolean | undefined;
15
14
  /** Add plain styling (background only appears on hover or focus). */
package/ui/form/Button.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getColorClass } from "../style/Color.js";
3
2
  import { getFlexClass } from "../style/Flex.js";
4
3
  import { getStatusClass } from "../style/Status.js";
5
4
  import { getTypographyClass } from "../style/Typography.js";
@@ -14,7 +13,7 @@ import { Clickable } from "./Clickable.js";
14
13
  * @see https://shelving.cc/ui/getButtonClass
15
14
  */
16
15
  export function getButtonClass(variants) {
17
- return getClass(getModuleClass(BUTTON_CSS, "button", variants), getFlexClass(variants), getStatusClass(variants), getColorClass(variants), getTypographyClass(variants));
16
+ return getClass(getModuleClass(BUTTON_CSS, "button", variants), getFlexClass(variants), getStatusClass(variants), getTypographyClass(variants));
18
17
  }
19
18
  /**
20
19
  * Render either a `<button>` or an `<a href="">` styled as a button, based on whether an `onClick` or `href` prop is provided.
@@ -1,5 +1,4 @@
1
1
  import type { ReactElement } from "react";
2
- import { type ColorVariants, getColorClass } from "../style/Color.js";
3
2
  import { type FlexVariants, getFlexClass } from "../style/Flex.js";
4
3
  import { getStatusClass, type StatusVariants } from "../style/Status.js";
5
4
  import { getTypographyClass, type TypographyVariants } from "../style/Typography.js";
@@ -12,7 +11,7 @@ import { Clickable, type ClickableProps } from "./Clickable.js";
12
11
  *
13
12
  * @see https://shelving.cc/ui/ButtonVariants
14
13
  */
15
- export interface ButtonVariants extends FlexVariants, ColorVariants, StatusVariants, TypographyVariants {
14
+ export interface ButtonVariants extends FlexVariants, StatusVariants, TypographyVariants {
16
15
  /** This is the default button in a form and should be displayed stronger. */
17
16
  strong?: boolean | undefined;
18
17
  /** Add plain styling (background only appears on hover or focus). */
@@ -37,7 +36,6 @@ export function getButtonClass(variants: ButtonVariants): string {
37
36
  getModuleClass(BUTTON_CSS, "button", variants),
38
37
  getFlexClass(variants),
39
38
  getStatusClass(variants),
40
- getColorClass(variants),
41
39
  getTypographyClass(variants),
42
40
  );
43
41
  }
@@ -1,5 +1,4 @@
1
1
  import type { ReactElement } from "react";
2
- import type { ColorVariants } from "../style/Color.js";
3
2
  import { type TypographyVariants } from "../style/Typography.js";
4
3
  import type { OptionalChildProps } from "../util/index.js";
5
4
  /**
@@ -7,7 +6,7 @@ import type { OptionalChildProps } from "../util/index.js";
7
6
  *
8
7
  * @see https://shelving.cc/ui/CodeProps
9
8
  */
10
- export interface CodeProps extends ColorVariants, TypographyVariants, OptionalChildProps {
9
+ export interface CodeProps extends TypographyVariants, OptionalChildProps {
11
10
  plain?: boolean | undefined;
12
11
  }
13
12
  /**
@@ -19,9 +19,9 @@
19
19
  .prose :is(code, kbd, samp, var):not(pre *) {
20
20
  /* Box */
21
21
  display: inline-block;
22
- vertical-align: text-bottom;
23
22
  padding-inline: var(--code-padding, var(--space-xxsmall));
24
23
  border-radius: var(--code-radius, var(--radius-xxsmall));
24
+ vertical-align: baseline;
25
25
 
26
26
  /* Style */
27
27
  background: var(--code-background, var(--tint-90));
@@ -1,5 +1,4 @@
1
1
  import type { ReactElement } from "react";
2
- import type { ColorVariants } from "../style/Color.js";
3
2
  import { getTypographyClass, type TypographyVariants } from "../style/Typography.js";
4
3
  import { getClass, getModuleClass } from "../util/css.js";
5
4
  import type { OptionalChildProps } from "../util/index.js";
@@ -14,7 +13,7 @@ const CODE_PLAIN_CLASS = getModuleClass(CODE_CSS, "plain");
14
13
  *
15
14
  * @see https://shelving.cc/ui/CodeProps
16
15
  */
17
- export interface CodeProps extends ColorVariants, TypographyVariants, OptionalChildProps {
16
+ export interface CodeProps extends TypographyVariants, OptionalChildProps {
18
17
  plain?: boolean | undefined;
19
18
  }
20
19
 
@@ -1,5 +1,4 @@
1
1
  import type { ReactElement } from "react";
2
- import { type ColorVariants } from "../style/Color.js";
3
2
  import { type TypographyVariants } from "../style/Typography.js";
4
3
  import type { OptionalChildProps } from "../util/props.js";
5
4
  /**
@@ -7,7 +6,7 @@ import type { OptionalChildProps } from "../util/props.js";
7
6
  *
8
7
  * @see https://shelving.cc/ui/DeletedProps
9
8
  */
10
- export interface DeletedProps extends OptionalChildProps, ColorVariants, TypographyVariants {
9
+ export interface DeletedProps extends OptionalChildProps, TypographyVariants {
11
10
  }
12
11
  /**
13
12
  * Deleted text — renders a `<del>` element to mark content removed from a document.
@@ -1,5 +1,4 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getColorClass } from "../style/Color.js";
3
2
  import { getTypographyClass } from "../style/Typography.js";
4
3
  import { getClass, getModuleClass } from "../util/css.js";
5
4
  import DELETED_CSS from "./Deleted.module.css";
@@ -13,5 +12,5 @@ const DELETED_CLASS = getModuleClass(DELETED_CSS, "deleted");
13
12
  */
14
13
  export function Deleted({ children, ...props }) {
15
14
  return (_jsx("del", { className: getClass(DELETED_CLASS, //
16
- getColorClass(props), getTypographyClass(props)), children: children }));
15
+ getTypographyClass(props)), children: children }));
17
16
  }
@@ -1,5 +1,4 @@
1
1
  import type { ReactElement } from "react";
2
- import { type ColorVariants, getColorClass } from "../style/Color.js";
3
2
  import { getTypographyClass, type TypographyVariants } from "../style/Typography.js";
4
3
  import { getClass, getModuleClass } from "../util/css.js";
5
4
  import type { OptionalChildProps } from "../util/props.js";
@@ -12,7 +11,7 @@ const DELETED_CLASS = getModuleClass(DELETED_CSS, "deleted");
12
11
  *
13
12
  * @see https://shelving.cc/ui/DeletedProps
14
13
  */
15
- export interface DeletedProps extends OptionalChildProps, ColorVariants, TypographyVariants {}
14
+ export interface DeletedProps extends OptionalChildProps, TypographyVariants {}
16
15
 
17
16
  /**
18
17
  * Deleted text — renders a `<del>` element to mark content removed from a document.
@@ -26,7 +25,6 @@ export function Deleted({ children, ...props }: DeletedProps): ReactElement {
26
25
  <del
27
26
  className={getClass(
28
27
  DELETED_CLASS, //
29
- getColorClass(props),
30
28
  getTypographyClass(props),
31
29
  )}
32
30
  >
@@ -1,5 +1,4 @@
1
1
  import type { ReactElement } from "react";
2
- import { type ColorVariants } from "../style/Color.js";
3
2
  import { type TypographyVariants } from "../style/Typography.js";
4
3
  import type { OptionalChildProps } from "../util/props.js";
5
4
  /**
@@ -7,7 +6,7 @@ import type { OptionalChildProps } from "../util/props.js";
7
6
  *
8
7
  * @see https://shelving.cc/ui/InsertedProps
9
8
  */
10
- export interface InsertedProps extends OptionalChildProps, ColorVariants, TypographyVariants {
9
+ export interface InsertedProps extends OptionalChildProps, TypographyVariants {
11
10
  }
12
11
  /**
13
12
  * Inserted text — renders an `<ins>` element to mark content added to a document.
@@ -1,5 +1,4 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getColorClass } from "../style/Color.js";
3
2
  import { getTypographyClass } from "../style/Typography.js";
4
3
  import { getClass, getModuleClass } from "../util/css.js";
5
4
  import INSERTED_CSS from "./Inserted.module.css";
@@ -13,5 +12,5 @@ const INSERTED_CLASS = getModuleClass(INSERTED_CSS, "inserted");
13
12
  */
14
13
  export function Inserted({ children, ...props }) {
15
14
  return (_jsx("ins", { className: getClass(INSERTED_CLASS, //
16
- getColorClass(props), getTypographyClass(props)), children: children }));
15
+ getTypographyClass(props)), children: children }));
17
16
  }
@@ -1,5 +1,4 @@
1
1
  import type { ReactElement } from "react";
2
- import { type ColorVariants, getColorClass } from "../style/Color.js";
3
2
  import { getTypographyClass, type TypographyVariants } from "../style/Typography.js";
4
3
  import { getClass, getModuleClass } from "../util/css.js";
5
4
  import type { OptionalChildProps } from "../util/props.js";
@@ -12,7 +11,7 @@ const INSERTED_CLASS = getModuleClass(INSERTED_CSS, "inserted");
12
11
  *
13
12
  * @see https://shelving.cc/ui/InsertedProps
14
13
  */
15
- export interface InsertedProps extends OptionalChildProps, ColorVariants, TypographyVariants {}
14
+ export interface InsertedProps extends OptionalChildProps, TypographyVariants {}
16
15
 
17
16
  /**
18
17
  * Inserted text — renders an `<ins>` element to mark content added to a document.
@@ -26,7 +25,6 @@ export function Inserted({ children, ...props }: InsertedProps): ReactElement {
26
25
  <ins
27
26
  className={getClass(
28
27
  INSERTED_CLASS, //
29
- getColorClass(props),
30
28
  getTypographyClass(props),
31
29
  )}
32
30
  >
@@ -1,13 +1,12 @@
1
1
  import type { ReactElement } from "react";
2
2
  import { type ClickableProps } from "../form/Clickable.js";
3
- import { type ColorVariants } from "../style/Color.js";
4
3
  import { type TypographyVariants } from "../style/Typography.js";
5
4
  /**
6
5
  * Props for `Link` — `ClickableProps` (`href` for navigation or `onClick` for actions) plus colour and typography variants.
7
6
  *
8
7
  * @see https://shelving.cc/ui/LinkProps
9
8
  */
10
- export interface LinkProps extends ClickableProps, ColorVariants, TypographyVariants {
9
+ export interface LinkProps extends ClickableProps, TypographyVariants {
11
10
  }
12
11
  /**
13
12
  * Inline link — delegates to `<Clickable>`, rendering an `<a>` (when `href` is set) or `<button>` (when `onClick` is set).
package/ui/inline/Link.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Clickable } from "../form/Clickable.js";
3
- import { getColorClass } from "../style/Color.js";
4
3
  import { getTypographyClass } from "../style/Typography.js";
5
4
  import { getClass, getModuleClass } from "../util/css.js";
6
5
  import LINK_CSS from "./Link.module.css";
@@ -13,5 +12,5 @@ const LINK_CLASS = getModuleClass(LINK_CSS, "link");
13
12
  */
14
13
  export function Link(props) {
15
14
  return (_jsx(Clickable, { ...props, className: getClass(LINK_CLASS, //
16
- getColorClass(props), getTypographyClass(props)) }));
15
+ getTypographyClass(props)) }));
17
16
  }
@@ -1,6 +1,5 @@
1
1
  import type { ReactElement } from "react";
2
2
  import { Clickable, type ClickableProps } from "../form/Clickable.js";
3
- import { type ColorVariants, getColorClass } from "../style/Color.js";
4
3
  import { getTypographyClass, type TypographyVariants } from "../style/Typography.js";
5
4
  import { getClass, getModuleClass } from "../util/css.js";
6
5
  import LINK_CSS from "./Link.module.css";
@@ -12,7 +11,7 @@ const LINK_CLASS = getModuleClass(LINK_CSS, "link");
12
11
  *
13
12
  * @see https://shelving.cc/ui/LinkProps
14
13
  */
15
- export interface LinkProps extends ClickableProps, ColorVariants, TypographyVariants {}
14
+ export interface LinkProps extends ClickableProps, TypographyVariants {}
16
15
 
17
16
  /**
18
17
  * Inline link — delegates to `<Clickable>`, rendering an `<a>` (when `href` is set) or `<button>` (when `onClick` is set).
@@ -26,7 +25,6 @@ export function Link(props: LinkProps): ReactElement {
26
25
  {...props}
27
26
  className={getClass(
28
27
  LINK_CLASS, //
29
- getColorClass(props),
30
28
  getTypographyClass(props),
31
29
  )}
32
30
  />
@@ -12,10 +12,10 @@
12
12
  display: inline-block;
13
13
  padding-inline: var(--mark-padding, var(--space-xxsmall));
14
14
  border-radius: var(--mark-radius, var(--radius-xxsmall));
15
- vertical-align: text-bottom;
15
+ vertical-align: baseline;
16
16
 
17
17
  /* Style */
18
- background-color: var(--mark-background, var(--tint-50));
18
+ background: var(--mark-background, var(--tint-80));
19
19
  color: var(--mark-color, var(--tint-00));
20
20
 
21
21
  /* Text */
@@ -0,0 +1,19 @@
1
+ import type { ReactElement } from "react";
2
+ import { type TypographyVariants } from "../style/Typography.js";
3
+ import type { OptionalChildProps } from "../util/props.js";
4
+ /**
5
+ * Props for `Span` — colour and typography variants, plus optional `children`.
6
+ *
7
+ * @see https://shelving.cc/ui/SpanProps
8
+ */
9
+ export interface SpanProps extends OptionalChildProps, TypographyVariants {
10
+ }
11
+ /**
12
+ * Styled inline text — renders a `<span>` carrying only the colour and typography variant classes, with no styling of its own.
13
+ * - Reach for it to apply variants (`size`, `weight`, `tint`, `color`, …) to a run of text that has no semantic meaning of its own.
14
+ *
15
+ * @kind component
16
+ * @example <Span weight="strong" tint="30">label</Span>
17
+ * @see https://shelving.cc/ui/Span
18
+ */
19
+ export declare function Span({ children, ...props }: SpanProps): ReactElement;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { getTypographyClass } from "../style/Typography.js";
3
+ /**
4
+ * Styled inline text — renders a `<span>` carrying only the colour and typography variant classes, with no styling of its own.
5
+ * - Reach for it to apply variants (`size`, `weight`, `tint`, `color`, …) to a run of text that has no semantic meaning of its own.
6
+ *
7
+ * @kind component
8
+ * @example <Span weight="strong" tint="30">label</Span>
9
+ * @see https://shelving.cc/ui/Span
10
+ */
11
+ export function Span({ children, ...props }) {
12
+ return _jsx("span", { className: getTypographyClass(props), children: children });
13
+ }
@@ -0,0 +1,33 @@
1
+ # Span
2
+
3
+ Styled inline text — renders a `<span>` element that carries only the colour and typography variant classes you pass it, with no styling of its own. Reach for it when you need to apply variants to a run of text that has no semantic meaning, the inline counterpart to a styled `<div>`.
4
+
5
+ **Things to know:**
6
+
7
+ - It is purely presentational: use `<Strong>` for importance, `<Emphasis>` for stress emphasis, `<Mark>` for highlighting, and `<Small>` for fine print — `Span` is for everything that is _only_ a visual tweak.
8
+ - With no props it is an inert wrapper — it renders a bare `<span>` and changes nothing.
9
+ - It accepts the full [typography variants](/ui/TypographyVariants) (`size`, `weight`, `font`, `case`, `tint`, `left` / `center` / `right`, `wrap` / `nowrap`) and the [colour variant](/ui/ColorVariants) (`color`).
10
+ - `color` sets the [tint ladder](/ui/TINT_CLASS) for the span and its descendants; pair it with `tint` to actually paint the span's own text from a ladder step (e.g. `color="purple" tint="40"`).
11
+
12
+ ## Usage
13
+
14
+ ### Applying typography variants
15
+
16
+ ```tsx
17
+ import { Span } from "shelving/ui";
18
+
19
+ <p>Total <Span weight="strong">$35.00</Span> due today.</p>
20
+ <p><Span case="upper" size="xsmall">New</Span></p>
21
+ ```
22
+
23
+ ### Colouring a run of text
24
+
25
+ ```tsx
26
+ import { Span } from "shelving/ui";
27
+
28
+ <Span color="purple" tint="40">on-brand accent</Span>
29
+ ```
30
+
31
+ ## Styling
32
+
33
+ `Span` declares no CSS of its own — there are no theming hooks. All appearance comes from the colour and typography variant props, which apply shared variant classes from the design system.
@@ -0,0 +1,22 @@
1
+ import type { ReactElement } from "react";
2
+ import { getTypographyClass, type TypographyVariants } from "../style/Typography.js";
3
+ import type { OptionalChildProps } from "../util/props.js";
4
+
5
+ /**
6
+ * Props for `Span` — colour and typography variants, plus optional `children`.
7
+ *
8
+ * @see https://shelving.cc/ui/SpanProps
9
+ */
10
+ export interface SpanProps extends OptionalChildProps, TypographyVariants {}
11
+
12
+ /**
13
+ * Styled inline text — renders a `<span>` carrying only the colour and typography variant classes, with no styling of its own.
14
+ * - Reach for it to apply variants (`size`, `weight`, `tint`, `color`, …) to a run of text that has no semantic meaning of its own.
15
+ *
16
+ * @kind component
17
+ * @example <Span weight="strong" tint="30">label</Span>
18
+ * @see https://shelving.cc/ui/Span
19
+ */
20
+ export function Span({ children, ...props }: SpanProps): ReactElement {
21
+ return <span className={getTypographyClass(props)}>{children}</span>;
22
+ }
@@ -5,6 +5,7 @@ export * from "./Inserted.js";
5
5
  export * from "./Link.js";
6
6
  export * from "./Mark.js";
7
7
  export * from "./Small.js";
8
+ export * from "./Span.js";
8
9
  export * from "./Strong.js";
9
10
  export * from "./Subscript.js";
10
11
  export * from "./Superscript.js";
@@ -5,6 +5,7 @@ export * from "./Inserted.js";
5
5
  export * from "./Link.js";
6
6
  export * from "./Mark.js";
7
7
  export * from "./Small.js";
8
+ export * from "./Span.js";
8
9
  export * from "./Strong.js";
9
10
  export * from "./Subscript.js";
10
11
  export * from "./Superscript.js";
@@ -5,6 +5,7 @@ export * from "./Inserted.js";
5
5
  export * from "./Link.js";
6
6
  export * from "./Mark.js";
7
7
  export * from "./Small.js";
8
+ export * from "./Span.js";
8
9
  export * from "./Strong.js";
9
10
  export * from "./Subscript.js";
10
11
  export * from "./Superscript.js";
@@ -22,9 +22,9 @@ export declare function RetryButton({ children, ...props }: RetryButtonProps): R
22
22
  /**
23
23
  * Props for a component that renders a caught error `reason`.
24
24
  *
25
- * @see https://shelving.cc/ui/ErrorComponentProps
25
+ * @see https://shelving.cc/ui/ErrorProps
26
26
  */
27
- export interface ErrorComponentProps {
27
+ export interface ErrorProps {
28
28
  reason: unknown;
29
29
  }
30
30
  /**
@@ -34,7 +34,7 @@ export interface ErrorComponentProps {
34
34
  */
35
35
  export interface CatcherProps extends ChildProps {
36
36
  /** Component to render an error (defaults to `<ErrorNotice />`) */
37
- as: (props: ErrorComponentProps) => ReactElement;
37
+ as: (props: ErrorProps) => ReactElement;
38
38
  }
39
39
  type CatcherState = {
40
40
  /** The error that was caught. */
@@ -56,27 +56,6 @@ export declare class Catcher extends Component<CatcherProps, CatcherState> {
56
56
  static getDerivedStateFromError(reason: unknown): CatcherState;
57
57
  render(): ReactNode;
58
58
  }
59
- /**
60
- * Props for `<PageCatcher>` — the page `children` to guard.
61
- *
62
- * @see https://shelving.cc/ui/PageCatcherProps
63
- */
64
- export interface PageCatcherProps extends ChildProps {
65
- }
66
- /**
67
- * Error boundary for a whole page that renders a full `<ErrorPage>` fallback on error.
68
- *
69
- * @kind component
70
- * @see https://shelving.cc/ui/PageCatcher
71
- */
72
- export declare function PageCatcher({ children }: PageCatcherProps): ReactElement;
73
- /**
74
- * Props for `<ErrorNotice>` — the caught error `reason`.
75
- *
76
- * @see https://shelving.cc/ui/ErrorNoticeProps
77
- */
78
- export interface ErrorNoticeProps extends ErrorComponentProps {
79
- }
80
59
  /**
81
60
  * Render a caught error as an inline `<Notice>` with a retry button.
82
61
  *
@@ -85,14 +64,14 @@ export interface ErrorNoticeProps extends ErrorComponentProps {
85
64
  * @kind component
86
65
  * @see https://shelving.cc/ui/ErrorNotice
87
66
  */
88
- export declare function ErrorNotice({ reason }: ErrorNoticeProps): ReactElement;
67
+ export declare function ErrorNotice({ reason }: ErrorProps): ReactElement;
89
68
  /**
90
- * Props for `<ErrorPage>` the caught error `reason`.
69
+ * Error boundary for a whole page that renders a full `<ErrorPage>` fallback on error.
91
70
  *
92
- * @see https://shelving.cc/ui/ErrorPageProps
71
+ * @kind component
72
+ * @see https://shelving.cc/ui/PageCatcher
93
73
  */
94
- export interface ErrorPageProps extends ErrorComponentProps {
95
- }
74
+ export declare function PageCatcher({ children }: ChildProps): ReactElement;
96
75
  /**
97
76
  * Render a caught error as a full-page `<Page>` with an error `<Card>` and retry button.
98
77
  *
@@ -101,5 +80,5 @@ export interface ErrorPageProps extends ErrorComponentProps {
101
80
  * @kind component
102
81
  * @see https://shelving.cc/ui/ErrorPage
103
82
  */
104
- export declare function ErrorPage({ reason }: ErrorPageProps): ReactElement;
83
+ export declare function ErrorPage({ reason }: ErrorProps): ReactElement;
105
84
  export {};
@@ -3,6 +3,7 @@ import { ArrowPathIcon } from "@heroicons/react/24/solid";
3
3
  import { Component, createContext, use } from "react";
4
4
  import { getMessage } from "../../util/error.js";
5
5
  import { Card } from "../block/Card.js";
6
+ import { Paragraph } from "../block/Paragraph.js";
6
7
  import { Row } from "../block/Row.js";
7
8
  import { Subheading } from "../block/Subheading.js";
8
9
  import { Button } from "../form/Button.js";
@@ -59,15 +60,6 @@ export class Catcher extends Component {
59
60
  return (_jsx(RetryContext, { value: retry, children: _jsx(ErrorComponent, { reason: reason }) }));
60
61
  }
61
62
  }
62
- /**
63
- * Error boundary for a whole page that renders a full `<ErrorPage>` fallback on error.
64
- *
65
- * @kind component
66
- * @see https://shelving.cc/ui/PageCatcher
67
- */
68
- export function PageCatcher({ children }) {
69
- return _jsx(Catcher, { as: ErrorPage, children: children });
70
- }
71
63
  /**
72
64
  * Render a caught error as an inline `<Notice>` with a retry button.
73
65
  *
@@ -78,7 +70,16 @@ export function PageCatcher({ children }) {
78
70
  */
79
71
  export function ErrorNotice({ reason }) {
80
72
  const message = getMessage(reason) ?? "Unknown error";
81
- return (_jsxs(Notice, { status: "error", children: [_jsx("p", { children: message }), _jsx(RetryButton, { small: true })] }));
73
+ return (_jsxs(Notice, { status: "error", children: [_jsx(Paragraph, { children: message }), _jsx(RetryButton, { small: true })] }));
74
+ }
75
+ /**
76
+ * Error boundary for a whole page that renders a full `<ErrorPage>` fallback on error.
77
+ *
78
+ * @kind component
79
+ * @see https://shelving.cc/ui/PageCatcher
80
+ */
81
+ export function PageCatcher({ children }) {
82
+ return _jsx(Catcher, { as: ErrorPage, children: children });
82
83
  }
83
84
  /**
84
85
  * Render a caught error as a full-page `<Page>` with an error `<Card>` and retry button.
@@ -3,6 +3,7 @@ import { Component, createContext, type ReactElement, type ReactNode, use } from
3
3
  import { getMessage } from "../../util/error.js";
4
4
  import type { Callback } from "../../util/function.js";
5
5
  import { Card } from "../block/Card.js";
6
+ import { Paragraph } from "../block/Paragraph.js";
6
7
  import { Row } from "../block/Row.js";
7
8
  import { Subheading } from "../block/Subheading.js";
8
9
  import { Button, type ButtonVariants } from "../form/Button.js";
@@ -51,9 +52,9 @@ export function RetryButton({ children = RETRY_CHILDREN, ...props }: RetryButton
51
52
  /**
52
53
  * Props for a component that renders a caught error `reason`.
53
54
  *
54
- * @see https://shelving.cc/ui/ErrorComponentProps
55
+ * @see https://shelving.cc/ui/ErrorProps
55
56
  */
56
- export interface ErrorComponentProps {
57
+ export interface ErrorProps {
57
58
  reason: unknown;
58
59
  }
59
60
 
@@ -64,7 +65,7 @@ export interface ErrorComponentProps {
64
65
  */
65
66
  export interface CatcherProps extends ChildProps {
66
67
  /** Component to render an error (defaults to `<ErrorNotice />`) */
67
- as: (props: ErrorComponentProps) => ReactElement;
68
+ as: (props: ErrorProps) => ReactElement;
68
69
  }
69
70
 
70
71
  type CatcherState = {
@@ -107,30 +108,6 @@ export class Catcher extends Component<CatcherProps, CatcherState> {
107
108
  }
108
109
  }
109
110
 
110
- /**
111
- * Props for `<PageCatcher>` — the page `children` to guard.
112
- *
113
- * @see https://shelving.cc/ui/PageCatcherProps
114
- */
115
- export interface PageCatcherProps extends ChildProps {}
116
-
117
- /**
118
- * Error boundary for a whole page that renders a full `<ErrorPage>` fallback on error.
119
- *
120
- * @kind component
121
- * @see https://shelving.cc/ui/PageCatcher
122
- */
123
- export function PageCatcher({ children }: PageCatcherProps): ReactElement {
124
- return <Catcher as={ErrorPage}>{children}</Catcher>;
125
- }
126
-
127
- /**
128
- * Props for `<ErrorNotice>` — the caught error `reason`.
129
- *
130
- * @see https://shelving.cc/ui/ErrorNoticeProps
131
- */
132
- export interface ErrorNoticeProps extends ErrorComponentProps {}
133
-
134
111
  /**
135
112
  * Render a caught error as an inline `<Notice>` with a retry button.
136
113
  *
@@ -139,22 +116,25 @@ export interface ErrorNoticeProps extends ErrorComponentProps {}
139
116
  * @kind component
140
117
  * @see https://shelving.cc/ui/ErrorNotice
141
118
  */
142
- export function ErrorNotice({ reason }: ErrorNoticeProps): ReactElement {
119
+ export function ErrorNotice({ reason }: ErrorProps): ReactElement {
143
120
  const message = getMessage(reason) ?? "Unknown error";
144
121
  return (
145
122
  <Notice status="error">
146
- <p>{message}</p>
123
+ <Paragraph>{message}</Paragraph>
147
124
  <RetryButton small />
148
125
  </Notice>
149
126
  );
150
127
  }
151
128
 
152
129
  /**
153
- * Props for `<ErrorPage>` the caught error `reason`.
130
+ * Error boundary for a whole page that renders a full `<ErrorPage>` fallback on error.
154
131
  *
155
- * @see https://shelving.cc/ui/ErrorPageProps
132
+ * @kind component
133
+ * @see https://shelving.cc/ui/PageCatcher
156
134
  */
157
- export interface ErrorPageProps extends ErrorComponentProps {}
135
+ export function PageCatcher({ children }: ChildProps): ReactElement {
136
+ return <Catcher as={ErrorPage}>{children}</Catcher>;
137
+ }
158
138
 
159
139
  /**
160
140
  * Render a caught error as a full-page `<Page>` with an error `<Card>` and retry button.
@@ -164,7 +144,7 @@ export interface ErrorPageProps extends ErrorComponentProps {}
164
144
  * @kind component
165
145
  * @see https://shelving.cc/ui/ErrorPage
166
146
  */
167
- export function ErrorPage({ reason }: ErrorPageProps): ReactElement {
147
+ export function ErrorPage({ reason }: ErrorProps): ReactElement {
168
148
  const message = getMessage(reason) ?? "Unknown error";
169
149
  return (
170
150
  <Page title="Error">
package/ui/misc/Icon.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ComponentType, ReactElement } from "react";
2
- import { type ColorVariants } from "../style/Color.js";
2
+ import type { ColorVariants } from "../style/Color.js";
3
3
  import type { SpaceVariants } from "../style/Space.js";
4
4
  import { type StatusVariants } from "../style/Status.js";
5
5
  import type { TintVariant } from "../style/Tint.js";
package/ui/misc/Icon.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { CheckCircleIcon, ExclamationTriangleIcon, InformationCircleIcon, XCircleIcon } from "@heroicons/react/24/solid";
3
- import { getColorClass } from "../style/Color.js";
4
3
  import { getStatusClass } from "../style/Status.js";
5
4
  import { getTypographyClass } from "../style/Typography.js";
6
5
  import { getClass, getModuleClass } from "../util/css.js";
@@ -24,5 +23,5 @@ const STATUS_ICONS = {
24
23
  export function Icon(props) {
25
24
  const { status = "info", icon: Element = STATUS_ICONS[status] ?? InformationCircleIcon } = props;
26
25
  return (_jsx(Element, { className: getClass(getModuleClass(ICON_CSS, "icon"), //
27
- getColorClass(props), getStatusClass(props), getTypographyClass(props)) }));
26
+ getStatusClass(props), getTypographyClass(props)) }));
28
27
  }
package/ui/misc/Icon.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CheckCircleIcon, ExclamationTriangleIcon, InformationCircleIcon, XCircleIcon } from "@heroicons/react/24/solid";
2
2
  import type { ComponentType, ReactElement } from "react";
3
- import { type ColorVariants, getColorClass } from "../style/Color.js";
3
+ import type { ColorVariants } from "../style/Color.js";
4
4
  import type { SpaceVariants } from "../style/Space.js";
5
5
  import { getStatusClass, type Status, type StatusVariants } from "../style/Status.js";
6
6
  import type { TintVariant } from "../style/Tint.js";
@@ -55,9 +55,8 @@ export function Icon(props: IconProps): ReactElement {
55
55
  <Element
56
56
  className={getClass(
57
57
  getModuleClass(ICON_CSS, "icon"), //
58
- getColorClass(props),
59
58
  getStatusClass(props),
60
- getTypographyClass(props), // Used for size and tint.
59
+ getTypographyClass(props), // Used for colour, size, and tint.
61
60
  )}
62
61
  />
63
62
  );
@@ -0,0 +1,31 @@
1
+ import { type ReactElement, type ReactNode } from "react";
2
+ import type { ChildProps } from "../util/props.js";
3
+ /**
4
+ * Props for `<Loader>` and `<PageLoader>` — the `children` to load plus an optional `fallback` shown while they suspend.
5
+ *
6
+ * @see https://shelving.cc/ui/LoaderProps
7
+ */
8
+ export interface LoaderProps extends ChildProps {
9
+ /** Element rendered while `children` suspend (defaults to `LOADING`). */
10
+ readonly fallback?: ReactNode | undefined;
11
+ }
12
+ /**
13
+ * Load a component.
14
+ *
15
+ * - Wrapped in `<Catcher>` so child components can throw errors.
16
+ * - Wrapped in `<Suspense>` so child components can throw promises.
17
+ *
18
+ * @kind component
19
+ * @see https://shelving.cc/ui/Loader
20
+ */
21
+ export declare function Loader({ children, fallback }: LoaderProps): ReactElement;
22
+ /**
23
+ * Load a page.
24
+ *
25
+ * - Wrapped in `<PageCatcher>` so child components can throw errors.
26
+ * - Wrapped in `<Suspense>` so child components can throw promises.
27
+ *
28
+ * @kind component
29
+ * @see https://shelving.cc/ui/PageLoader
30
+ */
31
+ export declare function PageLoader({ children, fallback }: LoaderProps): ReactElement;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Suspense } from "react";
3
+ import { CenteredLayout } from "../layout/CenteredLayout.js";
4
+ import { Catcher, PageCatcher } from "./Catcher.js";
5
+ import { LOADING } from "./Loading.js";
6
+ /**
7
+ * Load a component.
8
+ *
9
+ * - Wrapped in `<Catcher>` so child components can throw errors.
10
+ * - Wrapped in `<Suspense>` so child components can throw promises.
11
+ *
12
+ * @kind component
13
+ * @see https://shelving.cc/ui/Loader
14
+ */
15
+ export function Loader({ children, fallback = LOADING }) {
16
+ return (_jsx(Catcher, { children: _jsx(Suspense, { fallback: fallback, children: children }) }));
17
+ }
18
+ /**
19
+ * Load a page.
20
+ *
21
+ * - Wrapped in `<PageCatcher>` so child components can throw errors.
22
+ * - Wrapped in `<Suspense>` so child components can throw promises.
23
+ *
24
+ * @kind component
25
+ * @see https://shelving.cc/ui/PageLoader
26
+ */
27
+ export function PageLoader({ children, fallback = _jsx(CenteredLayout, { children: LOADING }) }) {
28
+ return (_jsx(PageCatcher, { children: _jsx(Suspense, { fallback: fallback, children: children }) }));
29
+ }
@@ -0,0 +1,49 @@
1
+ import { type ReactElement, type ReactNode, Suspense } from "react";
2
+ import { CenteredLayout } from "../layout/CenteredLayout.js";
3
+ import type { ChildProps } from "../util/props.js";
4
+ import { Catcher, PageCatcher } from "./Catcher.js";
5
+ import { LOADING } from "./Loading.js";
6
+
7
+ /**
8
+ * Props for `<Loader>` and `<PageLoader>` — the `children` to load plus an optional `fallback` shown while they suspend.
9
+ *
10
+ * @see https://shelving.cc/ui/LoaderProps
11
+ */
12
+ export interface LoaderProps extends ChildProps {
13
+ /** Element rendered while `children` suspend (defaults to `LOADING`). */
14
+ readonly fallback?: ReactNode | undefined;
15
+ }
16
+
17
+ /**
18
+ * Load a component.
19
+ *
20
+ * - Wrapped in `<Catcher>` so child components can throw errors.
21
+ * - Wrapped in `<Suspense>` so child components can throw promises.
22
+ *
23
+ * @kind component
24
+ * @see https://shelving.cc/ui/Loader
25
+ */
26
+ export function Loader({ children, fallback = LOADING }: LoaderProps): ReactElement {
27
+ return (
28
+ <Catcher>
29
+ <Suspense fallback={fallback}>{children}</Suspense>
30
+ </Catcher>
31
+ );
32
+ }
33
+
34
+ /**
35
+ * Load a page.
36
+ *
37
+ * - Wrapped in `<PageCatcher>` so child components can throw errors.
38
+ * - Wrapped in `<Suspense>` so child components can throw promises.
39
+ *
40
+ * @kind component
41
+ * @see https://shelving.cc/ui/PageLoader
42
+ */
43
+ export function PageLoader({ children, fallback = <CenteredLayout>{LOADING}</CenteredLayout> }: LoaderProps): ReactElement {
44
+ return (
45
+ <PageCatcher>
46
+ <Suspense fallback={fallback}>{children}</Suspense>
47
+ </PageCatcher>
48
+ );
49
+ }
package/ui/misc/Tag.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import type { ReactElement } from "react";
2
2
  import { type ClickableProps } from "../form/Clickable.js";
3
- import { type ColorVariants } from "../style/Color.js";
4
3
  import { type StatusVariants } from "../style/Status.js";
5
4
  import { type TypographyVariants } from "../style/Typography.js";
6
5
  /**
@@ -8,7 +7,7 @@ import { type TypographyVariants } from "../style/Typography.js";
8
7
  *
9
8
  * @see https://shelving.cc/ui/TagVariants
10
9
  */
11
- export interface TagVariants extends StatusVariants, ColorVariants, TypographyVariants {
10
+ export interface TagVariants extends StatusVariants, TypographyVariants {
12
11
  }
13
12
  /**
14
13
  * Build the combined `className` string for a `<Tag>` from its styling variants.
package/ui/misc/Tag.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Clickable } from "../form/Clickable.js";
3
- import { getColorClass } from "../style/Color.js";
4
3
  import { getStatusClass } from "../style/Status.js";
5
4
  import { getTypographyClass } from "../style/Typography.js";
6
5
  import { getClass, getModuleClass } from "../util/css.js";
@@ -16,7 +15,7 @@ const TAG_CLASS = getModuleClass(TAG_CSS, "tag");
16
15
  */
17
16
  export function getTagClass(variants) {
18
17
  return getClass(TAG_CLASS, //
19
- getStatusClass(variants), getColorClass(variants), getTypographyClass(variants));
18
+ getStatusClass(variants), getTypographyClass(variants));
20
19
  }
21
20
  /**
22
21
  * Small inline label used to annotate other content.
package/ui/misc/Tag.tsx CHANGED
@@ -1,6 +1,5 @@
1
1
  import type { ReactElement } from "react";
2
2
  import { Clickable, type ClickableProps } from "../form/Clickable.js";
3
- import { type ColorVariants, getColorClass } from "../style/Color.js";
4
3
  import { getStatusClass, type StatusVariants } from "../style/Status.js";
5
4
  import { getTypographyClass, type TypographyVariants } from "../style/Typography.js";
6
5
  import { getClass, getModuleClass } from "../util/css.js";
@@ -13,7 +12,7 @@ const TAG_CLASS = getModuleClass(TAG_CSS, "tag");
13
12
  *
14
13
  * @see https://shelving.cc/ui/TagVariants
15
14
  */
16
- export interface TagVariants extends StatusVariants, ColorVariants, TypographyVariants {}
15
+ export interface TagVariants extends StatusVariants, TypographyVariants {}
17
16
 
18
17
  /**
19
18
  * Build the combined `className` string for a `<Tag>` from its styling variants.
@@ -27,7 +26,6 @@ export function getTagClass(variants: TagVariants) {
27
26
  return getClass(
28
27
  TAG_CLASS, //
29
28
  getStatusClass(variants),
30
- getColorClass(variants),
31
29
  getTypographyClass(variants),
32
30
  );
33
31
  }
@@ -1,5 +1,6 @@
1
1
  export * from "./Catcher.js";
2
2
  export * from "./Icon.js";
3
+ export * from "./Loader.js";
3
4
  export * from "./Loading.js";
4
5
  export * from "./Mapper.js";
5
6
  export * from "./Markup.js";
package/ui/misc/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./Catcher.js";
2
2
  export * from "./Icon.js";
3
+ export * from "./Loader.js";
3
4
  export * from "./Loading.js";
4
5
  export * from "./Mapper.js";
5
6
  export * from "./Markup.js";
package/ui/misc/index.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./Catcher.js";
2
2
  export * from "./Icon.js";
3
+ export * from "./Loader.js";
3
4
  export * from "./Loading.js";
4
5
  export * from "./Mapper.js";
5
6
  export * from "./Markup.js";
@@ -1,4 +1,3 @@
1
- import { type ColorVariants } from "./Color.js";
2
1
  import { type IndentVariants } from "./Indent.js";
3
2
  import { type PaddingVariants } from "./Padding.js";
4
3
  import { type SpaceVariants } from "./Space.js";
@@ -9,7 +8,7 @@ import { type WidthVariants } from "./Width.js";
9
8
  *
10
9
  * @see https://shelving.cc/ui/BlockVariants
11
10
  */
12
- export interface BlockVariants extends ColorVariants, IndentVariants, SpaceVariants, PaddingVariants, TypographyVariants, WidthVariants {
11
+ export interface BlockVariants extends IndentVariants, SpaceVariants, PaddingVariants, TypographyVariants, WidthVariants {
13
12
  }
14
13
  /**
15
14
  * Get the combined `className` string for a block from its styling variants.
package/ui/style/Block.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { getClass, getModuleClass } from "../util/css.js";
2
2
  import BLOCK_CSS from "./Block.module.css";
3
- import { getColorClass } from "./Color.js";
4
3
  import { getIndentClass } from "./Indent.js";
5
4
  import { getPaddingClass } from "./Padding.js";
6
5
  import { getSpaceClass } from "./Space.js";
@@ -18,5 +17,5 @@ const BLOCK_CLASS = getModuleClass(BLOCK_CSS, "block");
18
17
  */
19
18
  export function getBlockClass(variants) {
20
19
  return getClass(BLOCK_CLASS, //
21
- getColorClass(variants), getIndentClass(variants), getPaddingClass(variants), getSpaceClass(variants), getTypographyClass(variants), getWidthClass(variants));
20
+ getIndentClass(variants), getPaddingClass(variants), getSpaceClass(variants), getTypographyClass(variants), getWidthClass(variants));
22
21
  }
@@ -1,6 +1,5 @@
1
1
  import { getClass, getModuleClass } from "../util/css.js";
2
2
  import BLOCK_CSS from "./Block.module.css";
3
- import { type ColorVariants, getColorClass } from "./Color.js";
4
3
  import { getIndentClass, type IndentVariants } from "./Indent.js";
5
4
  import { getPaddingClass, type PaddingVariants } from "./Padding.js";
6
5
  import { getSpaceClass, type SpaceVariants } from "./Space.js";
@@ -14,7 +13,7 @@ const BLOCK_CLASS = getModuleClass(BLOCK_CSS, "block");
14
13
  *
15
14
  * @see https://shelving.cc/ui/BlockVariants
16
15
  */
17
- export interface BlockVariants extends ColorVariants, IndentVariants, SpaceVariants, PaddingVariants, TypographyVariants, WidthVariants {}
16
+ export interface BlockVariants extends IndentVariants, SpaceVariants, PaddingVariants, TypographyVariants, WidthVariants {}
18
17
 
19
18
  /**
20
19
  * Get the combined `className` string for a block from its styling variants.
@@ -28,7 +27,6 @@ export interface BlockVariants extends ColorVariants, IndentVariants, SpaceVaria
28
27
  export function getBlockClass(variants: BlockVariants): string {
29
28
  return getClass(
30
29
  BLOCK_CLASS, //
31
- getColorClass(variants),
32
30
  getIndentClass(variants),
33
31
  getPaddingClass(variants),
34
32
  getSpaceClass(variants),
@@ -1,3 +1,4 @@
1
+ import { type ColorVariants } from "./Color.js";
1
2
  import type { TintVariant } from "./Tint.js";
2
3
  /**
3
4
  * Allowed values for font size for components that support `TypographyVariants`
@@ -24,11 +25,13 @@ export type CaseVariant = "title" | "body" | "label" | "code" | "upper" | "lower
24
25
  */
25
26
  export type FontVariant = "title" | "body" | "label" | "code" | "serif" | "sans" | "monospace";
26
27
  /**
27
- * Typographic variant props — font-family, weight, case, size, tint, alignment, and wrap, applied via `getTypographyClass()`
28
+ * Typographic variant props — colour, font-family, weight, case, size, tint, alignment, and wrap, applied via `getTypographyClass()`
29
+ *
30
+ * - Extends `ColorVariants`, so anything that accepts typography also accepts the `color` variant.
28
31
  *
29
32
  * @see https://shelving.cc/ui/TypographyVariants
30
33
  */
31
- export interface TypographyVariants {
34
+ export interface TypographyVariants extends ColorVariants {
32
35
  /** Font size of the element. */
33
36
  size?: SizeVariant | undefined;
34
37
  /** Set CSS text `color:` to one of the shades of the current tint ladder. */
@@ -53,10 +56,11 @@ export interface TypographyVariants {
53
56
  /**
54
57
  * Get the typography class for a component from its typographic variant props.
55
58
  *
56
- * Maps the size, weight, font, case, tint, alignment, and wrap variant props to their CSS classes.
59
+ * Maps the colour, size, weight, font, case, tint, alignment, and wrap variant props to their CSS classes — the `color` variant is composed in via `getColorClass()`.
57
60
  *
58
- * @returns The combined typography class string, or `undefined` when no variants apply.
61
+ * @returns The combined typography class string (empty when no variants apply).
59
62
  * @example getTypographyClass({ font: "title", size: "large", center: true })
63
+ * @example getTypographyClass({ color: "purple", tint: "40" })
60
64
  * @see https://shelving.cc/ui/getTypographyClass
61
65
  */
62
- export declare function getTypographyClass({ tint, weight, font, case: caseValue, size, ...props }: TypographyVariants): string | undefined;
66
+ export declare function getTypographyClass({ tint, weight, font, case: caseValue, size, ...props }: TypographyVariants): string;
@@ -1,14 +1,16 @@
1
- import { getModuleClass } from "../util/css.js";
1
+ import { getClass, getModuleClass } from "../util/css.js";
2
+ import { getColorClass } from "./Color.js";
2
3
  import TYPOGRAPHY_CSS from "./Typography.module.css";
3
4
  /**
4
5
  * Get the typography class for a component from its typographic variant props.
5
6
  *
6
- * Maps the size, weight, font, case, tint, alignment, and wrap variant props to their CSS classes.
7
+ * Maps the colour, size, weight, font, case, tint, alignment, and wrap variant props to their CSS classes — the `color` variant is composed in via `getColorClass()`.
7
8
  *
8
- * @returns The combined typography class string, or `undefined` when no variants apply.
9
+ * @returns The combined typography class string (empty when no variants apply).
9
10
  * @example getTypographyClass({ font: "title", size: "large", center: true })
11
+ * @example getTypographyClass({ color: "purple", tint: "40" })
10
12
  * @see https://shelving.cc/ui/getTypographyClass
11
13
  */
12
14
  export function getTypographyClass({ tint, weight, font, case: caseValue, size, ...props }) {
13
- return getModuleClass(TYPOGRAPHY_CSS, caseValue && `case-${caseValue}`, tint && `tint-${tint}`, weight && `weight-${weight}`, font && `font-${font}`, size && `size-${size}`, props);
15
+ return getClass(getColorClass(props), getModuleClass(TYPOGRAPHY_CSS, caseValue && `case-${caseValue}`, tint && `tint-${tint}`, weight && `weight-${weight}`, font && `font-${font}`, size && `size-${size}`, props));
14
16
  }
@@ -1,4 +1,5 @@
1
- import { getModuleClass } from "../util/css.js";
1
+ import { getClass, getModuleClass } from "../util/css.js";
2
+ import { type ColorVariants, getColorClass } from "./Color.js";
2
3
  import type { TintVariant } from "./Tint.js";
3
4
  import TYPOGRAPHY_CSS from "./Typography.module.css";
4
5
 
@@ -49,11 +50,13 @@ export type CaseVariant = "title" | "body" | "label" | "code" | "upper" | "lower
49
50
  export type FontVariant = "title" | "body" | "label" | "code" | "serif" | "sans" | "monospace";
50
51
 
51
52
  /**
52
- * Typographic variant props — font-family, weight, case, size, tint, alignment, and wrap, applied via `getTypographyClass()`
53
+ * Typographic variant props — colour, font-family, weight, case, size, tint, alignment, and wrap, applied via `getTypographyClass()`
54
+ *
55
+ * - Extends `ColorVariants`, so anything that accepts typography also accepts the `color` variant.
53
56
  *
54
57
  * @see https://shelving.cc/ui/TypographyVariants
55
58
  */
56
- export interface TypographyVariants {
59
+ export interface TypographyVariants extends ColorVariants {
57
60
  /** Font size of the element. */
58
61
  size?: SizeVariant | undefined;
59
62
  /** Set CSS text `color:` to one of the shades of the current tint ladder. */
@@ -79,20 +82,24 @@ export interface TypographyVariants {
79
82
  /**
80
83
  * Get the typography class for a component from its typographic variant props.
81
84
  *
82
- * Maps the size, weight, font, case, tint, alignment, and wrap variant props to their CSS classes.
85
+ * Maps the colour, size, weight, font, case, tint, alignment, and wrap variant props to their CSS classes — the `color` variant is composed in via `getColorClass()`.
83
86
  *
84
- * @returns The combined typography class string, or `undefined` when no variants apply.
87
+ * @returns The combined typography class string (empty when no variants apply).
85
88
  * @example getTypographyClass({ font: "title", size: "large", center: true })
89
+ * @example getTypographyClass({ color: "purple", tint: "40" })
86
90
  * @see https://shelving.cc/ui/getTypographyClass
87
91
  */
88
- export function getTypographyClass({ tint, weight, font, case: caseValue, size, ...props }: TypographyVariants): string | undefined {
89
- return getModuleClass(
90
- TYPOGRAPHY_CSS,
91
- caseValue && `case-${caseValue}`,
92
- tint && `tint-${tint}`,
93
- weight && `weight-${weight}`,
94
- font && `font-${font}`,
95
- size && `size-${size}`,
96
- props,
92
+ export function getTypographyClass({ tint, weight, font, case: caseValue, size, ...props }: TypographyVariants): string {
93
+ return getClass(
94
+ getColorClass(props),
95
+ getModuleClass(
96
+ TYPOGRAPHY_CSS,
97
+ caseValue && `case-${caseValue}`,
98
+ tint && `tint-${tint}`,
99
+ weight && `weight-${weight}`,
100
+ font && `font-${font}`,
101
+ size && `size-${size}`,
102
+ props,
103
+ ),
97
104
  );
98
105
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  The typography variant props set an element's text styling from a single helper — `<Heading font="title" size="large">`, `<Paragraph weight="strong" center>`, `<Small case="upper">`. They're **overrides** for one-off changes; for an app-wide change, retune the variables below in a theme file.
4
4
 
5
- `getTypographyClass({ size, weight, font, case, tint, left, center, right, wrap, nowrap })` maps each prop to a class (e.g. `size="large"` → `size-large`, `font="title"` → `font-title`, `weight="strong"` → `weight-strong`, `case="upper"` → `case-upper`), and combines them with text alignment, tint colour, and wrapping. It supersedes the former `getFontClass()`, `getSizeClass()`, and `getWeightClass()` helpers, which were merged into this module.
5
+ `getTypographyClass({ color, size, weight, font, case, tint, left, center, right, wrap, nowrap })` maps each prop to a class (e.g. `size="large"` → `size-large`, `font="title"` → `font-title`, `weight="strong"` → `weight-strong`, `case="upper"` → `case-upper`), and combines them with text alignment, tint colour, and wrapping. `TypographyVariants` extends `ColorVariants`, so it also accepts `color` and composes [`getColorClass()`](/ui/getColorClass) internally — anything that opts into typography gets the `color` variant for free and no longer needs to extend `ColorVariants` or call `getColorClass()` separately. (`getColorClass()` stays exported for the rare element that wants colour without typography, such as `<Icon>`.) It also supersedes the former `getFontClass()`, `getSizeClass()`, and `getWeightClass()` helpers, which were merged into this module.
6
6
 
7
7
  The semantic faces, weights, sizes, and cases are aliases of the base values, so a theme usually only needs to move the small set of base variables.
8
8