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.
- package/package.json +3 -3
- package/ui/README.md +4 -4
- package/ui/app/App.d.ts +0 -12
- package/ui/app/App.js +0 -14
- package/ui/app/App.tsx +0 -14
- package/ui/block/Address.module.css +2 -0
- package/ui/block/Block.d.ts +7 -3
- package/ui/block/Block.js +2 -2
- package/ui/block/Block.module.css +4 -0
- package/ui/block/Block.tsx +8 -4
- package/ui/block/Blockquote.module.css +1 -1
- package/ui/block/Caption.module.css +2 -2
- package/ui/block/Card.d.ts +9 -2
- package/ui/block/Card.js +4 -3
- package/ui/block/Card.tsx +13 -5
- package/ui/block/Definitions.module.css +3 -4
- package/ui/block/Divider.module.css +1 -1
- package/ui/block/Heading.module.css +2 -3
- package/ui/block/Label.module.css +2 -4
- package/ui/block/List.module.css +3 -1
- package/ui/block/List.tsx +0 -1
- package/ui/block/Panel.d.ts +7 -7
- package/ui/block/Panel.js +2 -2
- package/ui/block/Panel.module.css +4 -1
- package/ui/block/Panel.tsx +11 -11
- package/ui/block/Paragraph.module.css +2 -0
- package/ui/block/Preformatted.module.css +2 -4
- package/ui/block/Section.d.ts +20 -29
- package/ui/block/Section.js +21 -33
- package/ui/block/Section.md +2 -2
- package/ui/block/Section.module.css +2 -0
- package/ui/block/Section.tsx +32 -46
- package/ui/block/Subheading.module.css +2 -3
- package/ui/block/Title.module.css +2 -3
- package/ui/block/Video.js +3 -1
- package/ui/block/Video.tsx +10 -1
- package/ui/form/Button.module.css +1 -3
- package/ui/form/Field.module.css +1 -2
- package/ui/form/Input.module.css +1 -3
- package/ui/inline/Code.module.css +1 -3
- package/ui/inline/Deleted.module.css +1 -1
- package/ui/inline/Inserted.module.css +1 -1
- package/ui/inline/Link.module.css +1 -1
- package/ui/inline/Mark.module.css +1 -1
- package/ui/inline/Small.module.css +1 -1
- package/ui/inline/Strong.module.css +1 -1
- package/ui/menu/Menu.module.css +1 -4
- package/ui/misc/Loading.module.css +1 -1
- package/ui/misc/StatusIcon.module.css +1 -1
- package/ui/misc/Tag.module.css +1 -3
- package/ui/notice/Message.module.css +1 -1
- package/ui/notice/Notice.module.css +1 -2
- package/ui/style/Flex.js +2 -1
- package/ui/style/Flex.module.css +1 -1
- package/ui/style/Flex.tsx +4 -1
- package/ui/style/Padding.js +1 -1
- package/ui/style/Padding.module.css +18 -18
- package/ui/style/Padding.tsx +1 -1
- package/ui/style/Radius.module.css +7 -8
- package/ui/style/Space.js +1 -1
- package/ui/style/Space.module.css +25 -26
- package/ui/style/Space.tsx +1 -1
- package/ui/style/Tint.d.ts +6 -0
- package/ui/style/Tint.module.css +0 -6
- package/ui/style/Tint.tsx +28 -0
- package/ui/style/Typography.d.ts +37 -32
- package/ui/style/Typography.js +4 -8
- package/ui/style/Typography.module.css +163 -0
- package/ui/style/Typography.tsx +47 -59
- package/ui/style/getRadiusClass.md +8 -9
- package/ui/style/getSpaceClass.md +9 -10
- package/ui/style/getTypographyClass.md +64 -0
- package/ui/style/index.d.ts +0 -3
- package/ui/style/index.js +0 -3
- package/ui/style/index.tsx +0 -3
- package/ui/style/layers.css +2 -2
- package/ui/table/Table.module.css +1 -3
- package/ui/style/Font.d.ts +0 -24
- package/ui/style/Font.js +0 -13
- package/ui/style/Font.module.css +0 -50
- package/ui/style/Font.tsx +0 -31
- package/ui/style/Size.d.ts +0 -24
- package/ui/style/Size.js +0 -13
- package/ui/style/Size.module.css +0 -69
- package/ui/style/Size.tsx +0 -31
- package/ui/style/Weight.d.ts +0 -24
- package/ui/style/Weight.js +0 -13
- package/ui/style/Weight.module.css +0 -42
- package/ui/style/Weight.tsx +0 -31
- package/ui/style/getFontClass.md +0 -32
- package/ui/style/getSizeClass.md +0 -35
- package/ui/style/getWeightClass.md +0 -18
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
@layer defaults {
|
|
4
4
|
:root {
|
|
5
5
|
/* Radii — corner rounding. */
|
|
6
|
-
--radius:
|
|
7
|
-
--radius-
|
|
8
|
-
--radius-
|
|
9
|
-
--radius-
|
|
10
|
-
--radius-
|
|
11
|
-
--radius-
|
|
12
|
-
--radius-
|
|
13
|
-
--radius-xxlarge: calc(var(--radius) * 3); /* 48px */
|
|
6
|
+
--radius-xxsmall: calc(var(--radius-normal) * 0.25); /* 4px */
|
|
7
|
+
--radius-xsmall: calc(var(--radius-normal) * 0.5); /* 8px */
|
|
8
|
+
--radius-small: calc(var(--radius-normal) * 0.75); /* 12px */
|
|
9
|
+
--radius-normal: 1rem; /* 16px */
|
|
10
|
+
--radius-large: calc(var(--radius-normal) * 1.5); /* 24px */
|
|
11
|
+
--radius-xlarge: calc(var(--radius-normal) * 2); /* 32px */
|
|
12
|
+
--radius-xxlarge: calc(var(--radius-normal) * 3); /* 48px */
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
|
package/ui/style/Space.js
CHANGED
|
@@ -9,5 +9,5 @@ import SPACE_CSS from "./Space.module.css";
|
|
|
9
9
|
* @see https://dhoulb.github.io/shelving/ui/style/Space/getSpaceClass
|
|
10
10
|
*/
|
|
11
11
|
export function getSpaceClass({ space }) {
|
|
12
|
-
return space && getModuleClass(SPACE_CSS, space);
|
|
12
|
+
return space && getModuleClass(SPACE_CSS, `space-${space}`);
|
|
13
13
|
}
|
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
@layer defaults {
|
|
4
4
|
:root {
|
|
5
5
|
/* Spacings */
|
|
6
|
-
--space:
|
|
7
|
-
--space-
|
|
8
|
-
--space-
|
|
9
|
-
--space-
|
|
10
|
-
--space-
|
|
11
|
-
--space-
|
|
12
|
-
--space-
|
|
13
|
-
--space-xxlarge: calc(var(--space) * 3); /* 48px */
|
|
6
|
+
--space-xxsmall: calc(var(--space-normal) * 0.25); /* 4px */
|
|
7
|
+
--space-xsmall: calc(var(--space-normal) * 0.5); /* 8px */
|
|
8
|
+
--space-small: calc(var(--space-normal) * 0.75); /* 12px */
|
|
9
|
+
--space-normal: 1rem; /* 16px */
|
|
10
|
+
--space-large: calc(var(--space-normal) * 1.5); /* 24px */
|
|
11
|
+
--space-xlarge: calc(var(--space-normal) * 2); /* 32px */
|
|
12
|
+
--space-xxlarge: calc(var(--space-normal) * 3); /* 48px */
|
|
14
13
|
|
|
15
14
|
/* Semantic spacings */
|
|
16
15
|
--space-section: 2rem; /* Default top margin for titles/headings/section blocks. */
|
|
@@ -20,60 +19,60 @@
|
|
|
20
19
|
|
|
21
20
|
@layer variants {
|
|
22
21
|
/* Block-space variants — opt-in margin-block modifiers for any block-level component. */
|
|
23
|
-
.none {
|
|
22
|
+
.space-none {
|
|
24
23
|
margin-block: 0;
|
|
25
24
|
}
|
|
26
|
-
.xxsmall {
|
|
25
|
+
.space-xxsmall {
|
|
27
26
|
margin-block: var(--space-xxsmall);
|
|
28
27
|
}
|
|
29
|
-
.xsmall {
|
|
28
|
+
.space-xsmall {
|
|
30
29
|
margin-block: var(--space-xsmall);
|
|
31
30
|
}
|
|
32
|
-
.small {
|
|
31
|
+
.space-small {
|
|
33
32
|
margin-block: var(--space-small);
|
|
34
33
|
}
|
|
35
|
-
.normal {
|
|
34
|
+
.space-normal {
|
|
36
35
|
margin-block: var(--space-normal);
|
|
37
36
|
}
|
|
38
|
-
.large {
|
|
37
|
+
.space-large {
|
|
39
38
|
margin-block: var(--space-large);
|
|
40
39
|
}
|
|
41
|
-
.xlarge {
|
|
40
|
+
.space-xlarge {
|
|
42
41
|
margin-block: var(--space-xlarge);
|
|
43
42
|
}
|
|
44
|
-
.xxlarge {
|
|
43
|
+
.space-xxlarge {
|
|
45
44
|
margin-block: var(--space-xxlarge);
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
/* Numeric block-space multiples of `--space-normal` (`1x` … `10x`). */
|
|
49
|
-
|
|
48
|
+
.space-1x {
|
|
50
49
|
margin-block: calc(var(--space-normal) * 1);
|
|
51
50
|
}
|
|
52
|
-
|
|
51
|
+
.space-2x {
|
|
53
52
|
margin-block: calc(var(--space-normal) * 2);
|
|
54
53
|
}
|
|
55
|
-
|
|
54
|
+
.space-3x {
|
|
56
55
|
margin-block: calc(var(--space-normal) * 3);
|
|
57
56
|
}
|
|
58
|
-
|
|
57
|
+
.space-4x {
|
|
59
58
|
margin-block: calc(var(--space-normal) * 4);
|
|
60
59
|
}
|
|
61
|
-
|
|
60
|
+
.space-5x {
|
|
62
61
|
margin-block: calc(var(--space-normal) * 5);
|
|
63
62
|
}
|
|
64
|
-
|
|
63
|
+
.space-6x {
|
|
65
64
|
margin-block: calc(var(--space-normal) * 6);
|
|
66
65
|
}
|
|
67
|
-
|
|
66
|
+
.space-7x {
|
|
68
67
|
margin-block: calc(var(--space-normal) * 7);
|
|
69
68
|
}
|
|
70
|
-
|
|
69
|
+
.space-8x {
|
|
71
70
|
margin-block: calc(var(--space-normal) * 8);
|
|
72
71
|
}
|
|
73
|
-
|
|
72
|
+
.space-9x {
|
|
74
73
|
margin-block: calc(var(--space-normal) * 9);
|
|
75
74
|
}
|
|
76
|
-
|
|
75
|
+
.space-10x {
|
|
77
76
|
margin-block: calc(var(--space-normal) * 10);
|
|
78
77
|
}
|
|
79
78
|
}
|
package/ui/style/Space.tsx
CHANGED
|
@@ -45,5 +45,5 @@ export interface SpaceVariants {
|
|
|
45
45
|
* @see https://dhoulb.github.io/shelving/ui/style/Space/getSpaceClass
|
|
46
46
|
*/
|
|
47
47
|
export function getSpaceClass({ space }: SpaceVariants): string | undefined {
|
|
48
|
-
return space && getModuleClass(SPACE_CSS, space);
|
|
48
|
+
return space && getModuleClass(SPACE_CSS, `space-${space}`);
|
|
49
49
|
}
|
package/ui/style/Tint.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shades of the currently selected tint color, from `"00"` (black) through `"50"` (the hue itself) to `"100"` (white).
|
|
3
|
+
*
|
|
4
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Tint/TintVariant
|
|
5
|
+
*/
|
|
6
|
+
export type TintVariant = "00" | "05" | "10" | "15" | "20" | "25" | "30" | "35" | "40" | "45" | "50" | "55" | "60" | "65" | "70" | "75" | "80" | "85" | "90" | "95" | "100";
|
|
1
7
|
/**
|
|
2
8
|
* CSS class that (re)calculates the full ladder of tint shades from the current global tint colour.
|
|
3
9
|
*
|
package/ui/style/Tint.module.css
CHANGED
package/ui/style/Tint.tsx
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
import { getModuleClass } from "../util/css.js";
|
|
2
2
|
import THEME_CSS from "./Tint.module.css";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Shades of the currently selected tint color, from `"00"` (black) through `"50"` (the hue itself) to `"100"` (white).
|
|
6
|
+
*
|
|
7
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Tint/TintVariant
|
|
8
|
+
*/
|
|
9
|
+
export type TintVariant =
|
|
10
|
+
| "00"
|
|
11
|
+
| "05"
|
|
12
|
+
| "10"
|
|
13
|
+
| "15"
|
|
14
|
+
| "20"
|
|
15
|
+
| "25"
|
|
16
|
+
| "30"
|
|
17
|
+
| "35"
|
|
18
|
+
| "40"
|
|
19
|
+
| "45"
|
|
20
|
+
| "50"
|
|
21
|
+
| "55"
|
|
22
|
+
| "60"
|
|
23
|
+
| "65"
|
|
24
|
+
| "70"
|
|
25
|
+
| "75"
|
|
26
|
+
| "80"
|
|
27
|
+
| "85"
|
|
28
|
+
| "90"
|
|
29
|
+
| "95"
|
|
30
|
+
| "100";
|
|
31
|
+
|
|
4
32
|
/**
|
|
5
33
|
* CSS class that (re)calculates the full ladder of tint shades from the current global tint colour.
|
|
6
34
|
*
|
package/ui/style/Typography.d.ts
CHANGED
|
@@ -1,57 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type SizeVariants } from "./Size.js";
|
|
3
|
-
import { type WeightVariants } from "./Weight.js";
|
|
1
|
+
import type { TintVariant } from "./Tint.js";
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
6
|
-
* - Can be applied as the text `color:` for components that support `TypographyVariants`
|
|
3
|
+
* Allowed values for font size for components that support `TypographyVariants`
|
|
7
4
|
*
|
|
8
|
-
* @see https://dhoulb.github.io/shelving/ui/style/Typography/
|
|
5
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Typography/SizeVariant
|
|
9
6
|
*/
|
|
10
|
-
export type
|
|
7
|
+
export type SizeVariant = "xxsmall" | "xsmall" | "small" | "normal" | "large" | "xlarge" | "xxlarge";
|
|
11
8
|
/**
|
|
12
|
-
*
|
|
9
|
+
* Allowed values for font weight for components that support `TypographyVariants`
|
|
13
10
|
*
|
|
14
|
-
* @see https://dhoulb.github.io/shelving/ui/style/Typography/
|
|
11
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Typography/WeightVariant
|
|
15
12
|
*/
|
|
16
|
-
export type
|
|
17
|
-
/** Align text to the start of the line (LTR: left). */
|
|
18
|
-
left?: boolean | undefined;
|
|
19
|
-
/** Centre text horizontally. */
|
|
20
|
-
center?: boolean | undefined;
|
|
21
|
-
/** Align text to the end of the line (LTR: right). */
|
|
22
|
-
right?: boolean | undefined;
|
|
23
|
-
};
|
|
13
|
+
export type WeightVariant = "title" | "body" | "label" | "code" | "normal" | "strong";
|
|
24
14
|
/**
|
|
25
|
-
*
|
|
15
|
+
* Allowed values for text case for components that support `TypographyVariants`
|
|
26
16
|
*
|
|
27
|
-
* @see https://dhoulb.github.io/shelving/ui/style/Typography/
|
|
17
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Typography/CaseVariant
|
|
28
18
|
*/
|
|
29
|
-
export type
|
|
30
|
-
/** Enable wrapping. */
|
|
31
|
-
wrap?: boolean | undefined;
|
|
32
|
-
/** Disable wrapping. */
|
|
33
|
-
nowrap?: boolean | undefined;
|
|
34
|
-
};
|
|
19
|
+
export type CaseVariant = "title" | "body" | "label" | "code" | "upper" | "lower" | "normal";
|
|
35
20
|
/**
|
|
36
|
-
*
|
|
21
|
+
* Allowed values for font family for components that support `TypographyVariants`
|
|
37
22
|
*
|
|
38
|
-
*
|
|
39
|
-
|
|
23
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Typography/FontVariant
|
|
24
|
+
*/
|
|
25
|
+
export type FontVariant = "title" | "body" | "label" | "code" | "serif" | "sans" | "monospace";
|
|
26
|
+
/**
|
|
27
|
+
* Typographic variant props — font-family, weight, case, size, tint, alignment, and wrap, applied via `getTypographyClass()`
|
|
40
28
|
*
|
|
41
29
|
* @see https://dhoulb.github.io/shelving/ui/style/Typography/TypographyVariants
|
|
42
30
|
*/
|
|
43
|
-
export interface TypographyVariants
|
|
31
|
+
export interface TypographyVariants {
|
|
32
|
+
/** Font size of the element. */
|
|
33
|
+
size?: SizeVariant | undefined;
|
|
44
34
|
/** Set CSS text `color:` to one of the shades of the current tint ladder. */
|
|
45
35
|
tint?: TintVariant | undefined;
|
|
36
|
+
/** Font family of the element. */
|
|
37
|
+
font?: FontVariant | undefined;
|
|
38
|
+
/** Text case of the element. */
|
|
39
|
+
case?: CaseVariant | undefined;
|
|
40
|
+
/** Font weight of the element. */
|
|
41
|
+
weight?: WeightVariant | undefined;
|
|
42
|
+
/** Align text to the start of the line (LTR: left). */
|
|
43
|
+
left?: boolean | undefined;
|
|
44
|
+
/** Centre text horizontally. */
|
|
45
|
+
center?: boolean | undefined;
|
|
46
|
+
/** Align text to the end of the line (LTR: right). */
|
|
47
|
+
right?: boolean | undefined;
|
|
48
|
+
/** Enable wrapping. */
|
|
49
|
+
wrap?: boolean | undefined;
|
|
50
|
+
/** Disable wrapping. */
|
|
51
|
+
nowrap?: boolean | undefined;
|
|
46
52
|
}
|
|
47
53
|
/**
|
|
48
54
|
* Get the typography class for a component from its typographic variant props.
|
|
49
55
|
*
|
|
50
|
-
*
|
|
56
|
+
* Maps the size, weight, font, case, tint, alignment, and wrap variant props to their CSS classes.
|
|
51
57
|
*
|
|
52
|
-
* @param variants
|
|
53
58
|
* @returns The combined typography class string, or `undefined` when no variants apply.
|
|
54
59
|
* @example getTypographyClass({ font: "title", size: "large", center: true })
|
|
55
60
|
* @see https://dhoulb.github.io/shelving/ui/style/Typography/getTypographyClass
|
|
56
61
|
*/
|
|
57
|
-
export declare function getTypographyClass({ tint, ...props }: TypographyVariants): string | undefined;
|
|
62
|
+
export declare function getTypographyClass({ tint, weight, font, case: caseValue, size, ...props }: TypographyVariants): string | undefined;
|
package/ui/style/Typography.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getFontClass } from "./Font.js";
|
|
3
|
-
import { getSizeClass } from "./Size.js";
|
|
1
|
+
import { getModuleClass } from "../util/css.js";
|
|
4
2
|
import TYPOGRAPHY_CSS from "./Typography.module.css";
|
|
5
|
-
import { getWeightClass } from "./Weight.js";
|
|
6
3
|
/**
|
|
7
4
|
* Get the typography class for a component from its typographic variant props.
|
|
8
5
|
*
|
|
9
|
-
*
|
|
6
|
+
* Maps the size, weight, font, case, tint, alignment, and wrap variant props to their CSS classes.
|
|
10
7
|
*
|
|
11
|
-
* @param variants
|
|
12
8
|
* @returns The combined typography class string, or `undefined` when no variants apply.
|
|
13
9
|
* @example getTypographyClass({ font: "title", size: "large", center: true })
|
|
14
10
|
* @see https://dhoulb.github.io/shelving/ui/style/Typography/getTypographyClass
|
|
15
11
|
*/
|
|
16
|
-
export function getTypographyClass({ tint, ...props }) {
|
|
17
|
-
return
|
|
12
|
+
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);
|
|
18
14
|
}
|
|
@@ -1,7 +1,170 @@
|
|
|
1
1
|
@import "layers.css";
|
|
2
2
|
@import "Tint.module.css";
|
|
3
3
|
|
|
4
|
+
@layer defaults {
|
|
5
|
+
:root {
|
|
6
|
+
/* Font faces */
|
|
7
|
+
--font-sans: system-ui;
|
|
8
|
+
--font-monospace: ui-monospace, "SF Mono", "Consolas", "Menlo", monospace;
|
|
9
|
+
--font-serif: "Palatino", "Garamond", serif;
|
|
10
|
+
|
|
11
|
+
/* Semantic font faces */
|
|
12
|
+
--font-title: var(--font-sans);
|
|
13
|
+
--font-body: var(--font-sans);
|
|
14
|
+
--font-label: var(--font-sans);
|
|
15
|
+
--font-code: var(--font-monospace);
|
|
16
|
+
|
|
17
|
+
/* Font weights */
|
|
18
|
+
--weight-normal: 400;
|
|
19
|
+
--weight-strong: 700;
|
|
20
|
+
|
|
21
|
+
/* Semantic font weights */
|
|
22
|
+
--weight-title: var(--weight-strong);
|
|
23
|
+
--weight-body: var(--weight-normal);
|
|
24
|
+
--weight-label: var(--weight-strong);
|
|
25
|
+
--weight-code: 500;
|
|
26
|
+
|
|
27
|
+
/* Sizings */
|
|
28
|
+
--size-scale: 1.25;
|
|
29
|
+
--size-xxsmall: calc(var(--size-normal) * pow(var(--size-scale), -3));
|
|
30
|
+
--size-xsmall: calc(var(--size-normal) * pow(var(--size-scale), -2));
|
|
31
|
+
--size-small: calc(var(--size-normal) * pow(var(--size-scale), -1));
|
|
32
|
+
--size-normal: 1rem;
|
|
33
|
+
--size-large: calc(var(--size-normal) * pow(var(--size-scale), 1));
|
|
34
|
+
--size-xlarge: calc(var(--size-normal) * pow(var(--size-scale), 2));
|
|
35
|
+
--size-xxlarge: calc(var(--size-normal) * pow(var(--size-scale), 3));
|
|
36
|
+
--size-xxxlarge: calc(var(--size-normal) * pow(var(--size-scale), 4));
|
|
37
|
+
|
|
38
|
+
/* Semantic sizes */
|
|
39
|
+
--size-icon: var(--size-large);
|
|
40
|
+
--size-label: var(--size-small);
|
|
41
|
+
|
|
42
|
+
/* Relative sizes */
|
|
43
|
+
--size-smaller: 0.875em;
|
|
44
|
+
--size-larger: 1.5em;
|
|
45
|
+
--size-xlarger: 2.5em;
|
|
46
|
+
--size-xxlarger: 5em;
|
|
47
|
+
|
|
48
|
+
/* Line heights */
|
|
49
|
+
--leading: clamp(1.05em, calc(1em + 0.5rem), 1.5em);
|
|
50
|
+
--leading-normal: 1.5;
|
|
51
|
+
|
|
52
|
+
/* Semantic cases */
|
|
53
|
+
--case-title: none;
|
|
54
|
+
--case-body: none;
|
|
55
|
+
--case-label: uppercase;
|
|
56
|
+
--case-code: none;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
body {
|
|
60
|
+
font-family: var(--font-body);
|
|
61
|
+
font-weight: var(--weight-body);
|
|
62
|
+
font-size: var(--size-normal);
|
|
63
|
+
line-height: var(--leading);
|
|
64
|
+
text-align: start;
|
|
65
|
+
text-transform: var(--case-body);
|
|
66
|
+
color: var(--tint-00);
|
|
67
|
+
background-color: var(--tint-100);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
4
71
|
@layer variants {
|
|
72
|
+
/* Font-size variants. */
|
|
73
|
+
.size-xxsmall {
|
|
74
|
+
font-size: var(--size-xxsmall);
|
|
75
|
+
line-height: var(--leading);
|
|
76
|
+
}
|
|
77
|
+
.size-xsmall {
|
|
78
|
+
font-size: var(--size-xsmall);
|
|
79
|
+
line-height: var(--leading);
|
|
80
|
+
}
|
|
81
|
+
.size-small {
|
|
82
|
+
font-size: var(--size-small);
|
|
83
|
+
line-height: var(--leading);
|
|
84
|
+
}
|
|
85
|
+
.size-normal {
|
|
86
|
+
font-size: var(--size-normal);
|
|
87
|
+
line-height: var(--leading);
|
|
88
|
+
}
|
|
89
|
+
.size-large {
|
|
90
|
+
font-size: var(--size-large);
|
|
91
|
+
line-height: var(--leading);
|
|
92
|
+
}
|
|
93
|
+
.size-xlarge {
|
|
94
|
+
font-size: var(--size-xlarge);
|
|
95
|
+
line-height: var(--leading);
|
|
96
|
+
}
|
|
97
|
+
.size-xxlarge {
|
|
98
|
+
font-size: var(--size-xxlarge);
|
|
99
|
+
line-height: var(--leading);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* Font-family variants. */
|
|
103
|
+
.font-title {
|
|
104
|
+
font-family: var(--font-title);
|
|
105
|
+
}
|
|
106
|
+
.font-body {
|
|
107
|
+
font-family: var(--font-body);
|
|
108
|
+
}
|
|
109
|
+
.font-code {
|
|
110
|
+
font-family: var(--font-code);
|
|
111
|
+
}
|
|
112
|
+
.font-label {
|
|
113
|
+
font-family: var(--font-label);
|
|
114
|
+
}
|
|
115
|
+
.font-sans {
|
|
116
|
+
font-family: var(--font-sans);
|
|
117
|
+
}
|
|
118
|
+
.font-serif {
|
|
119
|
+
font-family: var(--font-serif);
|
|
120
|
+
}
|
|
121
|
+
.font-monospace {
|
|
122
|
+
font-family: var(--font-monospace);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* Font-weight variants. */
|
|
126
|
+
.weight-title {
|
|
127
|
+
font-weight: var(--weight-title);
|
|
128
|
+
}
|
|
129
|
+
.weight-body {
|
|
130
|
+
font-weight: var(--weight-body);
|
|
131
|
+
}
|
|
132
|
+
.weight-code {
|
|
133
|
+
font-weight: var(--weight-code);
|
|
134
|
+
}
|
|
135
|
+
.weight-label {
|
|
136
|
+
font-weight: var(--weight-label);
|
|
137
|
+
}
|
|
138
|
+
.weight-normal {
|
|
139
|
+
font-weight: var(--weight-normal);
|
|
140
|
+
}
|
|
141
|
+
.weight-strong {
|
|
142
|
+
font-weight: var(--weight-strong);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* Font-case variants. */
|
|
146
|
+
.case-title {
|
|
147
|
+
text-transform: var(--case-title);
|
|
148
|
+
}
|
|
149
|
+
.case-body {
|
|
150
|
+
text-transform: var(--case-body);
|
|
151
|
+
}
|
|
152
|
+
.case-code {
|
|
153
|
+
text-transform: var(--case-code);
|
|
154
|
+
}
|
|
155
|
+
.case-label {
|
|
156
|
+
text-transform: var(--case-label);
|
|
157
|
+
}
|
|
158
|
+
.case-upper {
|
|
159
|
+
text-transform: uppercase;
|
|
160
|
+
}
|
|
161
|
+
.case-lower {
|
|
162
|
+
text-transform: lowercase;
|
|
163
|
+
}
|
|
164
|
+
.case-normal {
|
|
165
|
+
text-transform: none;
|
|
166
|
+
}
|
|
167
|
+
|
|
5
168
|
/* Text tint variants — set CSS `color:` to a shade of the current tint ladder. */
|
|
6
169
|
.tint-00 {
|
|
7
170
|
color: var(--tint-00);
|
package/ui/style/Typography.tsx
CHANGED
|
@@ -1,92 +1,80 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { getSizeClass, type SizeVariants } from "./Size.js";
|
|
1
|
+
import { getModuleClass } from "../util/css.js";
|
|
2
|
+
import type { TintVariant } from "./Tint.js";
|
|
4
3
|
import TYPOGRAPHY_CSS from "./Typography.module.css";
|
|
5
|
-
import { getWeightClass, type WeightVariants } from "./Weight.js";
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
|
-
*
|
|
9
|
-
* - Can be applied as the text `color:` for components that support `TypographyVariants`
|
|
6
|
+
* Allowed values for font size for components that support `TypographyVariants`
|
|
10
7
|
*
|
|
11
|
-
* @see https://dhoulb.github.io/shelving/ui/style/Typography/
|
|
8
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Typography/SizeVariant
|
|
12
9
|
*/
|
|
13
|
-
export type
|
|
14
|
-
| "00"
|
|
15
|
-
| "05"
|
|
16
|
-
| "10"
|
|
17
|
-
| "15"
|
|
18
|
-
| "20"
|
|
19
|
-
| "25"
|
|
20
|
-
| "30"
|
|
21
|
-
| "35"
|
|
22
|
-
| "40"
|
|
23
|
-
| "45"
|
|
24
|
-
| "50"
|
|
25
|
-
| "55"
|
|
26
|
-
| "60"
|
|
27
|
-
| "65"
|
|
28
|
-
| "70"
|
|
29
|
-
| "75"
|
|
30
|
-
| "80"
|
|
31
|
-
| "85"
|
|
32
|
-
| "90"
|
|
33
|
-
| "95"
|
|
34
|
-
| "100";
|
|
10
|
+
export type SizeVariant = "xxsmall" | "xsmall" | "small" | "normal" | "large" | "xlarge" | "xxlarge";
|
|
35
11
|
|
|
36
12
|
/**
|
|
37
|
-
*
|
|
13
|
+
* Allowed values for font weight for components that support `TypographyVariants`
|
|
38
14
|
*
|
|
39
|
-
* @see https://dhoulb.github.io/shelving/ui/style/Typography/
|
|
15
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Typography/WeightVariant
|
|
40
16
|
*/
|
|
41
|
-
export type
|
|
42
|
-
/** Align text to the start of the line (LTR: left). */
|
|
43
|
-
left?: boolean | undefined;
|
|
44
|
-
/** Centre text horizontally. */
|
|
45
|
-
center?: boolean | undefined;
|
|
46
|
-
/** Align text to the end of the line (LTR: right). */
|
|
47
|
-
right?: boolean | undefined;
|
|
48
|
-
};
|
|
17
|
+
export type WeightVariant = "title" | "body" | "label" | "code" | "normal" | "strong";
|
|
49
18
|
|
|
50
19
|
/**
|
|
51
|
-
*
|
|
20
|
+
* Allowed values for text case for components that support `TypographyVariants`
|
|
52
21
|
*
|
|
53
|
-
* @see https://dhoulb.github.io/shelving/ui/style/Typography/
|
|
22
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Typography/CaseVariant
|
|
54
23
|
*/
|
|
55
|
-
export type
|
|
56
|
-
/** Enable wrapping. */
|
|
57
|
-
wrap?: boolean | undefined;
|
|
58
|
-
/** Disable wrapping. */
|
|
59
|
-
nowrap?: boolean | undefined;
|
|
60
|
-
};
|
|
24
|
+
export type CaseVariant = "title" | "body" | "label" | "code" | "upper" | "lower" | "normal";
|
|
61
25
|
|
|
62
26
|
/**
|
|
63
|
-
*
|
|
27
|
+
* Allowed values for font family for components that support `TypographyVariants`
|
|
64
28
|
*
|
|
65
|
-
*
|
|
66
|
-
|
|
29
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Typography/FontVariant
|
|
30
|
+
*/
|
|
31
|
+
export type FontVariant = "title" | "body" | "label" | "code" | "serif" | "sans" | "monospace";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Typographic variant props — font-family, weight, case, size, tint, alignment, and wrap, applied via `getTypographyClass()`
|
|
67
35
|
*
|
|
68
36
|
* @see https://dhoulb.github.io/shelving/ui/style/Typography/TypographyVariants
|
|
69
37
|
*/
|
|
70
|
-
export interface TypographyVariants
|
|
38
|
+
export interface TypographyVariants {
|
|
39
|
+
/** Font size of the element. */
|
|
40
|
+
size?: SizeVariant | undefined;
|
|
71
41
|
/** Set CSS text `color:` to one of the shades of the current tint ladder. */
|
|
72
42
|
tint?: TintVariant | undefined;
|
|
43
|
+
/** Font family of the element. */
|
|
44
|
+
font?: FontVariant | undefined;
|
|
45
|
+
/** Text case of the element. */
|
|
46
|
+
case?: CaseVariant | undefined;
|
|
47
|
+
/** Font weight of the element. */
|
|
48
|
+
weight?: WeightVariant | undefined;
|
|
49
|
+
/** Align text to the start of the line (LTR: left). */
|
|
50
|
+
left?: boolean | undefined;
|
|
51
|
+
/** Centre text horizontally. */
|
|
52
|
+
center?: boolean | undefined;
|
|
53
|
+
/** Align text to the end of the line (LTR: right). */
|
|
54
|
+
right?: boolean | undefined;
|
|
55
|
+
/** Enable wrapping. */
|
|
56
|
+
wrap?: boolean | undefined;
|
|
57
|
+
/** Disable wrapping. */
|
|
58
|
+
nowrap?: boolean | undefined;
|
|
73
59
|
}
|
|
74
60
|
|
|
75
61
|
/**
|
|
76
62
|
* Get the typography class for a component from its typographic variant props.
|
|
77
63
|
*
|
|
78
|
-
*
|
|
64
|
+
* Maps the size, weight, font, case, tint, alignment, and wrap variant props to their CSS classes.
|
|
79
65
|
*
|
|
80
|
-
* @param variants
|
|
81
66
|
* @returns The combined typography class string, or `undefined` when no variants apply.
|
|
82
67
|
* @example getTypographyClass({ font: "title", size: "large", center: true })
|
|
83
68
|
* @see https://dhoulb.github.io/shelving/ui/style/Typography/getTypographyClass
|
|
84
69
|
*/
|
|
85
|
-
export function getTypographyClass({ tint, ...props }: TypographyVariants): string | undefined {
|
|
86
|
-
return
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
70
|
+
export function getTypographyClass({ tint, weight, font, case: caseValue, size, ...props }: TypographyVariants): string | undefined {
|
|
71
|
+
return getModuleClass(
|
|
72
|
+
TYPOGRAPHY_CSS,
|
|
73
|
+
caseValue && `case-${caseValue}`,
|
|
74
|
+
tint && `tint-${tint}`,
|
|
75
|
+
weight && `weight-${weight}`,
|
|
76
|
+
font && `font-${font}`,
|
|
77
|
+
size && `size-${size}`,
|
|
78
|
+
props,
|
|
91
79
|
);
|
|
92
80
|
}
|
|
@@ -4,15 +4,14 @@ This module's main job is to **define and document the corner-radius design toke
|
|
|
4
4
|
|
|
5
5
|
## Theme variables
|
|
6
6
|
|
|
7
|
-
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. Every step derives from `--radius`, so changing that one value reflows the whole ramp.
|
|
7
|
+
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. Every step derives from `--radius-normal`, so changing that one value reflows the whole ramp.
|
|
8
8
|
|
|
9
9
|
| Variable | Default | Notes |
|
|
10
10
|
|---|---|---|
|
|
11
|
-
| `--radius` | `
|
|
12
|
-
| `--radius-
|
|
13
|
-
| `--radius-
|
|
14
|
-
| `--radius-
|
|
15
|
-
| `--radius-
|
|
16
|
-
| `--radius-
|
|
17
|
-
| `--radius-
|
|
18
|
-
| `--radius-xxlarge` | `calc(var(--radius) * 3)` | 48px |
|
|
11
|
+
| `--radius-xxsmall` | `calc(var(--radius-normal) * 0.25)` | 4px |
|
|
12
|
+
| `--radius-xsmall` | `calc(var(--radius-normal) * 0.5)` | 8px |
|
|
13
|
+
| `--radius-small` | `calc(var(--radius-normal) * 0.75)` | 12px |
|
|
14
|
+
| `--radius-normal` | `var(--radius-normal)` | 16px — Base radius (the root of the scale) |
|
|
15
|
+
| `--radius-large` | `calc(var(--radius-normal) * 1.5)` | 24px |
|
|
16
|
+
| `--radius-xlarge` | `calc(var(--radius-normal) * 2)` | 32px |
|
|
17
|
+
| `--radius-xxlarge` | `calc(var(--radius-normal) * 3)` | 48px |
|