shelving 1.237.0 → 1.239.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 +27 -4
- package/ui/app/App.d.ts +13 -2
- package/ui/app/App.js +15 -2
- package/ui/app/App.tsx +15 -2
- package/ui/block/Address.module.css +2 -1
- package/ui/block/Block.module.css +1 -1
- package/ui/block/Blockquote.module.css +5 -1
- package/ui/block/Caption.module.css +4 -1
- package/ui/block/Card.md +1 -1
- package/ui/block/Card.module.css +7 -1
- package/ui/block/Definitions.module.css +6 -1
- package/ui/block/Divider.module.css +4 -1
- package/ui/block/Heading.md +1 -1
- package/ui/block/Heading.module.css +5 -1
- package/ui/block/Image.module.css +2 -1
- package/ui/block/Label.module.css +6 -1
- package/ui/block/List.md +1 -1
- package/ui/block/List.module.css +2 -1
- package/ui/block/Panel.d.ts +6 -5
- package/ui/block/Panel.js +6 -5
- package/ui/block/Panel.md +1 -1
- package/ui/block/Panel.module.css +7 -5
- package/ui/block/Panel.tsx +7 -5
- package/ui/block/Paragraph.md +1 -1
- package/ui/block/Paragraph.module.css +2 -1
- package/ui/block/Preformatted.module.css +10 -1
- package/ui/block/Prose.md +1 -1
- package/ui/block/Prose.module.css +2 -1
- package/ui/block/Section.md +1 -1
- package/ui/block/Section.module.css +2 -1
- package/ui/block/Subheading.md +1 -1
- package/ui/block/Subheading.module.css +5 -1
- package/ui/block/Table.md +1 -1
- package/ui/block/Table.module.css +7 -1
- package/ui/block/Title.md +1 -1
- package/ui/block/Title.module.css +5 -1
- package/ui/block/Video.module.css +7 -1
- package/ui/dialog/Dialog.md +1 -1
- package/ui/dialog/Dialog.module.css +4 -1
- package/ui/dialog/Modal.md +2 -2
- package/ui/dialog/Modal.module.css +8 -1
- package/ui/docs/DocumentationHomePage.d.ts +15 -0
- package/ui/docs/DocumentationHomePage.js +24 -0
- package/ui/docs/DocumentationHomePage.md +42 -0
- package/ui/docs/DocumentationHomePage.test.tsx +35 -0
- package/ui/docs/DocumentationHomePage.tsx +46 -0
- package/ui/docs/index.d.ts +1 -0
- package/ui/docs/index.js +1 -0
- package/ui/docs/index.ts +1 -0
- package/ui/form/Button.md +1 -1
- package/ui/form/Button.module.css +10 -1
- package/ui/form/Field.md +1 -1
- package/ui/form/Field.module.css +6 -1
- package/ui/form/Form.md +1 -1
- package/ui/form/Form.module.css +2 -1
- package/ui/form/Input.module.css +10 -2
- package/ui/form/Popover.module.css +6 -1
- package/ui/form/Progress.module.css +4 -1
- package/ui/inline/Code.md +2 -2
- package/ui/inline/Code.module.css +7 -1
- package/ui/inline/Deleted.module.css +4 -1
- package/ui/inline/Emphasis.module.css +1 -1
- package/ui/inline/Inserted.module.css +4 -1
- package/ui/inline/Link.md +2 -2
- package/ui/inline/Link.module.css +4 -2
- package/ui/inline/Mark.md +1 -1
- package/ui/inline/Mark.module.css +3 -1
- package/ui/inline/Small.module.css +2 -1
- package/ui/inline/Strong.md +1 -1
- package/ui/inline/Strong.module.css +2 -1
- package/ui/inline/Subscript.module.css +1 -1
- package/ui/inline/Superscript.module.css +1 -1
- package/ui/layout/CenteredLayout.md +2 -2
- package/ui/layout/CenteredLayout.module.css +2 -1
- package/ui/layout/Layout.module.css +4 -2
- package/ui/layout/SidebarLayout.md +1 -1
- package/ui/layout/SidebarLayout.module.css +5 -1
- package/ui/menu/Menu.md +1 -1
- package/ui/menu/Menu.module.css +9 -1
- package/ui/menu/MenuItem.md +1 -1
- package/ui/misc/Loading.module.css +3 -1
- package/ui/misc/StatusIcon.module.css +2 -1
- package/ui/misc/Tag.md +1 -1
- package/ui/misc/Tag.module.css +9 -1
- package/ui/notice/Message.module.css +3 -1
- package/ui/notice/Notice.md +1 -1
- package/ui/notice/Notice.module.css +7 -1
- package/ui/notice/Notices.module.css +3 -1
- package/ui/style/Color.module.css +28 -1
- package/ui/style/Duration.d.ts +24 -0
- package/ui/style/Duration.js +13 -0
- package/ui/style/Duration.module.css +23 -0
- package/ui/style/Duration.tsx +31 -0
- package/ui/style/Flex.module.css +3 -1
- package/ui/style/Font.d.ts +24 -0
- package/ui/style/Font.js +13 -0
- package/ui/style/Font.module.css +50 -0
- package/ui/style/Font.tsx +31 -0
- package/ui/style/Gap.module.css +2 -1
- package/ui/style/Padding.module.css +2 -1
- package/ui/style/Radius.d.ts +24 -0
- package/ui/style/Radius.js +13 -0
- package/ui/style/Radius.module.css +43 -0
- package/ui/style/Radius.tsx +31 -0
- package/ui/style/Scroll.module.css +4 -0
- package/ui/style/Shadow.d.ts +24 -0
- package/ui/style/Shadow.js +13 -0
- package/ui/style/Shadow.module.css +42 -0
- package/ui/style/Shadow.tsx +31 -0
- package/ui/style/Size.d.ts +24 -0
- package/ui/style/Size.js +13 -0
- package/ui/style/Size.module.css +69 -0
- package/ui/style/Size.tsx +31 -0
- package/ui/style/Space.module.css +19 -1
- package/ui/style/Status.module.css +2 -1
- package/ui/style/Stroke.d.ts +24 -0
- package/ui/style/Stroke.js +13 -0
- package/ui/style/Stroke.module.css +26 -0
- package/ui/style/Stroke.tsx +31 -0
- package/ui/style/Tint.module.css +4 -1
- package/ui/style/Typography.d.ts +10 -26
- package/ui/style/Typography.js +8 -3
- package/ui/style/Typography.module.css +2 -66
- package/ui/style/Typography.tsx +17 -31
- package/ui/style/Weight.d.ts +24 -0
- package/ui/style/Weight.js +13 -0
- package/ui/style/Weight.module.css +42 -0
- package/ui/style/Weight.tsx +31 -0
- package/ui/style/Width.module.css +7 -1
- package/ui/style/getColorClass.md +47 -0
- package/ui/style/getDurationClass.md +18 -0
- package/ui/style/getFontClass.md +39 -0
- package/ui/style/getRadiusClass.md +24 -0
- package/ui/style/getShadowClass.md +23 -0
- package/ui/style/getSizeClass.md +42 -0
- package/ui/style/getSpaceClass.md +35 -0
- package/ui/style/getStrokeClass.md +20 -0
- package/ui/style/getWeightClass.md +25 -0
- package/ui/style/getWidthClass.md +18 -0
- package/ui/style/index.d.ts +7 -0
- package/ui/style/index.js +7 -0
- package/ui/style/index.tsx +7 -0
- package/ui/style/layers.css +26 -0
- package/ui/transition/FadeTransition.md +1 -1
- package/ui/transition/HorizontalTransition.md +1 -1
- package/ui/transition/Transition.md +1 -1
- package/ui/transition/VerticalTransition.md +1 -1
- package/ui/style/base.css +0 -161
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getModuleClass } from "../util/css.js";
|
|
2
|
+
import SIZE_CSS from "./Size.module.css";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Enumerated font-size scale selectable via the `size` variant prop.
|
|
6
|
+
*
|
|
7
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Size/UISize
|
|
8
|
+
*/
|
|
9
|
+
export type UISize = "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?: UISize | undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get the font-size class for a component from its `size` variant prop.
|
|
23
|
+
*
|
|
24
|
+
* @param variants Variant props containing the optional `size` scale.
|
|
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,4 +1,22 @@
|
|
|
1
|
-
@import "
|
|
1
|
+
@import "layers.css";
|
|
2
|
+
|
|
3
|
+
@layer defaults {
|
|
4
|
+
:root {
|
|
5
|
+
/* Spacings */
|
|
6
|
+
--space: 1rem;
|
|
7
|
+
--space-xxsmall: calc(var(--space) * 0.25); /* 4px */
|
|
8
|
+
--space-xsmall: calc(var(--space) * 0.5); /* 8px */
|
|
9
|
+
--space-small: calc(var(--space) * 0.75); /* 12px */
|
|
10
|
+
--space-normal: calc(var(--space) * 1); /* 16px */
|
|
11
|
+
--space-large: calc(var(--space) * 1.5); /* 24px */
|
|
12
|
+
--space-xlarge: calc(var(--space) * 2); /* 32px */
|
|
13
|
+
--space-xxlarge: calc(var(--space) * 3); /* 48px */
|
|
14
|
+
|
|
15
|
+
/* Semantic spacings */
|
|
16
|
+
--space-section: 2rem; /* Default top margin for titles/headings/section blocks. */
|
|
17
|
+
--space-paragraph: var(--space-normal); /* Default block-space for most prose-level elements. */
|
|
18
|
+
}
|
|
19
|
+
}
|
|
2
20
|
|
|
3
21
|
@layer variants {
|
|
4
22
|
/* Block-space variants — opt-in margin-block modifiers for any block-level component. */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enumerated border-thickness names selectable via the `stroke` variant prop.
|
|
3
|
+
*
|
|
4
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Stroke/UIStroke
|
|
5
|
+
*/
|
|
6
|
+
export type UIStroke = "normal" | "thick";
|
|
7
|
+
/**
|
|
8
|
+
* Variant props for the border thickness of an element, e.g. `stroke="thick"`.
|
|
9
|
+
*
|
|
10
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Stroke/StrokeVariants
|
|
11
|
+
*/
|
|
12
|
+
export interface StrokeVariants {
|
|
13
|
+
/** Border thickness of the element. */
|
|
14
|
+
stroke?: UIStroke | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get the border-thickness class for a component from its `stroke` variant prop.
|
|
18
|
+
*
|
|
19
|
+
* @param variants Variant props containing the optional `stroke` name.
|
|
20
|
+
* @returns The stroke class string, or `undefined` when no `stroke` is set.
|
|
21
|
+
* @example getStrokeClass({ stroke: "thick" }) // "stroke-thick"
|
|
22
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Stroke/getStrokeClass
|
|
23
|
+
*/
|
|
24
|
+
export declare function getStrokeClass({ stroke }: StrokeVariants): string | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getModuleClass } from "../util/css.js";
|
|
2
|
+
import STROKE_CSS from "./Stroke.module.css";
|
|
3
|
+
/**
|
|
4
|
+
* Get the border-thickness class for a component from its `stroke` variant prop.
|
|
5
|
+
*
|
|
6
|
+
* @param variants Variant props containing the optional `stroke` name.
|
|
7
|
+
* @returns The stroke class string, or `undefined` when no `stroke` is set.
|
|
8
|
+
* @example getStrokeClass({ stroke: "thick" }) // "stroke-thick"
|
|
9
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Stroke/getStrokeClass
|
|
10
|
+
*/
|
|
11
|
+
export function getStrokeClass({ stroke }) {
|
|
12
|
+
return stroke && getModuleClass(STROKE_CSS, `stroke-${stroke}`);
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
@import "layers.css";
|
|
2
|
+
|
|
3
|
+
@layer defaults {
|
|
4
|
+
:root {
|
|
5
|
+
/* Strokes — border thicknesses. Components hard-code to these and expose per-component
|
|
6
|
+
* `--x-border` / `--x-stroke` hooks to override. */
|
|
7
|
+
--stroke: 2px;
|
|
8
|
+
--stroke-normal: calc(var(--stroke) * 1);
|
|
9
|
+
--stroke-thick: calc(var(--stroke) * 1.5);
|
|
10
|
+
|
|
11
|
+
/* Semantic strokes */
|
|
12
|
+
--stroke-focus: var(--stroke-thick);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@layer variants {
|
|
17
|
+
/* Border-thickness variants. */
|
|
18
|
+
.stroke-normal {
|
|
19
|
+
border-style: solid;
|
|
20
|
+
border-width: var(--stroke-normal);
|
|
21
|
+
}
|
|
22
|
+
.stroke-thick {
|
|
23
|
+
border-style: solid;
|
|
24
|
+
border-width: var(--stroke-thick);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getModuleClass } from "../util/css.js";
|
|
2
|
+
import STROKE_CSS from "./Stroke.module.css";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Enumerated border-thickness names selectable via the `stroke` variant prop.
|
|
6
|
+
*
|
|
7
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Stroke/UIStroke
|
|
8
|
+
*/
|
|
9
|
+
export type UIStroke = "normal" | "thick";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Variant props for the border thickness of an element, e.g. `stroke="thick"`.
|
|
13
|
+
*
|
|
14
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Stroke/StrokeVariants
|
|
15
|
+
*/
|
|
16
|
+
export interface StrokeVariants {
|
|
17
|
+
/** Border thickness of the element. */
|
|
18
|
+
stroke?: UIStroke | undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get the border-thickness class for a component from its `stroke` variant prop.
|
|
23
|
+
*
|
|
24
|
+
* @param variants Variant props containing the optional `stroke` name.
|
|
25
|
+
* @returns The stroke class string, or `undefined` when no `stroke` is set.
|
|
26
|
+
* @example getStrokeClass({ stroke: "thick" }) // "stroke-thick"
|
|
27
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Stroke/getStrokeClass
|
|
28
|
+
*/
|
|
29
|
+
export function getStrokeClass({ stroke }: StrokeVariants): string | undefined {
|
|
30
|
+
return stroke && getModuleClass(STROKE_CSS, `stroke-${stroke}`);
|
|
31
|
+
}
|
package/ui/style/Tint.module.css
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
@import "layers.css";
|
|
2
|
+
|
|
1
3
|
@layer defaults {
|
|
2
4
|
:root {
|
|
3
|
-
/* Main tint color — the `50` tint is used to calculate all the other shades.
|
|
5
|
+
/* Main tint color — the `50` tint is used to calculate all the other shades.
|
|
6
|
+
* Defaults to `--color-gray` (defined in Color.module.css), resolved at use-time. */
|
|
4
7
|
--tint-50: var(--color-gray);
|
|
5
8
|
}
|
|
6
9
|
|
package/ui/style/Typography.d.ts
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* @see https://dhoulb.github.io/shelving/ui/style/Typography/UISize
|
|
5
|
-
*/
|
|
6
|
-
export type UISize = "xxsmall" | "xsmall" | "small" | "normal" | "large" | "xlarge" | "xxlarge";
|
|
7
|
-
/**
|
|
8
|
-
* Enumerated font-family names selectable via the `font` variant prop.
|
|
9
|
-
*
|
|
10
|
-
* @see https://dhoulb.github.io/shelving/ui/style/Typography/UIFont
|
|
11
|
-
*/
|
|
12
|
-
export type UIFont = "title" | "body" | "label" | "code" | "serif" | "sans" | "monospace";
|
|
13
|
-
/**
|
|
14
|
-
* Enumerated font-weight names selectable via the `weight` variant prop.
|
|
15
|
-
*
|
|
16
|
-
* @see https://dhoulb.github.io/shelving/ui/style/Typography/UIWeight
|
|
17
|
-
*/
|
|
18
|
-
export type UIWeight = "title" | "body" | "label" | "code" | "normal" | "strong";
|
|
1
|
+
import { type FontVariants } from "./Font.js";
|
|
2
|
+
import { type SizeVariants } from "./Size.js";
|
|
3
|
+
import { type WeightVariants } from "./Weight.js";
|
|
19
4
|
/**
|
|
20
5
|
* Enumerated tint shades selectable via the `tint` variant prop — shades of the current tint colour from `"00"` (black) through `"50"` (the hue itself) to `"100"` (white).
|
|
21
6
|
*
|
|
@@ -38,24 +23,23 @@ export type AlignVariants = {
|
|
|
38
23
|
/**
|
|
39
24
|
* Typographic variant props — font-family, weight, alignment, size, and tint.
|
|
40
25
|
*
|
|
26
|
+
* Combines the focused {@link SizeVariants}, {@link WeightVariants}, and {@link FontVariants} interfaces (each backed
|
|
27
|
+
* by its own CSS module) with text alignment and tint colour.
|
|
28
|
+
*
|
|
41
29
|
* @see https://dhoulb.github.io/shelving/ui/style/Typography/TypographyVariants
|
|
42
30
|
*/
|
|
43
|
-
export interface TypographyVariants extends AlignVariants {
|
|
44
|
-
/** Font family. */
|
|
45
|
-
font?: UIFont | undefined;
|
|
46
|
-
/** Font weight */
|
|
47
|
-
weight?: UIWeight | undefined;
|
|
48
|
-
/** Font size of the element. */
|
|
49
|
-
size?: UISize | undefined;
|
|
31
|
+
export interface TypographyVariants extends AlignVariants, SizeVariants, WeightVariants, FontVariants {
|
|
50
32
|
/** Set CSS text `color:` to one of the shades of the current tint colour (defaults to gray). */
|
|
51
33
|
tint?: UITint | undefined;
|
|
52
34
|
}
|
|
53
35
|
/**
|
|
54
36
|
* Get the typography class for a component from its typographic variant props.
|
|
55
37
|
*
|
|
38
|
+
* Composes the focused size, weight, and font helpers with text alignment and tint colour.
|
|
39
|
+
*
|
|
56
40
|
* @param props Typographic variant props (font, weight, size, tint, alignment).
|
|
57
41
|
* @returns The combined typography class string, or `undefined` when no variants apply.
|
|
58
42
|
* @example getTypographyClass({ font: "title", size: "large", center: true })
|
|
59
43
|
* @see https://dhoulb.github.io/shelving/ui/style/Typography/getTypographyClass
|
|
60
44
|
*/
|
|
61
|
-
export declare function getTypographyClass({ tint,
|
|
45
|
+
export declare function getTypographyClass({ tint, ...props }: TypographyVariants): string | undefined;
|
package/ui/style/Typography.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { getModuleClass } from "../util/css.js";
|
|
1
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
2
|
+
import { getFontClass } from "./Font.js";
|
|
3
|
+
import { getSizeClass } from "./Size.js";
|
|
2
4
|
import TYPOGRAPHY_CSS from "./Typography.module.css";
|
|
5
|
+
import { getWeightClass } from "./Weight.js";
|
|
3
6
|
/**
|
|
4
7
|
* Get the typography class for a component from its typographic variant props.
|
|
5
8
|
*
|
|
9
|
+
* Composes the focused size, weight, and font helpers with text alignment and tint colour.
|
|
10
|
+
*
|
|
6
11
|
* @param props Typographic variant props (font, weight, size, tint, alignment).
|
|
7
12
|
* @returns The combined typography class string, or `undefined` when no variants apply.
|
|
8
13
|
* @example getTypographyClass({ font: "title", size: "large", center: true })
|
|
9
14
|
* @see https://dhoulb.github.io/shelving/ui/style/Typography/getTypographyClass
|
|
10
15
|
*/
|
|
11
|
-
export function getTypographyClass({ tint,
|
|
12
|
-
return getModuleClass(TYPOGRAPHY_CSS, tint && `tint-${tint}`,
|
|
16
|
+
export function getTypographyClass({ tint, ...props }) {
|
|
17
|
+
return getClass(getSizeClass(props), getWeightClass(props), getFontClass(props), getModuleClass(TYPOGRAPHY_CSS, tint && `tint-${tint}`, props));
|
|
13
18
|
}
|
|
@@ -1,72 +1,8 @@
|
|
|
1
|
-
@import "
|
|
1
|
+
@import "layers.css";
|
|
2
2
|
@import "Tint.module.css";
|
|
3
3
|
|
|
4
4
|
@layer variants {
|
|
5
|
-
/*
|
|
6
|
-
.title {
|
|
7
|
-
font-family: var(--font-heading);
|
|
8
|
-
}
|
|
9
|
-
.body {
|
|
10
|
-
font-family: var(--font-body);
|
|
11
|
-
}
|
|
12
|
-
.code {
|
|
13
|
-
font-family: var(--font-code);
|
|
14
|
-
}
|
|
15
|
-
.label {
|
|
16
|
-
font-family: var(--font-code);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/* Font weight variants. */
|
|
20
|
-
.weight-title {
|
|
21
|
-
font-weight: var(--weight-heading);
|
|
22
|
-
}
|
|
23
|
-
.weight-body {
|
|
24
|
-
font-weight: var(--weight-body);
|
|
25
|
-
}
|
|
26
|
-
.weight-code {
|
|
27
|
-
font-weight: var(--weight-code);
|
|
28
|
-
}
|
|
29
|
-
.weight-label {
|
|
30
|
-
font-weight: var(--weight-code);
|
|
31
|
-
}
|
|
32
|
-
.weight-normal {
|
|
33
|
-
font-weight: var(--weight-normal);
|
|
34
|
-
}
|
|
35
|
-
.weight-strong {
|
|
36
|
-
font-weight: var(--weight-strong);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/* Font-size variants. */
|
|
40
|
-
.xxsmall {
|
|
41
|
-
font-size: var(--size-xxsmall);
|
|
42
|
-
line-height: var(--leading);
|
|
43
|
-
}
|
|
44
|
-
.xsmall {
|
|
45
|
-
font-size: var(--size-xsmall);
|
|
46
|
-
line-height: var(--leading);
|
|
47
|
-
}
|
|
48
|
-
.small {
|
|
49
|
-
font-size: var(--size-small);
|
|
50
|
-
line-height: var(--leading);
|
|
51
|
-
}
|
|
52
|
-
.normal {
|
|
53
|
-
font-size: var(--size-normal);
|
|
54
|
-
line-height: var(--leading);
|
|
55
|
-
}
|
|
56
|
-
.large {
|
|
57
|
-
font-size: var(--size-large);
|
|
58
|
-
line-height: var(--leading);
|
|
59
|
-
}
|
|
60
|
-
.xlarge {
|
|
61
|
-
font-size: var(--size-xlarge);
|
|
62
|
-
line-height: var(--leading);
|
|
63
|
-
}
|
|
64
|
-
.xxlarge {
|
|
65
|
-
font-size: var(--size-xxlarge);
|
|
66
|
-
line-height: var(--leading);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/* Text tint variants */
|
|
5
|
+
/* Text tint variants — set CSS `color:` to a shade of the current tint ladder. */
|
|
70
6
|
.tint-00 {
|
|
71
7
|
color: var(--tint-00);
|
|
72
8
|
}
|
package/ui/style/Typography.tsx
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
import { getModuleClass } from "../util/css.js";
|
|
1
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
2
|
+
import { type FontVariants, getFontClass } from "./Font.js";
|
|
3
|
+
import { getSizeClass, type SizeVariants } from "./Size.js";
|
|
2
4
|
import TYPOGRAPHY_CSS from "./Typography.module.css";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Enumerated font-size scale selectable via the `size` variant prop.
|
|
6
|
-
*
|
|
7
|
-
* @see https://dhoulb.github.io/shelving/ui/style/Typography/UISize
|
|
8
|
-
*/
|
|
9
|
-
export type UISize = "xxsmall" | "xsmall" | "small" | "normal" | "large" | "xlarge" | "xxlarge";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Enumerated font-family names selectable via the `font` variant prop.
|
|
13
|
-
*
|
|
14
|
-
* @see https://dhoulb.github.io/shelving/ui/style/Typography/UIFont
|
|
15
|
-
*/
|
|
16
|
-
export type UIFont = "title" | "body" | "label" | "code" | "serif" | "sans" | "monospace";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Enumerated font-weight names selectable via the `weight` variant prop.
|
|
20
|
-
*
|
|
21
|
-
* @see https://dhoulb.github.io/shelving/ui/style/Typography/UIWeight
|
|
22
|
-
*/
|
|
23
|
-
export type UIWeight = "title" | "body" | "label" | "code" | "normal" | "strong";
|
|
5
|
+
import { getWeightClass, type WeightVariants } from "./Weight.js";
|
|
24
6
|
|
|
25
7
|
/**
|
|
26
8
|
* Enumerated tint shades selectable via the `tint` variant prop — shades of the current tint colour from `"00"` (black) through `"50"` (the hue itself) to `"100"` (white).
|
|
@@ -67,15 +49,12 @@ export type AlignVariants = {
|
|
|
67
49
|
/**
|
|
68
50
|
* Typographic variant props — font-family, weight, alignment, size, and tint.
|
|
69
51
|
*
|
|
52
|
+
* Combines the focused {@link SizeVariants}, {@link WeightVariants}, and {@link FontVariants} interfaces (each backed
|
|
53
|
+
* by its own CSS module) with text alignment and tint colour.
|
|
54
|
+
*
|
|
70
55
|
* @see https://dhoulb.github.io/shelving/ui/style/Typography/TypographyVariants
|
|
71
56
|
*/
|
|
72
|
-
export interface TypographyVariants extends AlignVariants {
|
|
73
|
-
/** Font family. */
|
|
74
|
-
font?: UIFont | undefined;
|
|
75
|
-
/** Font weight */
|
|
76
|
-
weight?: UIWeight | undefined;
|
|
77
|
-
/** Font size of the element. */
|
|
78
|
-
size?: UISize | undefined;
|
|
57
|
+
export interface TypographyVariants extends AlignVariants, SizeVariants, WeightVariants, FontVariants {
|
|
79
58
|
/** Set CSS text `color:` to one of the shades of the current tint colour (defaults to gray). */
|
|
80
59
|
tint?: UITint | undefined;
|
|
81
60
|
}
|
|
@@ -83,11 +62,18 @@ export interface TypographyVariants extends AlignVariants {
|
|
|
83
62
|
/**
|
|
84
63
|
* Get the typography class for a component from its typographic variant props.
|
|
85
64
|
*
|
|
65
|
+
* Composes the focused size, weight, and font helpers with text alignment and tint colour.
|
|
66
|
+
*
|
|
86
67
|
* @param props Typographic variant props (font, weight, size, tint, alignment).
|
|
87
68
|
* @returns The combined typography class string, or `undefined` when no variants apply.
|
|
88
69
|
* @example getTypographyClass({ font: "title", size: "large", center: true })
|
|
89
70
|
* @see https://dhoulb.github.io/shelving/ui/style/Typography/getTypographyClass
|
|
90
71
|
*/
|
|
91
|
-
export function getTypographyClass({ tint,
|
|
92
|
-
return
|
|
72
|
+
export function getTypographyClass({ tint, ...props }: TypographyVariants): string | undefined {
|
|
73
|
+
return getClass(
|
|
74
|
+
getSizeClass(props),
|
|
75
|
+
getWeightClass(props),
|
|
76
|
+
getFontClass(props),
|
|
77
|
+
getModuleClass(TYPOGRAPHY_CSS, tint && `tint-${tint}`, props),
|
|
78
|
+
);
|
|
93
79
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enumerated font-weight names selectable via the `weight` variant prop.
|
|
3
|
+
*
|
|
4
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Weight/UIWeight
|
|
5
|
+
*/
|
|
6
|
+
export type UIWeight = "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?: UIWeight | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get the font-weight class for a component from its `weight` variant prop.
|
|
18
|
+
*
|
|
19
|
+
* @param variants Variant props containing the optional `weight` name.
|
|
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 Variant props containing the optional `weight` name.
|
|
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
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getModuleClass } from "../util/css.js";
|
|
2
|
+
import WEIGHT_CSS from "./Weight.module.css";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Enumerated font-weight names selectable via the `weight` variant prop.
|
|
6
|
+
*
|
|
7
|
+
* @see https://dhoulb.github.io/shelving/ui/style/Weight/UIWeight
|
|
8
|
+
*/
|
|
9
|
+
export type UIWeight = "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?: UIWeight | undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get the font-weight class for a component from its `weight` variant prop.
|
|
23
|
+
*
|
|
24
|
+
* @param variants Variant props containing the optional `weight` name.
|
|
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
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# getColorClass
|
|
2
|
+
|
|
3
|
+
The `color` variant prop moves the [tint ladder](/ui/TINT_CLASS) anchor to a named palette colour — `<Card color="red">`, `<Tag color="primary">`. It's an **override** for one-off recolouring of a component in a page; for an app-wide look, override the palette variables below in a theme file instead.
|
|
4
|
+
|
|
5
|
+
`getColorClass({ color })` returns `getClass(TINT_CLASS, "<colour>")` — it moves `--tint-50` to the chosen colour and recomposes the ladder, so the whole subtree retints. See [`TINT_CLASS`](/ui/TINT_CLASS) for how the ladder works.
|
|
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. Override a palette colour to re-aim every variant and status that maps to it.
|
|
10
|
+
|
|
11
|
+
### Palette
|
|
12
|
+
|
|
13
|
+
| Variable | Default | Notes |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| `--color-gray` | `oklch(60% 0.01 240)` | Neutral anchor — also the default tint when nothing moves it. |
|
|
16
|
+
| `--color-red` | `oklch(62% 0.2 30)` | |
|
|
17
|
+
| `--color-orange` | `oklch(74% 0.157 60)` | |
|
|
18
|
+
| `--color-yellow` | `oklch(86% 0.16 92)` | |
|
|
19
|
+
| `--color-green` | `oklch(72% 0.185 130)` | |
|
|
20
|
+
| `--color-aqua` | `oklch(72% 0.121 185)` | |
|
|
21
|
+
| `--color-blue` | `oklch(57% 0.216 260)` | |
|
|
22
|
+
| `--color-purple` | `oklch(58% 0.25 300)` | |
|
|
23
|
+
| `--color-pink` | `oklch(68% 0.239 350)` | |
|
|
24
|
+
|
|
25
|
+
### Semantic
|
|
26
|
+
|
|
27
|
+
| Variable | Default | Used for |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| `--color-link` | `var(--color-blue)` | Link colour. |
|
|
30
|
+
| `--color-focus` | `var(--color-blue)` | Focus outlines. |
|
|
31
|
+
| `--color-success` | `var(--color-green)` | `status="success"`. |
|
|
32
|
+
| `--color-warning` | `var(--color-orange)` | `status="warning"`. |
|
|
33
|
+
| `--color-failure` | `var(--color-red)` | `status="error"` / `status="danger"`. |
|
|
34
|
+
|
|
35
|
+
### Brand
|
|
36
|
+
|
|
37
|
+
| Variable | Default | Used for |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
| `--color-primary` | `var(--color-blue)` | `color="primary"`. |
|
|
40
|
+
| `--color-secondary` | `var(--color-purple)` | `color="secondary"`. |
|
|
41
|
+
| `--color-tertiary` | `var(--color-pink)` | `color="tertiary"`. |
|
|
42
|
+
|
|
43
|
+
## See also
|
|
44
|
+
|
|
45
|
+
- [`TINT_CLASS`](/ui/TINT_CLASS) — the tint ladder these colours feed, and the full theming guide.
|
|
46
|
+
- [`getStatusClass`](/ui/getStatusClass) — the semantic-status sibling of `color`.
|
|
47
|
+
- [`ui`](/ui) — the styling-system overview and the full list of base token pages.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# getDurationClass
|
|
2
|
+
|
|
3
|
+
This module's main job is to **define and document the transition/animation timing tokens**. Components and [transitions](/ui/Transition) read these tokens directly; `getDurationClass({ duration })` exists as a utility (e.g. `duration="fast"` → `duration-fast`) and as the home for this documentation.
|
|
4
|
+
|
|
5
|
+
## Theme variables
|
|
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.
|
|
8
|
+
|
|
9
|
+
| Variable | Default | Used for |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| `--duration-fast` | `150ms` | Snappy UI feedback — hovers, small toggles. |
|
|
12
|
+
| `--duration-normal` | `300ms` | Default transitions. |
|
|
13
|
+
| `--duration-slow` | `600ms` | Deliberate, large movements. |
|
|
14
|
+
|
|
15
|
+
## See also
|
|
16
|
+
|
|
17
|
+
- [`Transition`](/ui/Transition) — the enter/leave animation component that reads these.
|
|
18
|
+
- [`ui`](/ui) — the styling-system overview and the full list of base token pages.
|