@runbooks/design 0.1.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/README.md +14 -0
- package/dist/color.d.ts +17 -0
- package/dist/color.js +24 -0
- package/dist/geometry.test.d.ts +1 -0
- package/dist/geometry.test.js +155 -0
- package/dist/icons.d.ts +69 -0
- package/dist/icons.js +103 -0
- package/dist/icons.test.d.ts +1 -0
- package/dist/icons.test.js +140 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/mark.d.ts +42 -0
- package/dist/mark.js +102 -0
- package/dist/primitives.d.ts +75 -0
- package/dist/primitives.js +126 -0
- package/dist/primitives.test.d.ts +1 -0
- package/dist/primitives.test.js +134 -0
- package/dist/render.d.ts +97 -0
- package/dist/render.js +1085 -0
- package/dist/render.test.d.ts +1 -0
- package/dist/render.test.js +179 -0
- package/dist/specimen.d.ts +2 -0
- package/dist/specimen.gen.d.ts +1 -0
- package/dist/specimen.gen.js +9 -0
- package/dist/specimen.js +81 -0
- package/dist/stylesheet.d.ts +95 -0
- package/dist/stylesheet.js +987 -0
- package/dist/stylesheet.test.d.ts +1 -0
- package/dist/stylesheet.test.js +265 -0
- package/dist/text.d.ts +28 -0
- package/dist/text.js +89 -0
- package/dist/tokens.d.ts +104 -0
- package/dist/tokens.js +142 -0
- package/dist/tokens.test.d.ts +1 -0
- package/dist/tokens.test.js +125 -0
- package/fonts/IBMPlexMono-Regular-Latin1.woff2 +0 -0
- package/fonts/IBMPlexMono-SemiBold-Latin1.woff2 +0 -0
- package/fonts/IBMPlexSans-Italic-Latin1.woff2 +0 -0
- package/fonts/IBMPlexSans-Medium-Latin1.woff2 +0 -0
- package/fonts/IBMPlexSans-Regular-Latin1.woff2 +0 -0
- package/fonts/IBMPlexSans-SemiBold-Latin1.woff2 +0 -0
- package/fonts/LICENSE.txt +93 -0
- package/package.json +40 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { RISK_ORDER } from "@runbooks/schema";
|
|
6
|
+
import { EXEMPT_FROM_STROKE_FLOOR, PALETTES, RISK_COLORS, RISK_LABELS, DEFAULT_THEME, TYPE_SCALE, CONTRAST_FLOOR, meetsTextFloor, meetsStrokeFloor, riskLightnessOrder, riskColor, } from "./tokens.js";
|
|
7
|
+
import { contrast } from "./color.js";
|
|
8
|
+
const THEMES = ["dark", "light"];
|
|
9
|
+
/**
|
|
10
|
+
* The floors from §18.2, asserted against every pairing the product actually uses
|
|
11
|
+
* rather than checked once by eye. Measuring them is how the visual specification's
|
|
12
|
+
* original palette was found to fail two of its own three stated properties.
|
|
13
|
+
*/
|
|
14
|
+
describe("contrast floors hold for every pairing in use", () => {
|
|
15
|
+
it.each(THEMES)("%s: text and secondary text clear 4.5:1", (theme) => {
|
|
16
|
+
const p = PALETTES[theme];
|
|
17
|
+
for (const ground of [p.background, p.surface]) {
|
|
18
|
+
expect(meetsTextFloor(p.text, ground), `text on ${ground}`).toBe(true);
|
|
19
|
+
expect(meetsTextFloor(p.textSecondary, ground), `secondary on ${ground}`).toBe(true);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
// The trust accent is text, so it answers to the text floor. As specified it measured
|
|
23
|
+
// 4.23:1 on the dark ground.
|
|
24
|
+
it.each(THEMES)("%s: the trust accent clears the text floor", (theme) => {
|
|
25
|
+
const p = PALETTES[theme];
|
|
26
|
+
expect(contrast(p.trust, p.background)).toBeGreaterThanOrEqual(CONTRAST_FLOOR.text);
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Every token in the palette, not only the risk colours.
|
|
30
|
+
*
|
|
31
|
+
* `EXEMPT_FROM_STROKE_FLOOR` says in its own comment that it exists "so the exemption is
|
|
32
|
+
* a decision rather than an oversight the contrast test quietly skips" — and nothing
|
|
33
|
+
* read it. The test below sweeps `RISK_ORDER` and stops, so every other token was
|
|
34
|
+
* skipped exactly as quietly as the comment feared, exempt or not.
|
|
35
|
+
*
|
|
36
|
+
* Measured before it was written: `surface` and `border` are the only two under 3:1, in
|
|
37
|
+
* both themes, which is what the exemption already claimed. So this passes today and the
|
|
38
|
+
* list is load-bearing — take a name out of it and this fails, which is the difference
|
|
39
|
+
* between a decision and a sentence.
|
|
40
|
+
*/
|
|
41
|
+
it.each(THEMES)("%s: every palette colour clears the stroke floor on both grounds", (theme) => {
|
|
42
|
+
const p = PALETTES[theme];
|
|
43
|
+
// Both grounds, because content sits on both. The first version of this checked the
|
|
44
|
+
// page background only, and a card is `surface`: a colour can clear one and fail the
|
|
45
|
+
// other, and in the dark theme the two are far enough apart for that to happen —
|
|
46
|
+
// #5A6068 is 3.03:1 on the background and 2.76:1 on a card.
|
|
47
|
+
for (const [ground, against] of [["the page", p.background], ["a card", p.surface]]) {
|
|
48
|
+
for (const [name, value] of Object.entries(p)) {
|
|
49
|
+
if (typeof value !== "string" || !value.startsWith("#"))
|
|
50
|
+
continue;
|
|
51
|
+
if (name === "background" || name === "surface")
|
|
52
|
+
continue;
|
|
53
|
+
if (EXEMPT_FROM_STROKE_FLOOR.includes(name))
|
|
54
|
+
continue;
|
|
55
|
+
expect(meetsStrokeFloor(value, against), `${name} in ${theme} is ${contrast(value, against).toFixed(2)}:1 against ${ground}, and is not exempt`).toBe(true);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
it.each(THEMES)("%s: every risk colour clears the 3:1 stroke floor", (theme) => {
|
|
60
|
+
const p = PALETTES[theme];
|
|
61
|
+
for (const risk of RISK_ORDER) {
|
|
62
|
+
for (const ground of [p.background, p.surface]) {
|
|
63
|
+
expect(meetsStrokeFloor(riskColor(risk, theme), ground), `${risk} on ${ground} in ${theme}: ${contrast(riskColor(risk, theme), ground).toFixed(2)}:1`).toBe(true);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe("the risk scale survives greyscale", () => {
|
|
69
|
+
// Monotonic in lightness is what makes the scale readable in black and white and
|
|
70
|
+
// under colour blindness. The original palette put read-only at 0.182 and destructive
|
|
71
|
+
// at 0.186 — the same colour, to a greyscale reader.
|
|
72
|
+
it.each(THEMES)("%s: severity reads as darker, in order", (theme) => {
|
|
73
|
+
expect(riskLightnessOrder(theme)).toEqual([...RISK_ORDER]);
|
|
74
|
+
});
|
|
75
|
+
it.each(THEMES)("%s: adjacent steps are separable, not merely ordered", (theme) => {
|
|
76
|
+
const order = riskLightnessOrder(theme);
|
|
77
|
+
for (let i = 1; i < order.length; i++) {
|
|
78
|
+
const ratio = contrast(riskColor(order[i - 1], theme), riskColor(order[i], theme));
|
|
79
|
+
expect(ratio, `${order[i - 1]} vs ${order[i]}`).toBeGreaterThan(1.15);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
// A hue is never the sole carrier of meaning (§18.2 accessibility).
|
|
83
|
+
it("every risk has a text label", () => {
|
|
84
|
+
for (const risk of RISK_ORDER)
|
|
85
|
+
expect(RISK_LABELS[risk]).toMatch(/^[A-Z]{2,3}$/);
|
|
86
|
+
});
|
|
87
|
+
it("the ordering is identical in both themes", () => {
|
|
88
|
+
expect(riskLightnessOrder("dark")).toEqual(riskLightnessOrder("light"));
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
describe("colour never encodes status and risk at the same time (§18.2)", () => {
|
|
92
|
+
const source = readFileSync(join(dirname(fileURLToPath(import.meta.url)), "tokens.ts"), "utf8");
|
|
93
|
+
// A rule is better kept by having nothing to reach for. If a token for "current
|
|
94
|
+
// step" or "passed" ever appears, run state has taken the hue channel from risk.
|
|
95
|
+
it("defines no colour token for run or simulation state", () => {
|
|
96
|
+
expect(source).not.toMatch(/\b(current|passed|failed|active|running)Color\b/i);
|
|
97
|
+
expect(source).not.toMatch(/STATE_COLORS/);
|
|
98
|
+
});
|
|
99
|
+
it("defines no shadow token, so a canvas shadow cannot be reached for", () => {
|
|
100
|
+
expect(source).not.toMatch(/shadow/i);
|
|
101
|
+
});
|
|
102
|
+
it("defines no gradient token", () => {
|
|
103
|
+
expect(source).not.toMatch(/gradient/i);
|
|
104
|
+
});
|
|
105
|
+
it("defines no all-caps text style", () => {
|
|
106
|
+
expect(source).not.toMatch(/uppercase|textTransform/i);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
describe("theme defaults follow exposure time without locking anyone in", () => {
|
|
110
|
+
it("defaults both surfaces to dark", () => {
|
|
111
|
+
expect(DEFAULT_THEME).toEqual({ canvas: "dark", catalog: "dark" });
|
|
112
|
+
});
|
|
113
|
+
it("offers both themes, so a viewer's choice can win", () => {
|
|
114
|
+
expect(Object.keys(PALETTES).sort()).toEqual(["dark", "light"]);
|
|
115
|
+
expect(Object.keys(RISK_COLORS).sort()).toEqual(["dark", "light"]);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
describe("typography", () => {
|
|
119
|
+
it("caps body line length where it is a layout decision, not a per-page one", () => {
|
|
120
|
+
expect(TYPE_SCALE.body.maxLineLength).toBeLessThanOrEqual(75);
|
|
121
|
+
});
|
|
122
|
+
it("keeps a node label to two lines", () => {
|
|
123
|
+
expect(TYPE_SCALE.nodeLabel.maxLines).toBe(2);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
|
|
5
|
+
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@runbooks/design",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Design tokens, graph visual primitives, and SVG rendering.",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@runbooks/schema": "^0.1.0",
|
|
17
|
+
"@runbooks/graph": "^0.1.0"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/runbooks-directory/runbooks.directory"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20.11"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"fonts",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc -b",
|
|
37
|
+
"test": "vitest run --passWithNoTests",
|
|
38
|
+
"lint": "eslint src"
|
|
39
|
+
}
|
|
40
|
+
}
|