shelving 1.268.2 → 1.269.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shelving",
3
- "version": "1.268.2",
3
+ "version": "1.269.0",
4
4
  "author": "Dave Houlbrooke <dave@shax.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,14 +1,15 @@
1
1
  import type { ReactElement } from "react";
2
2
  import { type ClickableProps } from "../button/Clickable.js";
3
3
  import { type BlockVariants } from "../style/Block.js";
4
+ import { type ShadowVariants } from "../style/Shadow.js";
4
5
  import { type StatusVariants } from "../style/Status.js";
5
6
  import type { BlockElement } from "./Block.js";
6
7
  /**
7
- * Props for `Card` — combines `ClickableProps` (for navigable cards) with colour, status, padding, space, typography, and width variants.
8
+ * Props for `Card` — combines `ClickableProps` (for navigable cards) with colour, status, padding, space, typography, width, and shadow variants.
8
9
  *
9
10
  * @see https://shelving.cc/ui/CardProps
10
11
  */
11
- export interface CardProps extends ClickableProps, StatusVariants, BlockVariants {
12
+ export interface CardProps extends ClickableProps, StatusVariants, BlockVariants, ShadowVariants {
12
13
  /**
13
14
  * Element this `<Card>` renders as, e.g. "header" to output a "<header>"
14
15
  * @default "article"
@@ -21,6 +22,7 @@ export interface CardProps extends ClickableProps, StatusVariants, BlockVariants
21
22
  * - When `href` or `onClick` is set the card becomes navigable: a stretched overlay `<a>` / `<button>` covers the entire card while the children render normally inside.
22
23
  * - Real interactive elements inside the card (e.g. inline `<a>` links) stay clickable thanks to `position: relative; z-index: 2` rules in the stylesheet.
23
24
  * - Accepts a `status` colour and raw `ColorProps` — the card styles the box; lay out its contents however the use case needs.
25
+ * - Carries a `normal` drop shadow by default — set `shadow="none"` to flatten a card, or `shadow="small"` / `shadow="large"` to adjust its elevation.
24
26
  *
25
27
  * @kind component
26
28
  * @see https://shelving.cc/ui/Card
package/ui/block/Card.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Clickable } from "../button/Clickable.js";
3
3
  import { getBlockClass } from "../style/Block.js";
4
+ import { getShadowClass } from "../style/Shadow.js";
4
5
  import { getStatusClass } from "../style/Status.js";
5
6
  import { getClass, getModuleClass } from "../util/css.js";
6
7
  import CARD_CSS from "./Card.module.css";
@@ -10,6 +11,7 @@ import CARD_CSS from "./Card.module.css";
10
11
  * - When `href` or `onClick` is set the card becomes navigable: a stretched overlay `<a>` / `<button>` covers the entire card while the children render normally inside.
11
12
  * - Real interactive elements inside the card (e.g. inline `<a>` links) stay clickable thanks to `position: relative; z-index: 2` rules in the stylesheet.
12
13
  * - Accepts a `status` colour and raw `ColorProps` — the card styles the box; lay out its contents however the use case needs.
14
+ * - Carries a `normal` drop shadow by default — set `shadow="none"` to flatten a card, or `shadow="small"` / `shadow="large"` to adjust its elevation.
13
15
  *
14
16
  * @kind component
15
17
  * @see https://shelving.cc/ui/Card
@@ -17,5 +19,5 @@ import CARD_CSS from "./Card.module.css";
17
19
  export function Card({ as: Element = "article", children, href, onClick, title = "Open", ...props }) {
18
20
  const overlay = (href || onClick) && (_jsx(Clickable, { title: title, href: href, onClick: onClick, ...props, className: getModuleClass(CARD_CSS, "overlay") }));
19
21
  return (_jsxs(Element, { className: getClass(getModuleClass(CARD_CSS, "card"), //
20
- getStatusClass(props), getBlockClass(props)), children: [overlay, overlay ? _jsx("div", { children: children }) : children] }));
22
+ getStatusClass(props), getBlockClass(props), getShadowClass(props)), children: [overlay, overlay ? _jsx("div", { children: children }) : children] }));
21
23
  }
package/ui/block/Card.md CHANGED
@@ -7,7 +7,8 @@ A boxed surface that groups a self-contained piece of content. Rendered as an `<
7
7
  - Set `href` or `onClick` to make the whole card navigable — a stretched, visually-hidden overlay `<a>` / `<button>` covers the card while the children render normally inside. Real interactive elements inside the card (inline links, buttons) stay clickable and keyboard-focusable.
8
8
  - `color=` and `status=` move the tint anchor for the card's scope, so the surface, border, text, and hover shade all re-derive together — and nested components (`<Tag>`, `<Preformatted>`, `<Button>`) inherit the same tint.
9
9
  - A card styles only the box. Lay out its contents with the usual block components (`<Subheading>`, `<Paragraph>`, `<Row>`, …).
10
- - Composes the standard styling variants: `color`, `status`, `padding`, `space`, `width`, plus typography.
10
+ - Cards carry a `normal` drop shadow by default — set `shadow="none"` to flatten a given card, or `shadow="small"` / `shadow="large"` to adjust its elevation.
11
+ - Composes the standard styling variants: `color`, `status`, `padding`, `space`, `width`, `shadow`, plus typography.
11
12
 
12
13
  ## Usage
13
14
 
@@ -43,6 +44,16 @@ import { Card, Subheading } from "shelving/ui";
43
44
  <Card color="purple" padding="large" space="none"><Subheading>Featured</Subheading></Card>
44
45
  ```
45
46
 
47
+ ### Shadow
48
+
49
+ ```tsx
50
+ import { Card, Subheading } from "shelving/ui";
51
+
52
+ // Flatten one card; raise another.
53
+ <Card shadow="none"><Subheading>Flat</Subheading></Card>
54
+ <Card shadow="large"><Subheading>Raised</Subheading></Card>
55
+ ```
56
+
46
57
  ## Styling
47
58
 
48
59
  `Card` paints from the [tint ladder](/ui/TINT_CLASS); override these hooks at `:root` (or any ancestor scope) to retheme. Apply `color=` / `status=` (on the card or an ancestor scope) to recolour everything at once — surface, border, text, and hover shade re-derive together; reach for a per-property hook for a single surgical change.
@@ -57,19 +68,20 @@ import { Card, Subheading } from "shelving/ui";
57
68
  | `--card-radius` | Corner radius | `var(--radius-normal)` (16px) |
58
69
  | `--card-padding` | Inner padding | `var(--space-normal)` (16px) |
59
70
  | `--card-space` | Outer block margin (top + bottom) | `var(--space-paragraph)` (16px) |
60
- | `--card-shadow` | Drop shadow | `none` |
71
+ | `--card-shadow` | Drop shadow | `var(--shadow-normal)` |
61
72
  | `--card-transition` | Transition | `all var(--duration-fast)` (150ms) |
62
73
  | `--card-focus-border` | Focus outline | `var(--stroke-focus) solid var(--color-focus)` |
63
74
 
64
- **Global tokens it reads** — move these to retheme broadly rather than overriding ladder steps directly: the tint ladder `--tint-00` / `--tint-80` / `--tint-90` / `--tint-95`, plus `--space-normal`, `--space-paragraph`, `--radius-normal`, `--stroke-normal`, `--stroke-focus`, `--color-focus`, and `--duration-fast`.
75
+ **Global tokens it reads** — move these to retheme broadly rather than overriding ladder steps directly: the tint ladder `--tint-00` / `--tint-80` / `--tint-90` / `--tint-95`, plus `--space-normal`, `--space-paragraph`, `--radius-normal`, `--shadow-normal`, `--stroke-normal`, `--stroke-focus`, `--color-focus`, and `--duration-fast`.
65
76
 
66
77
  ```css
67
- /* Theme: borderless cards with a soft shadow and tighter corners. */
78
+ /* Theme: flat cards with tighter corners. */
68
79
  :root {
69
- --card-border: none;
70
- --card-shadow: var(--shadow-small);
80
+ --card-shadow: none;
71
81
  --card-radius: var(--radius-small);
72
82
  }
73
83
  ```
74
84
 
85
+ The `--card-shadow` hook sets the app-wide default; the `shadow=` variant prop wins over it on a per-card basis.
86
+
75
87
  To recolour cards, apply `color=` / `status=` to the card (or a tinted ancestor scope) — e.g. `<Card color="purple">` — rather than a per-component tint hook.
@@ -2,6 +2,7 @@
2
2
  @import url("../style/Color.module.css");
3
3
  @import url("../style/Duration.module.css");
4
4
  @import url("../style/Radius.module.css");
5
+ @import url("../style/Shadow.module.css");
5
6
  @import url("../style/Space.module.css");
6
7
  @import url("../style/Stroke.module.css");
7
8
  @import url("../style/Tint.module.css");
@@ -30,7 +31,7 @@
30
31
  /* Style */
31
32
  background: var(--card-background, var(--tint-90));
32
33
  color: var(--card-color, var(--tint-00));
33
- box-shadow: var(--card-shadow, none);
34
+ box-shadow: var(--card-shadow, var(--shadow-normal));
34
35
  transition: var(--card-transition, all var(--duration-fast));
35
36
  outline: var(--card-focus-border, var(--stroke-focus) solid var(--color-focus));
36
37
  outline-offset: calc(0px - var(--card-stroke, var(--stroke-normal)));
package/ui/block/Card.tsx CHANGED
@@ -1,17 +1,18 @@
1
1
  import type { ReactElement } from "react";
2
2
  import { Clickable, type ClickableProps } from "../button/Clickable.js";
3
3
  import { type BlockVariants, getBlockClass } from "../style/Block.js";
4
+ import { getShadowClass, type ShadowVariants } from "../style/Shadow.js";
4
5
  import { getStatusClass, type StatusVariants } from "../style/Status.js";
5
6
  import { getClass, getModuleClass } from "../util/css.js";
6
7
  import type { BlockElement } from "./Block.js";
7
8
  import CARD_CSS from "./Card.module.css";
8
9
 
9
10
  /**
10
- * Props for `Card` — combines `ClickableProps` (for navigable cards) with colour, status, padding, space, typography, and width variants.
11
+ * Props for `Card` — combines `ClickableProps` (for navigable cards) with colour, status, padding, space, typography, width, and shadow variants.
11
12
  *
12
13
  * @see https://shelving.cc/ui/CardProps
13
14
  */
14
- export interface CardProps extends ClickableProps, StatusVariants, BlockVariants {
15
+ export interface CardProps extends ClickableProps, StatusVariants, BlockVariants, ShadowVariants {
15
16
  /**
16
17
  * Element this `<Card>` renders as, e.g. "header" to output a "<header>"
17
18
  * @default "article"
@@ -25,6 +26,7 @@ export interface CardProps extends ClickableProps, StatusVariants, BlockVariants
25
26
  * - When `href` or `onClick` is set the card becomes navigable: a stretched overlay `<a>` / `<button>` covers the entire card while the children render normally inside.
26
27
  * - Real interactive elements inside the card (e.g. inline `<a>` links) stay clickable thanks to `position: relative; z-index: 2` rules in the stylesheet.
27
28
  * - Accepts a `status` colour and raw `ColorProps` — the card styles the box; lay out its contents however the use case needs.
29
+ * - Carries a `normal` drop shadow by default — set `shadow="none"` to flatten a card, or `shadow="small"` / `shadow="large"` to adjust its elevation.
28
30
  *
29
31
  * @kind component
30
32
  * @see https://shelving.cc/ui/Card
@@ -39,6 +41,7 @@ export function Card({ as: Element = "article", children, href, onClick, title =
39
41
  getModuleClass(CARD_CSS, "card"), //
40
42
  getStatusClass(props),
41
43
  getBlockClass(props),
44
+ getShadowClass(props),
42
45
  )}
43
46
  >
44
47
  {overlay}
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @see https://shelving.cc/ui/ShadowVariant
5
5
  */
6
- export type ShadowVariant = "none" | "xxsmall" | "xsmall" | "small" | "normal" | "large" | "xlarge" | "xxlarge";
6
+ export type ShadowVariant = "none" | "small" | "normal" | "large";
7
7
  /**
8
8
  * Variant props for the drop shadow of an element, e.g. `shadow="large"`.
9
9
  *
@@ -6,13 +6,9 @@
6
6
  --shadow-color: #0006;
7
7
 
8
8
  /* Shadows — elevation drop-shadows. */
9
- --shadow-xxsmall: 0 0.125rem 0.5rem -0.25rem var(--shadow-color);
10
- --shadow-xsmall: 0 0.25rem 1rem -0.5rem var(--shadow-color);
11
9
  --shadow-small: 0 0.375rem 1.5rem -0.75rem var(--shadow-color);
12
10
  --shadow-normal: 0 0.5rem 2rem -1rem var(--shadow-color);
13
11
  --shadow-large: 0 0.75rem 3rem -1.5rem var(--shadow-color);
14
- --shadow-xlarge: 0 1rem 4rem -2rem var(--shadow-color);
15
- --shadow-xxlarge: 0 1.5rem 6rem -3rem var(--shadow-color);
16
12
  }
17
13
  }
18
14
 
@@ -22,14 +18,6 @@
22
18
  box-shadow: none;
23
19
  }
24
20
 
25
- .shadow-xxsmall {
26
- box-shadow: var(--shadow-xxsmall);
27
- }
28
-
29
- .shadow-xsmall {
30
- box-shadow: var(--shadow-xsmall);
31
- }
32
-
33
21
  .shadow-small {
34
22
  box-shadow: var(--shadow-small);
35
23
  }
@@ -41,12 +29,4 @@
41
29
  .shadow-large {
42
30
  box-shadow: var(--shadow-large);
43
31
  }
44
-
45
- .shadow-xlarge {
46
- box-shadow: var(--shadow-xlarge);
47
- }
48
-
49
- .shadow-xxlarge {
50
- box-shadow: var(--shadow-xxlarge);
51
- }
52
32
  }
@@ -6,7 +6,7 @@ import SHADOW_CSS from "./Shadow.module.css";
6
6
  *
7
7
  * @see https://shelving.cc/ui/ShadowVariant
8
8
  */
9
- export type ShadowVariant = "none" | "xxsmall" | "xsmall" | "small" | "normal" | "large" | "xlarge" | "xxlarge";
9
+ export type ShadowVariant = "none" | "small" | "normal" | "large";
10
10
 
11
11
  /**
12
12
  * Variant props for the drop shadow of an element, e.g. `shadow="large"`.
@@ -8,10 +8,8 @@ The following `:root` variables are defined by this module and can be overridden
8
8
 
9
9
  | Variable | Default |
10
10
  |---|---|
11
- | `--shadow-xxsmall` | `0 0.125rem 0.5rem -0.25rem #0006` |
12
- | `--shadow-xsmall` | `0 0.25rem 1rem -0.5rem #0006` |
13
11
  | `--shadow-small` | `0 0.375rem 1.5rem -0.75rem #0006` |
14
12
  | `--shadow-normal` | `0 0.5rem 2rem -1rem #0006` |
15
13
  | `--shadow-large` | `0 0.75rem 3rem -1.5rem #0006` |
16
- | `--shadow-xlarge` | `0 1rem 4rem -2rem #0006` |
17
- | `--shadow-xxlarge` | `0 1.5rem 6rem -3rem #0006` |
14
+
15
+ The `shadow=` variant prop accepts `"none"`, `"small"`, `"normal"`, or `"large"` `"none"` removes a component's default shadow rather than mapping to a token.