shelving 1.253.2 → 1.253.3

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 (92) hide show
  1. package/package.json +3 -3
  2. package/ui/README.md +4 -4
  3. package/ui/app/App.d.ts +0 -12
  4. package/ui/app/App.js +0 -14
  5. package/ui/app/App.tsx +0 -14
  6. package/ui/block/Address.module.css +2 -0
  7. package/ui/block/Block.d.ts +7 -3
  8. package/ui/block/Block.js +2 -2
  9. package/ui/block/Block.module.css +4 -0
  10. package/ui/block/Block.tsx +8 -4
  11. package/ui/block/Blockquote.module.css +1 -1
  12. package/ui/block/Caption.module.css +2 -2
  13. package/ui/block/Card.d.ts +9 -2
  14. package/ui/block/Card.js +4 -3
  15. package/ui/block/Card.tsx +13 -5
  16. package/ui/block/Definitions.module.css +3 -4
  17. package/ui/block/Divider.module.css +1 -1
  18. package/ui/block/Heading.module.css +2 -3
  19. package/ui/block/Label.module.css +2 -4
  20. package/ui/block/List.module.css +3 -1
  21. package/ui/block/List.tsx +0 -1
  22. package/ui/block/Panel.d.ts +7 -7
  23. package/ui/block/Panel.js +2 -2
  24. package/ui/block/Panel.module.css +4 -1
  25. package/ui/block/Panel.tsx +11 -11
  26. package/ui/block/Paragraph.module.css +2 -0
  27. package/ui/block/Preformatted.module.css +2 -4
  28. package/ui/block/Section.d.ts +20 -29
  29. package/ui/block/Section.js +21 -33
  30. package/ui/block/Section.md +2 -2
  31. package/ui/block/Section.module.css +2 -0
  32. package/ui/block/Section.tsx +32 -46
  33. package/ui/block/Subheading.module.css +2 -3
  34. package/ui/block/Title.module.css +2 -3
  35. package/ui/block/Video.js +3 -1
  36. package/ui/block/Video.tsx +10 -1
  37. package/ui/form/Button.module.css +1 -3
  38. package/ui/form/Field.module.css +1 -2
  39. package/ui/form/Input.module.css +1 -3
  40. package/ui/inline/Code.module.css +1 -3
  41. package/ui/inline/Deleted.module.css +1 -1
  42. package/ui/inline/Inserted.module.css +1 -1
  43. package/ui/inline/Link.module.css +1 -1
  44. package/ui/inline/Mark.module.css +1 -1
  45. package/ui/inline/Small.module.css +1 -1
  46. package/ui/inline/Strong.module.css +1 -1
  47. package/ui/menu/Menu.module.css +1 -4
  48. package/ui/misc/Loading.module.css +1 -1
  49. package/ui/misc/StatusIcon.module.css +1 -1
  50. package/ui/misc/Tag.module.css +1 -3
  51. package/ui/notice/Message.module.css +1 -1
  52. package/ui/notice/Notice.module.css +1 -2
  53. package/ui/style/Flex.js +2 -1
  54. package/ui/style/Flex.module.css +1 -1
  55. package/ui/style/Flex.tsx +4 -1
  56. package/ui/style/Padding.js +1 -1
  57. package/ui/style/Padding.module.css +18 -18
  58. package/ui/style/Padding.tsx +1 -1
  59. package/ui/style/Radius.module.css +7 -8
  60. package/ui/style/Space.js +1 -1
  61. package/ui/style/Space.module.css +25 -26
  62. package/ui/style/Space.tsx +1 -1
  63. package/ui/style/Tint.d.ts +6 -0
  64. package/ui/style/Tint.module.css +0 -6
  65. package/ui/style/Tint.tsx +28 -0
  66. package/ui/style/Typography.d.ts +37 -32
  67. package/ui/style/Typography.js +4 -8
  68. package/ui/style/Typography.module.css +163 -0
  69. package/ui/style/Typography.tsx +47 -59
  70. package/ui/style/getRadiusClass.md +8 -9
  71. package/ui/style/getSpaceClass.md +9 -10
  72. package/ui/style/getTypographyClass.md +64 -0
  73. package/ui/style/index.d.ts +0 -3
  74. package/ui/style/index.js +0 -3
  75. package/ui/style/index.tsx +0 -3
  76. package/ui/style/layers.css +2 -2
  77. package/ui/table/Table.module.css +1 -3
  78. package/ui/style/Font.d.ts +0 -24
  79. package/ui/style/Font.js +0 -13
  80. package/ui/style/Font.module.css +0 -50
  81. package/ui/style/Font.tsx +0 -31
  82. package/ui/style/Size.d.ts +0 -24
  83. package/ui/style/Size.js +0 -13
  84. package/ui/style/Size.module.css +0 -69
  85. package/ui/style/Size.tsx +0 -31
  86. package/ui/style/Weight.d.ts +0 -24
  87. package/ui/style/Weight.js +0 -13
  88. package/ui/style/Weight.module.css +0 -42
  89. package/ui/style/Weight.tsx +0 -31
  90. package/ui/style/getFontClass.md +0 -32
  91. package/ui/style/getSizeClass.md +0 -35
  92. package/ui/style/getWeightClass.md +0 -18
@@ -2,7 +2,7 @@
2
2
 
3
3
  The `space` variant prop sets a block-level element's `margin-block` (top + bottom) from the spacing scale — `<Section space="large">`, `<Paragraph space="none">`. It's an **override** for one-off spacing; for an app-wide change, retune the spacing variables below in a theme file.
4
4
 
5
- `getSpaceClass({ space })` maps the prop to a margin class (e.g. `space="large"` → `large`). The same scale also backs `getPaddingClass()` and `getGapClass()`, so all three move together when you change `--space`.
5
+ `getSpaceClass({ space })` maps the prop to a margin class (e.g. `space="large"` → `large`). The same scale also backs `getPaddingClass()` and `getGapClass()`, so all three move together when you change `--space-normal`.
6
6
 
7
7
  Alongside the named scale, `space` and `padding` also accept numeric multiples of `--space-normal` — `1x` … `10x` (e.g. `padding="5x"` → `calc(var(--space-normal) * 5)`) — for larger one-off blocks like hero panels.
8
8
 
@@ -14,18 +14,17 @@ The following `:root` variables are defined by this module and can be overridden
14
14
 
15
15
  | Variable | Default | Notes |
16
16
  |---|---|---|
17
- | `--space` | `1rem` | Base spacing unit — the root of the scale. |
18
- | `--space-xxsmall` | `calc(var(--space) * 0.25)` | 4px |
19
- | `--space-xsmall` | `calc(var(--space) * 0.5)` | 8px |
20
- | `--space-small` | `calc(var(--space) * 0.75)` | 12px |
21
- | `--space-normal` | `calc(var(--space) * 1)` | 16px |
22
- | `--space-large` | `calc(var(--space) * 1.5)` | 24px |
23
- | `--space-xlarge` | `calc(var(--space) * 2)` | 32px |
24
- | `--space-xxlarge` | `calc(var(--space) * 3)` | 48px |
17
+ | `--space-xxsmall` | `var(--space-normal) * 0.25` | 4px |
18
+ | `--space-xsmall` | `var(--space-normal) * 0.5` | 8px |
19
+ | `--space-small` | `var(--space-normal) * 0.75` | 12px |
20
+ | `--space-normal` | 1rem | 16px - base spacing unit (the root of the scale). |
21
+ | `--space-large` | `var(--space-normal) * 1.5` | 24px |
22
+ | `--space-xlarge` | `var(--space-normal) * 2` | 32px |
23
+ | `--space-xxlarge` | `var(--space-normal) * 3` | 48px |
25
24
 
26
25
  ### Semantic
27
26
 
28
27
  | Variable | Default | Used for |
29
28
  |---|---|---|
30
- | `--space-section` | `2rem` | Top margin for titles / headings / section blocks. |
29
+ | `--space-section` | `var(--space-normal) * 2` | Top margin for titles / headings / section blocks. |
31
30
  | `--space-paragraph` | `var(--space-normal)` | Default block-space for most prose elements. |
@@ -0,0 +1,64 @@
1
+ # getTypographyClass
2
+
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
+
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.
6
+
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
+
9
+ ## Theme variables
10
+
11
+ The following `:root` variables are defined by this module and can be overridden in a theme file to adjust default styling across the whole app.
12
+
13
+ ### Faces
14
+
15
+ | Variable | Default | Notes |
16
+ |---|---|---|
17
+ | `--font-sans` | `system-ui` | Default UI face. |
18
+ | `--font-monospace` | `ui-monospace, "SF Mono", "Consolas", "Menlo", monospace` | Code face. |
19
+ | `--font-serif` | `"Palatino", "Garamond", serif` | Serif face. |
20
+ | `--font-title` | `var(--font-sans)` | Headings and titles. |
21
+ | `--font-body` | `var(--font-sans)` | Body baseline. |
22
+ | `--font-label` | `var(--font-sans)` | Labels. |
23
+ | `--font-code` | `var(--font-monospace)` | Code and preformatted text. |
24
+
25
+ ### Weights
26
+
27
+ | Variable | Default | Used for |
28
+ |---|---|---|
29
+ | `--weight-normal` | `400` | Body text. |
30
+ | `--weight-strong` | `700` | Bold / emphasis. |
31
+ | `--weight-title` | `var(--weight-strong)` | Headings and titles. |
32
+ | `--weight-body` | `var(--weight-normal)` | Body baseline. |
33
+ | `--weight-label` | `var(--weight-strong)` | Labels (`<Label>`, table/definition headers). |
34
+ | `--weight-code` | `500` | Monospace / code. |
35
+
36
+ ### Sizes
37
+
38
+ | Variable | Default | Notes |
39
+ |---|---|---|
40
+ | `--size-scale` | `1.25` | Ratio between steps. |
41
+ | `--size-normal` | `1rem` | Base size — the root of the modular scale. |
42
+ | `--size-xxsmall` … `--size-xxxlarge` | `calc(var(--size-normal) * pow(var(--size-scale), n))` | Each step is the base scaled by a power of the ratio. |
43
+ | `--size-icon` | `var(--size-large)` | Icon box size. |
44
+ | `--size-label` | `var(--size-small)` | Label text size. |
45
+ | `--size-smaller` | `0.875em` | Relative (em) shrink — e.g. inline `<Small>`. |
46
+ | `--size-larger` | `1.5em` | Relative grow. |
47
+ | `--size-xlarger` | `2.5em` | Relative grow. |
48
+ | `--size-xxlarger` | `5em` | Relative grow. |
49
+
50
+ ### Line height
51
+
52
+ | Variable | Default | Used for |
53
+ |---|---|---|
54
+ | `--leading` | `clamp(1.05em, calc(1em + 0.5rem), 1.5em)` | Default line height; paired with every font-size variant and the body baseline. |
55
+ | `--leading-normal` | `1.5` | Plain unitless line height for dense blocks. |
56
+
57
+ ### Case
58
+
59
+ | Variable | Default | Used for |
60
+ |---|---|---|
61
+ | `--case-title` | `none` | `text-transform` for titles and headings. |
62
+ | `--case-body` | `none` | `text-transform` for body text and the body baseline. |
63
+ | `--case-label` | `uppercase` | `text-transform` for labels and tags. |
64
+ | `--case-code` | `none` | `text-transform` for code and preformatted text. |
@@ -1,17 +1,14 @@
1
1
  export * from "./Color.js";
2
2
  export * from "./Duration.js";
3
3
  export * from "./Flex.js";
4
- export * from "./Font.js";
5
4
  export * from "./Gap.js";
6
5
  export * from "./Padding.js";
7
6
  export * from "./Radius.js";
8
7
  export * from "./Scroll.js";
9
8
  export * from "./Shadow.js";
10
- export * from "./Size.js";
11
9
  export * from "./Space.js";
12
10
  export * from "./Status.js";
13
11
  export * from "./Stroke.js";
14
12
  export * from "./Tint.js";
15
13
  export * from "./Typography.js";
16
- export * from "./Weight.js";
17
14
  export * from "./Width.js";
package/ui/style/index.js CHANGED
@@ -1,17 +1,14 @@
1
1
  export * from "./Color.js";
2
2
  export * from "./Duration.js";
3
3
  export * from "./Flex.js";
4
- export * from "./Font.js";
5
4
  export * from "./Gap.js";
6
5
  export * from "./Padding.js";
7
6
  export * from "./Radius.js";
8
7
  export * from "./Scroll.js";
9
8
  export * from "./Shadow.js";
10
- export * from "./Size.js";
11
9
  export * from "./Space.js";
12
10
  export * from "./Status.js";
13
11
  export * from "./Stroke.js";
14
12
  export * from "./Tint.js";
15
13
  export * from "./Typography.js";
16
- export * from "./Weight.js";
17
14
  export * from "./Width.js";
@@ -1,17 +1,14 @@
1
1
  export * from "./Color.js";
2
2
  export * from "./Duration.js";
3
3
  export * from "./Flex.js";
4
- export * from "./Font.js";
5
4
  export * from "./Gap.js";
6
5
  export * from "./Padding.js";
7
6
  export * from "./Radius.js";
8
7
  export * from "./Scroll.js";
9
8
  export * from "./Shadow.js";
10
- export * from "./Size.js";
11
9
  export * from "./Space.js";
12
10
  export * from "./Status.js";
13
11
  export * from "./Stroke.js";
14
12
  export * from "./Tint.js";
15
13
  export * from "./Typography.js";
16
- export * from "./Weight.js";
17
14
  export * from "./Width.js";
@@ -8,8 +8,8 @@
8
8
  * • `defaults` — `:root` design tokens (spread across the themed token modules), the tint ladder, and the
9
9
  * body baseline. Low-priority opt-in defaults.
10
10
  * • `components` — component-defining CSS. The bulk of the codebase.
11
- * • `variants` — cross-cutting opt-in modifiers (Color, Status, Space, Padding, Gap, Width, Size, Weight,
12
- * Font, Flex, Scroll). Always beat components.
11
+ * • `variants` — cross-cutting opt-in modifiers (Color, Status, Space, Padding, Gap, Width, Typography,
12
+ * Flex, Scroll). Always beat components.
13
13
  * • `overrides` — top-priority structural overrides like `:first-child` / `:last-child` margin collapses,
14
14
  * which must beat variant-set margins.
15
15
  *
@@ -1,10 +1,8 @@
1
1
  @import "../style/layers.css";
2
- @import "../style/Font.module.css";
3
- @import "../style/Size.module.css";
4
2
  @import "../style/Space.module.css";
5
3
  @import "../style/Stroke.module.css";
6
4
  @import "../style/Tint.module.css";
7
- @import "../style/Weight.module.css";
5
+ @import "../style/Typography.module.css";
8
6
 
9
7
  @layer components {
10
8
  .table,
@@ -1,24 +0,0 @@
1
- /**
2
- * Allowed values for font family for components that support `FontVariants`
3
- *
4
- * @see https://dhoulb.github.io/shelving/ui/style/Font/FontValue
5
- */
6
- export type FontValue = "title" | "body" | "label" | "code" | "serif" | "sans" | "monospace";
7
- /**
8
- * Variant props for the font family of an element, e.g. `font="title"`.
9
- *
10
- * @see https://dhoulb.github.io/shelving/ui/style/Font/FontVariants
11
- */
12
- export interface FontVariants {
13
- /** Font family of the element. */
14
- font?: FontValue | undefined;
15
- }
16
- /**
17
- * Get the font-family class for a component from its `font` variant prop.
18
- *
19
- * @param variants
20
- * @returns The font class string, or `undefined` when no `font` is set.
21
- * @example getFontClass({ font: "title" }) // "title"
22
- * @see https://dhoulb.github.io/shelving/ui/style/Font/getFontClass
23
- */
24
- export declare function getFontClass({ font }: FontVariants): string | undefined;
package/ui/style/Font.js DELETED
@@ -1,13 +0,0 @@
1
- import { getModuleClass } from "../util/css.js";
2
- import FONT_CSS from "./Font.module.css";
3
- /**
4
- * Get the font-family class for a component from its `font` variant prop.
5
- *
6
- * @param variants
7
- * @returns The font class string, or `undefined` when no `font` is set.
8
- * @example getFontClass({ font: "title" }) // "title"
9
- * @see https://dhoulb.github.io/shelving/ui/style/Font/getFontClass
10
- */
11
- export function getFontClass({ font }) {
12
- return font && getModuleClass(FONT_CSS, font);
13
- }
@@ -1,50 +0,0 @@
1
- @import "layers.css";
2
-
3
- @layer defaults {
4
- :root {
5
- /* Font faces */
6
- --font-sans: system-ui;
7
- --font-monospace: ui-monospace, "SF Mono", "Consolas", "Menlo", monospace;
8
- --font-serif: "Palatino", "Garamond", serif;
9
-
10
- /* Semantic font faces */
11
- --font-title: var(--font-sans);
12
- --font-body: var(--font-sans);
13
- --font-label: var(--font-sans);
14
- --font-code: var(--font-monospace);
15
-
16
- /* Semantic cases */
17
- --case-label: uppercase;
18
- }
19
-
20
- /* Baseline body font so a page with no `<Layout>` still reads correctly. */
21
- body {
22
- font-family: var(--font-body);
23
- text-align: start;
24
- }
25
- }
26
-
27
- @layer variants {
28
- /* Font-family variants. */
29
- .title {
30
- font-family: var(--font-title);
31
- }
32
- .body {
33
- font-family: var(--font-body);
34
- }
35
- .code {
36
- font-family: var(--font-code);
37
- }
38
- .label {
39
- font-family: var(--font-label);
40
- }
41
- .sans {
42
- font-family: var(--font-sans);
43
- }
44
- .serif {
45
- font-family: var(--font-serif);
46
- }
47
- .monospace {
48
- font-family: var(--font-monospace);
49
- }
50
- }
package/ui/style/Font.tsx DELETED
@@ -1,31 +0,0 @@
1
- import { getModuleClass } from "../util/css.js";
2
- import FONT_CSS from "./Font.module.css";
3
-
4
- /**
5
- * Allowed values for font family for components that support `FontVariants`
6
- *
7
- * @see https://dhoulb.github.io/shelving/ui/style/Font/FontValue
8
- */
9
- export type FontValue = "title" | "body" | "label" | "code" | "serif" | "sans" | "monospace";
10
-
11
- /**
12
- * Variant props for the font family of an element, e.g. `font="title"`.
13
- *
14
- * @see https://dhoulb.github.io/shelving/ui/style/Font/FontVariants
15
- */
16
- export interface FontVariants {
17
- /** Font family of the element. */
18
- font?: FontValue | undefined;
19
- }
20
-
21
- /**
22
- * Get the font-family class for a component from its `font` variant prop.
23
- *
24
- * @param variants
25
- * @returns The font class string, or `undefined` when no `font` is set.
26
- * @example getFontClass({ font: "title" }) // "title"
27
- * @see https://dhoulb.github.io/shelving/ui/style/Font/getFontClass
28
- */
29
- export function getFontClass({ font }: FontVariants): string | undefined {
30
- return font && getModuleClass(FONT_CSS, font);
31
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * Allowed values for font size for components that support `SizeVariants`
3
- *
4
- * @see https://dhoulb.github.io/shelving/ui/style/Size/SizeVariant
5
- */
6
- export type SizeVariant = "xxsmall" | "xsmall" | "small" | "normal" | "large" | "xlarge" | "xxlarge";
7
- /**
8
- * Variant props for the font size of an element, e.g. `size="large"`.
9
- *
10
- * @see https://dhoulb.github.io/shelving/ui/style/Size/SizeVariants
11
- */
12
- export interface SizeVariants {
13
- /** Font size of the element. */
14
- size?: SizeVariant | undefined;
15
- }
16
- /**
17
- * Get the font-size class for a component from its `size` variant prop.
18
- *
19
- * @param variants
20
- * @returns The size class string, or `undefined` when no `size` is set.
21
- * @example getSizeClass({ size: "large" }) // "large"
22
- * @see https://dhoulb.github.io/shelving/ui/style/Size/getSizeClass
23
- */
24
- export declare function getSizeClass({ size }: SizeVariants): string | undefined;
package/ui/style/Size.js DELETED
@@ -1,13 +0,0 @@
1
- import { getModuleClass } from "../util/css.js";
2
- import SIZE_CSS from "./Size.module.css";
3
- /**
4
- * Get the font-size class for a component from its `size` variant prop.
5
- *
6
- * @param variants
7
- * @returns The size class string, or `undefined` when no `size` is set.
8
- * @example getSizeClass({ size: "large" }) // "large"
9
- * @see https://dhoulb.github.io/shelving/ui/style/Size/getSizeClass
10
- */
11
- export function getSizeClass({ size }) {
12
- return size && getModuleClass(SIZE_CSS, size);
13
- }
@@ -1,69 +0,0 @@
1
- @import "layers.css";
2
-
3
- @layer defaults {
4
- :root {
5
- /* Sizings */
6
- --size: 1rem;
7
- --size-scale: 1.25;
8
- --size-xxsmall: calc(var(--size) * pow(var(--size-scale), -3));
9
- --size-xsmall: calc(var(--size) * pow(var(--size-scale), -2));
10
- --size-small: calc(var(--size) * pow(var(--size-scale), -1));
11
- --size-normal: calc(var(--size) * pow(var(--size-scale), 0));
12
- --size-large: calc(var(--size) * pow(var(--size-scale), 1));
13
- --size-xlarge: calc(var(--size) * pow(var(--size-scale), 2));
14
- --size-xxlarge: calc(var(--size) * pow(var(--size-scale), 3));
15
- --size-xxxlarge: calc(var(--size) * pow(var(--size-scale), 4));
16
-
17
- /* Semantic sizes */
18
- --size-icon: var(--size-large);
19
- --size-label: var(--size-small);
20
-
21
- /* Relative sizes */
22
- --size-smaller: 0.875em;
23
- --size-larger: 1.5em;
24
- --size-xlarger: 2.5em;
25
- --size-xxlarger: 5em;
26
-
27
- /* Line heights */
28
- --leading: clamp(1.05em, calc(1em + 0.5rem), 1.5em);
29
- --leading-normal: 1.5;
30
- }
31
-
32
- /* Baseline body size so a page with no `<Layout>` still reads correctly. */
33
- body {
34
- font-size: var(--size-normal);
35
- line-height: var(--leading);
36
- }
37
- }
38
-
39
- @layer variants {
40
- /* Font-size variants. */
41
- .xxsmall {
42
- font-size: var(--size-xxsmall);
43
- line-height: var(--leading);
44
- }
45
- .xsmall {
46
- font-size: var(--size-xsmall);
47
- line-height: var(--leading);
48
- }
49
- .small {
50
- font-size: var(--size-small);
51
- line-height: var(--leading);
52
- }
53
- .normal {
54
- font-size: var(--size-normal);
55
- line-height: var(--leading);
56
- }
57
- .large {
58
- font-size: var(--size-large);
59
- line-height: var(--leading);
60
- }
61
- .xlarge {
62
- font-size: var(--size-xlarge);
63
- line-height: var(--leading);
64
- }
65
- .xxlarge {
66
- font-size: var(--size-xxlarge);
67
- line-height: var(--leading);
68
- }
69
- }
package/ui/style/Size.tsx DELETED
@@ -1,31 +0,0 @@
1
- import { getModuleClass } from "../util/css.js";
2
- import SIZE_CSS from "./Size.module.css";
3
-
4
- /**
5
- * Allowed values for font size for components that support `SizeVariants`
6
- *
7
- * @see https://dhoulb.github.io/shelving/ui/style/Size/SizeVariant
8
- */
9
- export type SizeVariant = "xxsmall" | "xsmall" | "small" | "normal" | "large" | "xlarge" | "xxlarge";
10
-
11
- /**
12
- * Variant props for the font size of an element, e.g. `size="large"`.
13
- *
14
- * @see https://dhoulb.github.io/shelving/ui/style/Size/SizeVariants
15
- */
16
- export interface SizeVariants {
17
- /** Font size of the element. */
18
- size?: SizeVariant | undefined;
19
- }
20
-
21
- /**
22
- * Get the font-size class for a component from its `size` variant prop.
23
- *
24
- * @param variants
25
- * @returns The size class string, or `undefined` when no `size` is set.
26
- * @example getSizeClass({ size: "large" }) // "large"
27
- * @see https://dhoulb.github.io/shelving/ui/style/Size/getSizeClass
28
- */
29
- export function getSizeClass({ size }: SizeVariants): string | undefined {
30
- return size && getModuleClass(SIZE_CSS, size);
31
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * Allowed values for font weight for components that support `WeightVariants`
3
- *
4
- * @see https://dhoulb.github.io/shelving/ui/style/Weight/WeightVariant
5
- */
6
- export type WeightVariant = "title" | "body" | "label" | "code" | "normal" | "strong";
7
- /**
8
- * Variant props for the font weight of an element, e.g. `weight="strong"`.
9
- *
10
- * @see https://dhoulb.github.io/shelving/ui/style/Weight/WeightVariants
11
- */
12
- export interface WeightVariants {
13
- /** Font weight of the element. */
14
- weight?: WeightVariant | undefined;
15
- }
16
- /**
17
- * Get the font weight class for a component from its `weight` variant prop.
18
- *
19
- * @param variants
20
- * @returns The weight class string, or `undefined` when no `weight` is set.
21
- * @example getWeightClass({ weight: "strong" }) // "weight-strong"
22
- * @see https://dhoulb.github.io/shelving/ui/style/Weight/getWeightClass
23
- */
24
- export declare function getWeightClass({ weight }: WeightVariants): string | undefined;
@@ -1,13 +0,0 @@
1
- import { getModuleClass } from "../util/css.js";
2
- import WEIGHT_CSS from "./Weight.module.css";
3
- /**
4
- * Get the font weight class for a component from its `weight` variant prop.
5
- *
6
- * @param variants
7
- * @returns The weight class string, or `undefined` when no `weight` is set.
8
- * @example getWeightClass({ weight: "strong" }) // "weight-strong"
9
- * @see https://dhoulb.github.io/shelving/ui/style/Weight/getWeightClass
10
- */
11
- export function getWeightClass({ weight }) {
12
- return weight && getModuleClass(WEIGHT_CSS, `weight-${weight}`);
13
- }
@@ -1,42 +0,0 @@
1
- @import "layers.css";
2
-
3
- @layer defaults {
4
- :root {
5
- /* Font weights */
6
- --weight-normal: 400;
7
- --weight-strong: 700;
8
-
9
- /* Semantic font weights */
10
- --weight-title: var(--weight-strong);
11
- --weight-body: var(--weight-normal);
12
- --weight-label: var(--weight-strong);
13
- --weight-code: 500;
14
- }
15
-
16
- /* Baseline body weight so a page with no `<Layout>` still reads correctly. */
17
- body {
18
- font-weight: var(--weight-body);
19
- }
20
- }
21
-
22
- @layer variants {
23
- /* Font-weight variants. */
24
- .weight-title {
25
- font-weight: var(--weight-title);
26
- }
27
- .weight-body {
28
- font-weight: var(--weight-body);
29
- }
30
- .weight-code {
31
- font-weight: var(--weight-code);
32
- }
33
- .weight-label {
34
- font-weight: var(--weight-label);
35
- }
36
- .weight-normal {
37
- font-weight: var(--weight-normal);
38
- }
39
- .weight-strong {
40
- font-weight: var(--weight-strong);
41
- }
42
- }
@@ -1,31 +0,0 @@
1
- import { getModuleClass } from "../util/css.js";
2
- import WEIGHT_CSS from "./Weight.module.css";
3
-
4
- /**
5
- * Allowed values for font weight for components that support `WeightVariants`
6
- *
7
- * @see https://dhoulb.github.io/shelving/ui/style/Weight/WeightVariant
8
- */
9
- export type WeightVariant = "title" | "body" | "label" | "code" | "normal" | "strong";
10
-
11
- /**
12
- * Variant props for the font weight of an element, e.g. `weight="strong"`.
13
- *
14
- * @see https://dhoulb.github.io/shelving/ui/style/Weight/WeightVariants
15
- */
16
- export interface WeightVariants {
17
- /** Font weight of the element. */
18
- weight?: WeightVariant | undefined;
19
- }
20
-
21
- /**
22
- * Get the font weight class for a component from its `weight` variant prop.
23
- *
24
- * @param variants
25
- * @returns The weight class string, or `undefined` when no `weight` is set.
26
- * @example getWeightClass({ weight: "strong" }) // "weight-strong"
27
- * @see https://dhoulb.github.io/shelving/ui/style/Weight/getWeightClass
28
- */
29
- export function getWeightClass({ weight }: WeightVariants): string | undefined {
30
- return weight && getModuleClass(WEIGHT_CSS, `weight-${weight}`);
31
- }
@@ -1,32 +0,0 @@
1
- # getFontClass
2
-
3
- The `font` variant prop sets an element's font family — `<Code font="monospace">`, `<Heading font="title">`. It's an **override** for one-off typeface changes; for an app-wide change, point the font variables below at your own faces in a theme file.
4
-
5
- `getFontClass({ font })` maps the prop to a font-family class (e.g. `font="title"` → `title`). The semantic faces (`--font-title`, `--font-body`, …) are aliases of the three base faces, so a theme typically only redefines `--font-sans` / `--font-serif` / `--font-monospace`.
6
-
7
- ## Theme variables
8
-
9
- The following `:root` variables are defined by this module and can be overridden in a theme file to adjust default styling across the whole app.
10
-
11
- ### Faces
12
-
13
- | Variable | Default | Notes |
14
- |---|---|---|
15
- | `--font-sans` | `system-ui` | Default UI face. |
16
- | `--font-monospace` | `ui-monospace, "SF Mono", "Consolas", "Menlo", monospace` | Code face. |
17
- | `--font-serif` | `"Palatino", "Garamond", serif` | Serif face. |
18
-
19
- ### Semantic
20
-
21
- | Variable | Default | Used for |
22
- |---|---|---|
23
- | `--font-title` | `var(--font-sans)` | Headings and titles. |
24
- | `--font-body` | `var(--font-sans)` | Body baseline. |
25
- | `--font-label` | `var(--font-sans)` | Labels. |
26
- | `--font-code` | `var(--font-monospace)` | Code and preformatted text. |
27
-
28
- ### Case
29
-
30
- | Variable | Default | Used for |
31
- |---|---|---|
32
- | `--case-label` | `uppercase` | `text-transform` for labels and tags. |
@@ -1,35 +0,0 @@
1
- # getSizeClass
2
-
3
- The `size` variant prop sets an element's font size from the modular scale — `<Heading size="large">`, `<Small size="xsmall">`. It's an **override** for one-off sizing; for an app-wide change, retune the scale variables below in a theme file.
4
-
5
- `getSizeClass({ size })` maps the prop to a font-size class (e.g. `size="large"` → `large`). All steps derive from `--size` and `--size-scale`, so changing those two reflows the whole ramp.
6
-
7
- ## Theme variables
8
-
9
- The following `:root` variables are defined by this module and can be overridden in a theme file to adjust default styling across the whole app.
10
-
11
- ### Scale
12
-
13
- | Variable | Default | Notes |
14
- |---|---|---|
15
- | `--size` | `1rem` | Base size — the root of the modular scale. |
16
- | `--size-scale` | `1.25` | Ratio between steps. |
17
- | `--size-xxsmall` … `--size-xxxlarge` | `calc(var(--size) * pow(var(--size-scale), n))` | Each step is the base scaled by a power of the ratio (`--size-normal` = `var(--size)`). |
18
-
19
- ### Semantic & relative
20
-
21
- | Variable | Default | Used for |
22
- |---|---|---|
23
- | `--size-icon` | `var(--size-large)` | Icon box size. |
24
- | `--size-label` | `var(--size-small)` | Label text size. |
25
- | `--size-smaller` | `0.875em` | Relative (em) shrink — e.g. inline `<Small>`. |
26
- | `--size-larger` | `1.5em` | Relative grow. |
27
- | `--size-xlarger` | `2.5em` | Relative grow. |
28
- | `--size-xxlarger` | `5em` | Relative grow. |
29
-
30
- ### Line height
31
-
32
- | Variable | Default | Used for |
33
- |---|---|---|
34
- | `--leading` | `clamp(1.05em, calc(1em + 0.5rem), 1.5em)` | Default line height; paired with every font-size variant and the body baseline. |
35
- | `--leading-normal` | `1.5` | Plain unitless line height for dense blocks. |
@@ -1,18 +0,0 @@
1
- # getWeightClass
2
-
3
- The `weight` variant prop sets an element's font weight — `<Paragraph weight="strong">`. It's an **override** for one-off emphasis; for an app-wide change, override the weight variables below in a theme file.
4
-
5
- `getWeightClass({ weight })` maps the prop to a weight class (e.g. `weight="strong"` → `weight-strong`). The semantic weights are aliases of the two base weights, so themes usually only need to move `--weight-normal` / `--weight-strong`.
6
-
7
- ## Theme variables
8
-
9
- The following `:root` variables are defined by this module and can be overridden in a theme file to adjust default styling across the whole app.
10
-
11
- | Variable | Default | Used for |
12
- |---|---|---|
13
- | `--weight-normal` | `400` | Body text. |
14
- | `--weight-strong` | `700` | Bold / emphasis. |
15
- | `--weight-title` | `var(--weight-strong)` | Headings and titles. |
16
- | `--weight-body` | `var(--weight-normal)` | Body baseline. |
17
- | `--weight-label` | `var(--weight-strong)` | Labels (`<Label>`, table/definition headers). |
18
- | `--weight-code` | `500` | Monospace / code. |