@gryt/theme 0.8.0 → 0.9.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/dist/createGrytTheme.d.ts +16 -0
- package/dist/createGrytTheme.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +546 -456
- package/dist/index.js.map +1 -1
- package/dist/theme.d.ts +112 -0
- package/dist/theme.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/theme.d.ts
CHANGED
|
@@ -3,11 +3,115 @@ export type GrytAppearance = "dark" | "light";
|
|
|
3
3
|
export declare const GRYT_HUE_KEYS: readonly ["accent", "accentLight", "secondary", "secondaryLight", "success", "danger", "dangerLight", "warning", "onAccent", "onSecondary", "onDanger"];
|
|
4
4
|
export declare const GRYT_NEUTRAL_KEYS: readonly ["bg", "surface", "surfaceRaised", "surfaceHover", "border", "muted", "text"];
|
|
5
5
|
export declare const GRYT_RADIUS_KEYS: readonly ["sm", "md", "lg", "xl", "full"];
|
|
6
|
+
/**
|
|
7
|
+
* The three jobs a typeface does here.
|
|
8
|
+
*
|
|
9
|
+
* Three because that is what the interface actually distinguishes: the text
|
|
10
|
+
* you read, the headings above it, and the places where characters have to
|
|
11
|
+
* line up — code, hex values, timestamps, a fingerprint read aloud. Finer than
|
|
12
|
+
* that is a knob nobody turns, and coarser loses the one distinction that
|
|
13
|
+
* matters, which is that a proportional face cannot do the third job.
|
|
14
|
+
*/
|
|
15
|
+
export declare const GRYT_FONT_KEYS: readonly ["body", "display", "mono"];
|
|
16
|
+
/**
|
|
17
|
+
* How a theme is allowed to change the way Gryt moves.
|
|
18
|
+
*
|
|
19
|
+
* Two things, because they are the two a person can answer. How fast, which is
|
|
20
|
+
* one number over every tier, and what shape, which is one curve.
|
|
21
|
+
*
|
|
22
|
+
* Not per-tier durations. The tiers are already in proportion to each other —
|
|
23
|
+
* a drawer takes longer than a button because it travels further — and a
|
|
24
|
+
* theme that set them independently would be re-deciding a relationship
|
|
25
|
+
* somebody worked out once, five sliders at a time, with no way to tell it had
|
|
26
|
+
* gone wrong except by opening a drawer.
|
|
27
|
+
*
|
|
28
|
+
* `scale` at 0 means nothing animates. That is a real setting rather than a
|
|
29
|
+
* degenerate one: some people find movement unpleasant, and the honest way to
|
|
30
|
+
* offer that is a value in the theme rather than asking them to lie to their
|
|
31
|
+
* operating system about `prefers-reduced-motion`.
|
|
32
|
+
*/
|
|
33
|
+
export declare const GRYT_MOTION_CURVES: readonly ["spring", "smooth", "linear"];
|
|
6
34
|
export type GrytHueKey = (typeof GRYT_HUE_KEYS)[number];
|
|
7
35
|
export type GrytNeutralKey = (typeof GRYT_NEUTRAL_KEYS)[number];
|
|
8
36
|
export type GrytRadiusKey = (typeof GRYT_RADIUS_KEYS)[number];
|
|
37
|
+
export type GrytFontKey = (typeof GRYT_FONT_KEYS)[number];
|
|
38
|
+
export type GrytNamedCurve = (typeof GRYT_MOTION_CURVES)[number];
|
|
39
|
+
/** x1, y1, x2, y2 — the two control points of a cubic bezier. */
|
|
40
|
+
export type GrytBezier = readonly [number, number, number, number];
|
|
41
|
+
export type GrytMotionCurve = GrytNamedCurve | GrytBezier;
|
|
9
42
|
export type GrytHues = Record<GrytHueKey, string>;
|
|
10
43
|
export type GrytNeutrals = Record<GrytNeutralKey, string>;
|
|
44
|
+
/**
|
|
45
|
+
* A whole CSS font stack per role, not a family name.
|
|
46
|
+
*
|
|
47
|
+
* The fallbacks are the point. A theme names a face the machine reading it may
|
|
48
|
+
* not have — that is the ordinary case for anything a shared link asks for —
|
|
49
|
+
* and what it falls back to decides whether the note reads as a different
|
|
50
|
+
* choice or as a broken one. Carrying the stack means the theme's author picks
|
|
51
|
+
* that, rather than every consumer inventing its own tail.
|
|
52
|
+
*/
|
|
53
|
+
export type GrytFonts = Record<GrytFontKey, string>;
|
|
54
|
+
/**
|
|
55
|
+
* What the library is set in.
|
|
56
|
+
*
|
|
57
|
+
* Atkinson Hyperlegible, which is a legibility face rather than a taste one:
|
|
58
|
+
* its letterforms are drawn to be told apart at a glance, and Gryt is read in
|
|
59
|
+
* a sidebar at twelve pixels. `display` is the body face here — the default
|
|
60
|
+
* theme does not set headings in anything else, and a default that quietly
|
|
61
|
+
* differed from what ships would be a second thing to keep in step.
|
|
62
|
+
*/
|
|
63
|
+
export declare const grytFonts: GrytFonts;
|
|
64
|
+
/**
|
|
65
|
+
* The motion half of a theme.
|
|
66
|
+
*
|
|
67
|
+
* `curve` names one of the shipped shapes or carries a cubic bezier.
|
|
68
|
+
*
|
|
69
|
+
* A named curve keeps the library's two apart: `--ease-spring` overshoots and
|
|
70
|
+
* is for things that scale in place, `--ease-spring-tight` does not and is for
|
|
71
|
+
* things that travel inside their bounds. A bezier cannot express both, so
|
|
72
|
+
* setting one collapses them into a single shape — which is the honest cost of
|
|
73
|
+
* letting a theme draw its own, and is worth knowing before drawing one that
|
|
74
|
+
* overshoots.
|
|
75
|
+
*/
|
|
76
|
+
export interface GrytMotion {
|
|
77
|
+
/**
|
|
78
|
+
* Multiplier on every duration. 0 is no animation at all.
|
|
79
|
+
*
|
|
80
|
+
* One number rather than five, so the tiers keep the proportions they were
|
|
81
|
+
* given. The curves are duration-invariant — measured, not assumed: the same
|
|
82
|
+
* `linear()` sampled at 200ms and at 2000ms puts the element in the same
|
|
83
|
+
* place at every fraction of the animation, and peaks at the same 10.6% past
|
|
84
|
+
* its target — so scaling time changes how long it takes and nothing else
|
|
85
|
+
* about how it looks.
|
|
86
|
+
*/
|
|
87
|
+
scale: number;
|
|
88
|
+
curve: GrytMotionCurve;
|
|
89
|
+
}
|
|
90
|
+
export declare const grytMotion: GrytMotion;
|
|
91
|
+
/** Past this and it is somebody testing rather than choosing. */
|
|
92
|
+
export declare const GRYT_MOTION_SCALE_MAX = 3;
|
|
93
|
+
export declare function isBezier(curve: GrytMotionCurve): curve is GrytBezier;
|
|
94
|
+
/**
|
|
95
|
+
* A bezier CSS will accept.
|
|
96
|
+
*
|
|
97
|
+
* The x values are the time axis and have to stay inside it; a control point
|
|
98
|
+
* outside 0..1 horizontally is not a slower curve, it is an invalid one and
|
|
99
|
+
* the whole declaration is dropped. The y values may go outside, which is how
|
|
100
|
+
* a bezier overshoots, and that is allowed on purpose.
|
|
101
|
+
*/
|
|
102
|
+
export declare function isValidBezier(value: unknown): value is GrytBezier;
|
|
103
|
+
/** Long enough for a real stack, short enough not to be a payload. */
|
|
104
|
+
export declare const GRYT_FONT_STACK_MAX = 200;
|
|
105
|
+
/**
|
|
106
|
+
* A font stack that is safe to put in a stylesheet.
|
|
107
|
+
*
|
|
108
|
+
* This arrives from a link somebody was sent, so it is a string from a
|
|
109
|
+
* stranger heading for a CSS declaration. Anything that could close the
|
|
110
|
+
* declaration and start another one is refused outright rather than escaped —
|
|
111
|
+
* a font stack has no legitimate use for a brace, a semicolon or a comment
|
|
112
|
+
* marker, so there is nothing to lose by requiring it to look like one.
|
|
113
|
+
*/
|
|
114
|
+
export declare function isFontStack(value: string): boolean;
|
|
11
115
|
export interface GrytTheme {
|
|
12
116
|
/**
|
|
13
117
|
* What its author called it, if they called it anything.
|
|
@@ -24,6 +128,14 @@ export interface GrytTheme {
|
|
|
24
128
|
dark: GrytNeutrals;
|
|
25
129
|
light: GrytNeutrals;
|
|
26
130
|
radius: Record<GrytRadiusKey, number>;
|
|
131
|
+
/**
|
|
132
|
+
* Null when the theme does not care, which is every theme written before
|
|
133
|
+
* this existed and every link already shared. Absent means the library's
|
|
134
|
+
* own, so nothing that predates fonts renders differently for having them.
|
|
135
|
+
*/
|
|
136
|
+
fonts?: GrytFonts | null;
|
|
137
|
+
/** Null for the library's own motion, same reasoning as `fonts`. */
|
|
138
|
+
motion?: GrytMotion | null;
|
|
27
139
|
}
|
|
28
140
|
/** Long enough for a name, short enough not to be a payload. */
|
|
29
141
|
export declare const GRYT_THEME_NAME_MAX = 60;
|
package/dist/theme.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9C,eAAO,MAAM,aAAa,yJAYhB,CAAC;AAEX,eAAO,MAAM,iBAAiB,wFAQpB,CAAC;AAEX,eAAO,MAAM,gBAAgB,2CAA4C,CAAC;AAE1E,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AACxD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAChE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9C,eAAO,MAAM,aAAa,yJAYhB,CAAC;AAEX,eAAO,MAAM,iBAAiB,wFAQpB,CAAC;AAEX,eAAO,MAAM,gBAAgB,2CAA4C,CAAC;AAE1E;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,sCAAuC,CAAC;AAEnE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,kBAAkB,yCAA0C,CAAC;AAE1E,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AACxD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAChE,MAAM,MAAM,aAAa,GAAG,CAAC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