shelving 1.260.3 → 1.262.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/README.md +1 -1
- package/ui/block/Definitions.d.ts +1 -2
- package/ui/block/Definitions.tsx +1 -2
- package/ui/form/Button.d.ts +1 -2
- package/ui/form/Button.js +1 -2
- package/ui/form/Button.tsx +1 -3
- package/ui/form/CheckboxInput.js +0 -1
- package/ui/form/CheckboxInput.tsx +0 -1
- package/ui/form/RadioInput.js +0 -1
- package/ui/form/RadioInput.tsx +0 -1
- package/ui/inline/Code.d.ts +1 -2
- package/ui/inline/Code.md +4 -2
- package/ui/inline/Code.module.css +2 -2
- package/ui/inline/Code.tsx +1 -2
- package/ui/inline/Deleted.d.ts +4 -3
- package/ui/inline/Deleted.js +6 -4
- package/ui/inline/Deleted.md +34 -0
- package/ui/inline/Deleted.module.css +5 -3
- package/ui/inline/Deleted.tsx +16 -6
- package/ui/inline/Emphasis.d.ts +3 -2
- package/ui/inline/Emphasis.js +5 -3
- package/ui/inline/Emphasis.md +29 -0
- package/ui/inline/Emphasis.module.css +1 -1
- package/ui/inline/Emphasis.tsx +14 -4
- package/ui/inline/Inserted.d.ts +4 -3
- package/ui/inline/Inserted.js +5 -3
- package/ui/inline/Inserted.md +34 -0
- package/ui/inline/Inserted.module.css +5 -3
- package/ui/inline/Inserted.tsx +15 -5
- package/ui/inline/Link.d.ts +3 -2
- package/ui/inline/Link.js +4 -2
- package/ui/inline/Link.md +4 -2
- package/ui/inline/Link.module.css +3 -1
- package/ui/inline/Link.tsx +13 -4
- package/ui/inline/Mark.d.ts +3 -2
- package/ui/inline/Mark.js +6 -3
- package/ui/inline/Mark.md +6 -5
- package/ui/inline/Mark.module.css +12 -4
- package/ui/inline/Mark.tsx +16 -4
- package/ui/inline/Small.d.ts +3 -2
- package/ui/inline/Small.js +5 -3
- package/ui/inline/Small.md +30 -0
- package/ui/inline/Small.module.css +2 -1
- package/ui/inline/Small.tsx +14 -4
- package/ui/inline/Span.d.ts +19 -0
- package/ui/inline/Span.js +13 -0
- package/ui/inline/Span.md +33 -0
- package/ui/inline/Span.tsx +22 -0
- package/ui/inline/Strong.d.ts +3 -2
- package/ui/inline/Strong.js +5 -3
- package/ui/inline/Strong.md +5 -1
- package/ui/inline/Strong.module.css +1 -1
- package/ui/inline/Strong.tsx +14 -4
- package/ui/inline/index.d.ts +1 -0
- package/ui/inline/index.js +1 -0
- package/ui/inline/index.ts +1 -0
- package/ui/misc/Icon.d.ts +1 -1
- package/ui/misc/Icon.js +1 -2
- package/ui/misc/Icon.tsx +2 -3
- package/ui/misc/Tag.d.ts +1 -2
- package/ui/misc/Tag.js +1 -2
- package/ui/misc/Tag.tsx +1 -3
- package/ui/style/Block.d.ts +1 -2
- package/ui/style/Block.js +1 -2
- package/ui/style/Block.tsx +1 -3
- package/ui/style/Typography.d.ts +9 -5
- package/ui/style/Typography.js +6 -4
- package/ui/style/Typography.tsx +21 -14
- package/ui/style/getTypographyClass.md +1 -1
package/package.json
CHANGED
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()
|
|
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
|
|
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>`.
|
package/ui/block/Definitions.tsx
CHANGED
|
@@ -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
|
|
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>`.
|
package/ui/form/Button.d.ts
CHANGED
|
@@ -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,
|
|
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),
|
|
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.
|
package/ui/form/Button.tsx
CHANGED
|
@@ -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,
|
|
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
|
}
|
package/ui/form/CheckboxInput.js
CHANGED
|
@@ -4,7 +4,6 @@ import { getClass, getModuleClass } from "../util/css.js";
|
|
|
4
4
|
import { getInputClass } from "./Input.js";
|
|
5
5
|
import INPUT_CSS from "./Input.module.css";
|
|
6
6
|
const INPUT_LABEL_CLASS = getModuleClass(INPUT_CSS, "label");
|
|
7
|
-
const INPUT_PLACEHOLDER_CLASS = getModuleClass(INPUT_CSS, "placeholder");
|
|
8
7
|
/**
|
|
9
8
|
* Checkbox input bound to a `boolean` value, rendered as a labelled `<input type="checkbox">`.
|
|
10
9
|
* - The label content comes from `children`, falling back to `placeholder`/`title`.
|
|
@@ -6,7 +6,6 @@ import { getInputClass, type InputVariants, type ValueInputProps } from "./Input
|
|
|
6
6
|
import INPUT_CSS from "./Input.module.css";
|
|
7
7
|
|
|
8
8
|
const INPUT_LABEL_CLASS = getModuleClass(INPUT_CSS, "label");
|
|
9
|
-
const INPUT_PLACEHOLDER_CLASS = getModuleClass(INPUT_CSS, "placeholder");
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Props for `CheckboxInput`, a boolean-valued checkbox input.
|
package/ui/form/RadioInput.js
CHANGED
|
@@ -4,7 +4,6 @@ import { getClass, getModuleClass } from "../util/css.js";
|
|
|
4
4
|
import { getInputClass } from "./Input.js";
|
|
5
5
|
import INPUT_CSS from "./Input.module.css";
|
|
6
6
|
const INPUT_LABEL_CLASS = getModuleClass(INPUT_CSS, "label");
|
|
7
|
-
const INPUT_PLACEHOLDER_CLASS = getModuleClass(INPUT_CSS, "placeholder");
|
|
8
7
|
/**
|
|
9
8
|
* Single `<input type="radio">` wrapped in a `<label>` styled as an `<Input>`.
|
|
10
9
|
* - Calls `onValue(true)` when selected; label content comes from `children`, falling back to `placeholder`/`title`.
|
package/ui/form/RadioInput.tsx
CHANGED
|
@@ -6,7 +6,6 @@ import { getInputClass, type InputVariants, type ValueInputProps } from "./Input
|
|
|
6
6
|
import INPUT_CSS from "./Input.module.css";
|
|
7
7
|
|
|
8
8
|
const INPUT_LABEL_CLASS = getModuleClass(INPUT_CSS, "label");
|
|
9
|
-
const INPUT_PLACEHOLDER_CLASS = getModuleClass(INPUT_CSS, "placeholder");
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Props for `RadioInput`, a single labelled radio button styled as an input.
|
package/ui/inline/Code.d.ts
CHANGED
|
@@ -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
|
|
9
|
+
export interface CodeProps extends TypographyVariants, OptionalChildProps {
|
|
11
10
|
plain?: boolean | undefined;
|
|
12
11
|
}
|
|
13
12
|
/**
|
package/ui/inline/Code.md
CHANGED
|
@@ -13,7 +13,7 @@ An inline code span — renders a `<code>` element with monospace type and a sub
|
|
|
13
13
|
|
|
14
14
|
- Pick the sibling whose semantics match — they all look the same but mean different things to assistive tech and search.
|
|
15
15
|
- Pass `plain` to drop the default background and inline padding (useful when the code already sits inside a tinted container).
|
|
16
|
-
- Painted from the [tint ladder](/ui/TINT_CLASS): the background
|
|
16
|
+
- Painted from the [tint ladder](/ui/TINT_CLASS): the background defaults to `--tint-90` and the text to `--tint-00`, so it re-tints with its surrounding scope (override per-instance with `--code-background` / `--code-color`).
|
|
17
17
|
- Inside `<Prose>` raw `<code>` / `<kbd>` / `<samp>` / `<var>` pick up the same styling, and code inside a `<pre>` drops the inline box automatically.
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
@@ -37,7 +37,7 @@ import { Code } from "shelving/ui";
|
|
|
37
37
|
|
|
38
38
|
## Styling
|
|
39
39
|
|
|
40
|
-
`Code` paints from the [tint ladder](/ui/TINT_CLASS)
|
|
40
|
+
`Code` paints from the [tint ladder](/ui/TINT_CLASS): the box `background` / `color` default to ladder steps so they re-tint with the surrounding scope, and every property has a per-instance override hook.
|
|
41
41
|
|
|
42
42
|
| Variable | Styles | Default |
|
|
43
43
|
|---|---|---|
|
|
@@ -47,5 +47,7 @@ import { Code } from "shelving/ui";
|
|
|
47
47
|
| `--code-leading` | Line height | `var(--leading)` |
|
|
48
48
|
| `--code-padding` | Inline padding (non-`plain`) | `var(--space-xxsmall)` |
|
|
49
49
|
| `--code-radius` | Corner radius (non-`plain`) | `var(--radius-xxsmall)` |
|
|
50
|
+
| `--code-background` | Background fill (non-`plain`) | `var(--tint-90)` |
|
|
51
|
+
| `--code-color` | Text colour (non-`plain`) | `var(--tint-00)` |
|
|
50
52
|
|
|
51
53
|
**Global tokens it reads:** `--font-code`, `--weight-code`, `--size-smaller`, `--leading`, `--space-xxsmall`, `--radius-xxsmall`, and the tint-ladder steps `--tint-00` / `--tint-90` for the box fill and text.
|
package/ui/inline/Code.tsx
CHANGED
|
@@ -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
|
|
16
|
+
export interface CodeProps extends TypographyVariants, OptionalChildProps {
|
|
18
17
|
plain?: boolean | undefined;
|
|
19
18
|
}
|
|
20
19
|
|
package/ui/inline/Deleted.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
+
import { type TypographyVariants } from "../style/Typography.js";
|
|
2
3
|
import type { OptionalChildProps } from "../util/props.js";
|
|
3
4
|
/**
|
|
4
|
-
* Props for `Deleted` — optional `children`.
|
|
5
|
+
* Props for `Deleted` — colour and typography variants, plus optional `children`.
|
|
5
6
|
*
|
|
6
7
|
* @see https://shelving.cc/ui/DeletedProps
|
|
7
8
|
*/
|
|
8
|
-
export interface DeletedProps extends OptionalChildProps {
|
|
9
|
+
export interface DeletedProps extends OptionalChildProps, TypographyVariants {
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Deleted text — renders a `<del>` element to mark content removed from a document.
|
|
@@ -14,4 +15,4 @@ export interface DeletedProps extends OptionalChildProps {
|
|
|
14
15
|
* @example <Deleted>old price</Deleted>
|
|
15
16
|
* @see https://shelving.cc/ui/Deleted
|
|
16
17
|
*/
|
|
17
|
-
export declare function Deleted({ children }: DeletedProps): ReactElement;
|
|
18
|
+
export declare function Deleted({ children, ...props }: DeletedProps): ReactElement;
|
package/ui/inline/Deleted.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { getTypographyClass } from "../style/Typography.js";
|
|
3
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
3
4
|
import DELETED_CSS from "./Deleted.module.css";
|
|
4
|
-
const DELETED_CLASS = getModuleClass(DELETED_CSS, "
|
|
5
|
+
const DELETED_CLASS = getModuleClass(DELETED_CSS, "deleted");
|
|
5
6
|
/**
|
|
6
7
|
* Deleted text — renders a `<del>` element to mark content removed from a document.
|
|
7
8
|
*
|
|
@@ -9,6 +10,7 @@ const DELETED_CLASS = getModuleClass(DELETED_CSS, "definitions");
|
|
|
9
10
|
* @example <Deleted>old price</Deleted>
|
|
10
11
|
* @see https://shelving.cc/ui/Deleted
|
|
11
12
|
*/
|
|
12
|
-
export function Deleted({ children }) {
|
|
13
|
-
return _jsx("del", { className: DELETED_CLASS,
|
|
13
|
+
export function Deleted({ children, ...props }) {
|
|
14
|
+
return (_jsx("del", { className: getClass(DELETED_CLASS, //
|
|
15
|
+
getTypographyClass(props)), children: children }));
|
|
14
16
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Deleted
|
|
2
|
+
|
|
3
|
+
Deleted text — renders a `<del>` element to mark content that has been removed from a document, shown struck through in red by default. Prefer it over a raw `<del>` inside React components so the semantics and class names stay consistent.
|
|
4
|
+
|
|
5
|
+
**Things to know:**
|
|
6
|
+
|
|
7
|
+
- Use `Deleted` for content genuinely removed from a document (edits, diffs, retired prices), and `<Inserted>` for content added — they pair up.
|
|
8
|
+
- It drives its colour through the [tint ladder](/ui/TINT_CLASS), so the `color` variant (`color="purple"`, `color="orange"`, …) recolours the strike-through. The base tint defaults to `--color-red`.
|
|
9
|
+
- Inside `<Prose>` a raw `<del>` picks up the same styling, so Markdown-rendered deletions match component ones.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Marking a removed value
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Paragraph, Deleted, Inserted } from "shelving/ui";
|
|
17
|
+
|
|
18
|
+
<Paragraph>
|
|
19
|
+
Was <Deleted>$50</Deleted> <Inserted>$35</Inserted>.
|
|
20
|
+
</Paragraph>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Styling
|
|
24
|
+
|
|
25
|
+
`Deleted` paints from the [tint ladder](/ui/TINT_CLASS): the `50` tint sets the text colour, defaulting to `--color-red`. Override `--deleted-tint` to recolour from the base, or set each property directly.
|
|
26
|
+
|
|
27
|
+
| Variable | Styles | Default |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| `--deleted-tint` | Base tint (`--tint-50`) the colour derives from | `var(--color-red)` |
|
|
30
|
+
| `--deleted-color` | Text colour | `var(--tint-50)` |
|
|
31
|
+
| `--deleted-decoration` | Text decoration | `line-through var(--stroke-normal)` |
|
|
32
|
+
| `--deleted-weight` | Font weight | `var(--weight-strong)` |
|
|
33
|
+
|
|
34
|
+
**Global tokens it reads:** `--color-red`, `--stroke-normal`, `--weight-strong`, and the tint-ladder step `--tint-50`.
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
@layer components {
|
|
7
7
|
.deleted,
|
|
8
8
|
.prose del {
|
|
9
|
+
--tint-50: var(--deleted-tint, var(--color-red));
|
|
10
|
+
|
|
9
11
|
/* Style */
|
|
10
|
-
color: var(--color-
|
|
11
|
-
text-decoration: line-through var(--stroke-normal);
|
|
12
|
+
color: var(--deleted-color, var(--tint-50));
|
|
13
|
+
text-decoration: var(--deleted-decoration, line-through var(--stroke-normal));
|
|
12
14
|
|
|
13
15
|
/* Text */
|
|
14
|
-
font-weight: var(--weight-strong);
|
|
16
|
+
font-weight: var(--deleted-weight, var(--weight-strong));
|
|
15
17
|
}
|
|
16
18
|
}
|
package/ui/inline/Deleted.tsx
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { getTypographyClass, type TypographyVariants } from "../style/Typography.js";
|
|
3
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
3
4
|
import type { OptionalChildProps } from "../util/props.js";
|
|
4
5
|
import DELETED_CSS from "./Deleted.module.css";
|
|
5
6
|
|
|
6
|
-
const DELETED_CLASS = getModuleClass(DELETED_CSS, "
|
|
7
|
+
const DELETED_CLASS = getModuleClass(DELETED_CSS, "deleted");
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
|
-
* Props for `Deleted` — optional `children`.
|
|
10
|
+
* Props for `Deleted` — colour and typography variants, plus optional `children`.
|
|
10
11
|
*
|
|
11
12
|
* @see https://shelving.cc/ui/DeletedProps
|
|
12
13
|
*/
|
|
13
|
-
export interface DeletedProps extends OptionalChildProps {}
|
|
14
|
+
export interface DeletedProps extends OptionalChildProps, TypographyVariants {}
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Deleted text — renders a `<del>` element to mark content removed from a document.
|
|
@@ -19,6 +20,15 @@ export interface DeletedProps extends OptionalChildProps {}
|
|
|
19
20
|
* @example <Deleted>old price</Deleted>
|
|
20
21
|
* @see https://shelving.cc/ui/Deleted
|
|
21
22
|
*/
|
|
22
|
-
export function Deleted({ children }: DeletedProps): ReactElement {
|
|
23
|
-
return
|
|
23
|
+
export function Deleted({ children, ...props }: DeletedProps): ReactElement {
|
|
24
|
+
return (
|
|
25
|
+
<del
|
|
26
|
+
className={getClass(
|
|
27
|
+
DELETED_CLASS, //
|
|
28
|
+
getTypographyClass(props),
|
|
29
|
+
)}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</del>
|
|
33
|
+
);
|
|
24
34
|
}
|
package/ui/inline/Emphasis.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
+
import { type TypographyVariants } from "../style/Typography.js";
|
|
2
3
|
import type { OptionalChildProps } from "../util/props.js";
|
|
3
4
|
/**
|
|
4
5
|
* Props for `Emphasis` — optional `children`.
|
|
5
6
|
*
|
|
6
7
|
* @see https://shelving.cc/ui/EmphasisProps
|
|
7
8
|
*/
|
|
8
|
-
export interface EmphasisProps extends OptionalChildProps {
|
|
9
|
+
export interface EmphasisProps extends OptionalChildProps, TypographyVariants {
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Emphasised text — renders an `<em>` element for stress emphasis (typically italic).
|
|
@@ -14,4 +15,4 @@ export interface EmphasisProps extends OptionalChildProps {
|
|
|
14
15
|
* @example <Emphasis>really</Emphasis>
|
|
15
16
|
* @see https://shelving.cc/ui/Emphasis
|
|
16
17
|
*/
|
|
17
|
-
export declare function Emphasis({ children }: EmphasisProps): ReactElement;
|
|
18
|
+
export declare function Emphasis({ children, ...props }: EmphasisProps): ReactElement;
|
package/ui/inline/Emphasis.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { getTypographyClass } from "../style/Typography.js";
|
|
3
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
3
4
|
import EMPHASIS_CSS from "./Emphasis.module.css";
|
|
4
5
|
const EMPHASIS_CLASS = getModuleClass(EMPHASIS_CSS, "emphasis");
|
|
5
6
|
/**
|
|
@@ -9,6 +10,7 @@ const EMPHASIS_CLASS = getModuleClass(EMPHASIS_CSS, "emphasis");
|
|
|
9
10
|
* @example <Emphasis>really</Emphasis>
|
|
10
11
|
* @see https://shelving.cc/ui/Emphasis
|
|
11
12
|
*/
|
|
12
|
-
export function Emphasis({ children }) {
|
|
13
|
-
return _jsx("em", { className: EMPHASIS_CLASS,
|
|
13
|
+
export function Emphasis({ children, ...props }) {
|
|
14
|
+
return (_jsx("em", { className: getClass(EMPHASIS_CLASS, //
|
|
15
|
+
getTypographyClass(props)), children: children }));
|
|
14
16
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Emphasis
|
|
2
|
+
|
|
3
|
+
Emphasised text — renders an `<em>` element for stress emphasis, the kind that changes the meaning of a sentence (typically shown italic). Prefer it over a raw `<em>` or `<i>` inside React components so the semantics and class names stay consistent.
|
|
4
|
+
|
|
5
|
+
**Things to know:**
|
|
6
|
+
|
|
7
|
+
- Use `Emphasis` for stress emphasis (italic), `<Strong>` for importance (bold), and `<Mark>` for relevance highlighting — they are not interchangeable.
|
|
8
|
+
- It only sets the font style; it inherits colour, weight, and size from the surrounding text.
|
|
9
|
+
- Inside `<Prose>` raw `<em>` / `<i>` pick up the same styling, so Markdown-rendered emphasis matches component ones.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Stress emphasis in body copy
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Paragraph, Emphasis } from "shelving/ui";
|
|
17
|
+
|
|
18
|
+
<Paragraph>
|
|
19
|
+
You were meant to turn <Emphasis>left</Emphasis>.
|
|
20
|
+
</Paragraph>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Styling
|
|
24
|
+
|
|
25
|
+
`Emphasis` only sets its font style and inherits everything else from its surroundings.
|
|
26
|
+
|
|
27
|
+
| Variable | Styles | Default |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| `--emphasis-style` | Font style | `italic` |
|
package/ui/inline/Emphasis.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { getTypographyClass, type TypographyVariants } from "../style/Typography.js";
|
|
3
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
3
4
|
import type { OptionalChildProps } from "../util/props.js";
|
|
4
5
|
import EMPHASIS_CSS from "./Emphasis.module.css";
|
|
5
6
|
|
|
@@ -10,7 +11,7 @@ const EMPHASIS_CLASS = getModuleClass(EMPHASIS_CSS, "emphasis");
|
|
|
10
11
|
*
|
|
11
12
|
* @see https://shelving.cc/ui/EmphasisProps
|
|
12
13
|
*/
|
|
13
|
-
export interface EmphasisProps extends OptionalChildProps {}
|
|
14
|
+
export interface EmphasisProps extends OptionalChildProps, TypographyVariants {}
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Emphasised text — renders an `<em>` element for stress emphasis (typically italic).
|
|
@@ -19,6 +20,15 @@ export interface EmphasisProps extends OptionalChildProps {}
|
|
|
19
20
|
* @example <Emphasis>really</Emphasis>
|
|
20
21
|
* @see https://shelving.cc/ui/Emphasis
|
|
21
22
|
*/
|
|
22
|
-
export function Emphasis({ children }: EmphasisProps): ReactElement {
|
|
23
|
-
return
|
|
23
|
+
export function Emphasis({ children, ...props }: EmphasisProps): ReactElement {
|
|
24
|
+
return (
|
|
25
|
+
<em
|
|
26
|
+
className={getClass(
|
|
27
|
+
EMPHASIS_CLASS, //
|
|
28
|
+
getTypographyClass(props),
|
|
29
|
+
)}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</em>
|
|
33
|
+
);
|
|
24
34
|
}
|
package/ui/inline/Inserted.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
+
import { type TypographyVariants } from "../style/Typography.js";
|
|
2
3
|
import type { OptionalChildProps } from "../util/props.js";
|
|
3
4
|
/**
|
|
4
|
-
* Props for `Inserted` — optional `children`.
|
|
5
|
+
* Props for `Inserted` — colour and typography variants, plus optional `children`.
|
|
5
6
|
*
|
|
6
7
|
* @see https://shelving.cc/ui/InsertedProps
|
|
7
8
|
*/
|
|
8
|
-
export interface InsertedProps extends OptionalChildProps {
|
|
9
|
+
export interface InsertedProps extends OptionalChildProps, TypographyVariants {
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Inserted text — renders an `<ins>` element to mark content added to a document.
|
|
@@ -14,4 +15,4 @@ export interface InsertedProps extends OptionalChildProps {
|
|
|
14
15
|
* @example <Inserted>new price</Inserted>
|
|
15
16
|
* @see https://shelving.cc/ui/Inserted
|
|
16
17
|
*/
|
|
17
|
-
export declare function Inserted({ children }: InsertedProps): ReactElement;
|
|
18
|
+
export declare function Inserted({ children, ...props }: InsertedProps): ReactElement;
|
package/ui/inline/Inserted.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { getTypographyClass } from "../style/Typography.js";
|
|
3
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
3
4
|
import INSERTED_CSS from "./Inserted.module.css";
|
|
4
5
|
const INSERTED_CLASS = getModuleClass(INSERTED_CSS, "inserted");
|
|
5
6
|
/**
|
|
@@ -9,6 +10,7 @@ const INSERTED_CLASS = getModuleClass(INSERTED_CSS, "inserted");
|
|
|
9
10
|
* @example <Inserted>new price</Inserted>
|
|
10
11
|
* @see https://shelving.cc/ui/Inserted
|
|
11
12
|
*/
|
|
12
|
-
export function Inserted({ children }) {
|
|
13
|
-
return _jsx("ins", { className: INSERTED_CLASS,
|
|
13
|
+
export function Inserted({ children, ...props }) {
|
|
14
|
+
return (_jsx("ins", { className: getClass(INSERTED_CLASS, //
|
|
15
|
+
getTypographyClass(props)), children: children }));
|
|
14
16
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Inserted
|
|
2
|
+
|
|
3
|
+
Inserted text — renders an `<ins>` element to mark content that has been added to a document, shown underlined in green by default. Prefer it over a raw `<ins>` inside React components so the semantics and class names stay consistent.
|
|
4
|
+
|
|
5
|
+
**Things to know:**
|
|
6
|
+
|
|
7
|
+
- Use `Inserted` for content genuinely added to a document (edits, diffs, new prices), and `<Deleted>` for content removed — they pair up.
|
|
8
|
+
- It drives its colour through the [tint ladder](/ui/TINT_CLASS), so the `color` variant (`color="purple"`, `color="blue"`, …) recolours the underline. The base tint defaults to `--color-green`.
|
|
9
|
+
- Inside `<Prose>` a raw `<ins>` picks up the same styling, so Markdown-rendered insertions match component ones.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Marking an added value
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Paragraph, Deleted, Inserted } from "shelving/ui";
|
|
17
|
+
|
|
18
|
+
<Paragraph>
|
|
19
|
+
Was <Deleted>$50</Deleted> <Inserted>$35</Inserted>.
|
|
20
|
+
</Paragraph>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Styling
|
|
24
|
+
|
|
25
|
+
`Inserted` paints from the [tint ladder](/ui/TINT_CLASS): the `50` tint sets the text colour, defaulting to `--color-green`. Override `--inserted-tint` to recolour from the base, or set each property directly.
|
|
26
|
+
|
|
27
|
+
| Variable | Styles | Default |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| `--inserted-tint` | Base tint (`--tint-50`) the colour derives from | `var(--color-green)` |
|
|
30
|
+
| `--inserted-color` | Text colour | `var(--tint-50)` |
|
|
31
|
+
| `--inserted-decoration` | Text decoration | `underline var(--stroke-normal)` |
|
|
32
|
+
| `--inserted-weight` | Font weight | `var(--weight-strong)` |
|
|
33
|
+
|
|
34
|
+
**Global tokens it reads:** `--color-green`, `--stroke-normal`, `--weight-strong`, and the tint-ladder step `--tint-50`.
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
@layer components {
|
|
7
7
|
.inserted,
|
|
8
8
|
.prose ins {
|
|
9
|
+
--tint-50: var(--inserted-tint, var(--color-green));
|
|
10
|
+
|
|
9
11
|
/* Style */
|
|
10
|
-
color: var(--color-
|
|
11
|
-
text-decoration: underline var(--stroke-normal);
|
|
12
|
+
color: var(--inserted-color, var(--tint-50));
|
|
13
|
+
text-decoration: var(--inserted-decoration, underline var(--stroke-normal));
|
|
12
14
|
|
|
13
15
|
/* Text */
|
|
14
|
-
font-weight: var(--weight-strong);
|
|
16
|
+
font-weight: var(--inserted-weight, var(--weight-strong));
|
|
15
17
|
}
|
|
16
18
|
}
|
package/ui/inline/Inserted.tsx
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { getTypographyClass, type TypographyVariants } from "../style/Typography.js";
|
|
3
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
3
4
|
import type { OptionalChildProps } from "../util/props.js";
|
|
4
5
|
import INSERTED_CSS from "./Inserted.module.css";
|
|
5
6
|
|
|
6
7
|
const INSERTED_CLASS = getModuleClass(INSERTED_CSS, "inserted");
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
|
-
* Props for `Inserted` — optional `children`.
|
|
10
|
+
* Props for `Inserted` — colour and typography variants, plus optional `children`.
|
|
10
11
|
*
|
|
11
12
|
* @see https://shelving.cc/ui/InsertedProps
|
|
12
13
|
*/
|
|
13
|
-
export interface InsertedProps extends OptionalChildProps {}
|
|
14
|
+
export interface InsertedProps extends OptionalChildProps, TypographyVariants {}
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Inserted text — renders an `<ins>` element to mark content added to a document.
|
|
@@ -19,6 +20,15 @@ export interface InsertedProps extends OptionalChildProps {}
|
|
|
19
20
|
* @example <Inserted>new price</Inserted>
|
|
20
21
|
* @see https://shelving.cc/ui/Inserted
|
|
21
22
|
*/
|
|
22
|
-
export function Inserted({ children }: InsertedProps): ReactElement {
|
|
23
|
-
return
|
|
23
|
+
export function Inserted({ children, ...props }: InsertedProps): ReactElement {
|
|
24
|
+
return (
|
|
25
|
+
<ins
|
|
26
|
+
className={getClass(
|
|
27
|
+
INSERTED_CLASS, //
|
|
28
|
+
getTypographyClass(props),
|
|
29
|
+
)}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</ins>
|
|
33
|
+
);
|
|
24
34
|
}
|
package/ui/inline/Link.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import { type ClickableProps } from "../form/Clickable.js";
|
|
3
|
+
import { type TypographyVariants } from "../style/Typography.js";
|
|
3
4
|
/**
|
|
4
|
-
* Props for `Link` —
|
|
5
|
+
* Props for `Link` — `ClickableProps` (`href` for navigation or `onClick` for actions) plus colour and typography variants.
|
|
5
6
|
*
|
|
6
7
|
* @see https://shelving.cc/ui/LinkProps
|
|
7
8
|
*/
|
|
8
|
-
export interface LinkProps extends ClickableProps {
|
|
9
|
+
export interface LinkProps extends ClickableProps, TypographyVariants {
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
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,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Clickable } from "../form/Clickable.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getTypographyClass } from "../style/Typography.js";
|
|
4
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
4
5
|
import LINK_CSS from "./Link.module.css";
|
|
5
6
|
const LINK_CLASS = getModuleClass(LINK_CSS, "link");
|
|
6
7
|
/**
|
|
@@ -10,5 +11,6 @@ const LINK_CLASS = getModuleClass(LINK_CSS, "link");
|
|
|
10
11
|
* @see https://shelving.cc/ui/Link
|
|
11
12
|
*/
|
|
12
13
|
export function Link(props) {
|
|
13
|
-
return _jsx(Clickable, { ...props, className: LINK_CLASS
|
|
14
|
+
return (_jsx(Clickable, { ...props, className: getClass(LINK_CLASS, //
|
|
15
|
+
getTypographyClass(props)) }));
|
|
14
16
|
}
|