@solidrt/components 0.0.67 → 0.0.69
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 +3 -1
- package/docs/typography.md +2 -0
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/typography.ts +29 -1
- package/src/window.tsx +9 -1
package/README.md
CHANGED
|
@@ -163,9 +163,11 @@ API: `StyleProps`, `Glow`, `Glass`, `Material`, `MaterialRole`, `ElevationLevel`
|
|
|
163
163
|
|
|
164
164
|
`typeStyle(variant)` resolves a theme type-scale role (`caption`/`label`/`body`/`title`/`heading`) to font props ready to spread onto a `<text>` or `d-text`: `fontSize` carries `policy.textScale`, and `fontWeight` carries the low-DPI weight compensation. Reactive when called inside a tracked scope, like any theme/policy read. `Text` applies it for you; reach for the helpers when building custom text out of core primitives.
|
|
165
165
|
|
|
166
|
+
`typeScaleStyles()` is the type scale as font styles (every role in both polarities' weights, plus the mono family at body size), and `warmTypeScale()` hands them to core's `warmText`, which makes their glyph cells ahead of the first screen on the text engine's worker. `Window` does this on mount and again when the theme or the text policy changes; an app that draws its own window calls it once at startup.
|
|
167
|
+
|
|
166
168
|
The compensation exists because the renderer rasterizes glyphs unhinted and composites in nonlinear sRGB, which thins light-on-dark text on low-DPI displays as glyphs shrink. `typeWeight(weight, size, onDark?)` adds `policy.textWeightDelta` (0 on high-DPI displays) plus one extra step below 16px; dark-on-light text passes through untouched. `lightOnDark(text, fill)` computes the polarity for a known pair of colors (Button uses it for its fills); omitted, the theme's own palette polarity is used.
|
|
167
169
|
|
|
168
|
-
API: `typeStyle`, `typeWeight`, `lightOnDark` - typed and commented in [src/typography.ts](./src/typography.ts).
|
|
170
|
+
API: `typeStyle`, `typeWeight`, `lightOnDark`, `typeScaleStyles`, `warmTypeScale` - typed and commented in [src/typography.ts](./src/typography.ts).
|
|
169
171
|
|
|
170
172
|
## Spacing
|
|
171
173
|
|
package/docs/typography.md
CHANGED
|
@@ -2,4 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
`typeStyle(variant)` resolves a theme type-scale role (`caption`/`label`/`body`/`title`/`heading`) to font props ready to spread onto a `<text>` or `d-text`: `fontSize` carries `policy.textScale`, and `fontWeight` carries the low-DPI weight compensation. Reactive when called inside a tracked scope, like any theme/policy read. `Text` applies it for you; reach for the helpers when building custom text out of core primitives.
|
|
4
4
|
|
|
5
|
+
`typeScaleStyles()` is the type scale as font styles (every role in both polarities' weights, plus the mono family at body size), and `warmTypeScale()` hands them to core's `warmText`, which makes their glyph cells ahead of the first screen on the text engine's worker. `Window` does this on mount and again when the theme or the text policy changes; an app that draws its own window calls it once at startup.
|
|
6
|
+
|
|
5
7
|
The compensation exists because the renderer rasterizes glyphs unhinted and composites in nonlinear sRGB, which thins light-on-dark text on low-DPI displays as glyphs shrink. `typeWeight(weight, size, onDark?)` adds `policy.textWeightDelta` (0 on high-DPI displays) plus one extra step below 16px; dark-on-light text passes through untouched. `lightOnDark(text, fill)` computes the polarity for a known pair of colors (Button uses it for its fills); omitted, the theme's own palette polarity is used.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidrt/components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.69",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"funding": "https://github.com/sponsors/wellawaretech",
|
|
6
6
|
"author": "Antoine van Wel",
|
|
@@ -21,6 +21,6 @@
|
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@solidjs/signals": "2.0.0-rc.13",
|
|
24
|
-
"@solidrt/core": "0.0.
|
|
24
|
+
"@solidrt/core": "0.0.69"
|
|
25
25
|
}
|
|
26
26
|
}
|
package/src/index.ts
CHANGED
|
@@ -70,7 +70,7 @@ export {
|
|
|
70
70
|
type LayoutPolicy,
|
|
71
71
|
} from "./policy"
|
|
72
72
|
export { Density, type DensityProps, densityScale } from "./density"
|
|
73
|
-
export { typeStyle, typeWeight, lightOnDark } from "./typography"
|
|
73
|
+
export { typeStyle, typeWeight, lightOnDark, typeScaleStyles, warmTypeScale } from "./typography"
|
|
74
74
|
export { space } from "./spacing"
|
|
75
75
|
export type {
|
|
76
76
|
StyleProps,
|
package/src/typography.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { brightness } from "@solidrt/core"
|
|
1
|
+
import { brightness, warmText } from "@solidrt/core"
|
|
2
|
+
import type { MeasureTextOptions } from "@solidrt/core"
|
|
2
3
|
import { theme, type TextStyle, type TextVariant } from "./theme"
|
|
3
4
|
import { policy } from "./policy"
|
|
4
5
|
|
|
@@ -55,3 +56,30 @@ export function typeStyle(variant: TextVariant, onDark?: boolean) {
|
|
|
55
56
|
fontWeight: typeWeight(role.weight, size, onDark),
|
|
56
57
|
}
|
|
57
58
|
}
|
|
59
|
+
|
|
60
|
+
// Every role of the type scale, in both polarities' weights (a button's
|
|
61
|
+
// label on its primary fill is the opposite polarity of body text), plus
|
|
62
|
+
// the mono family at body size for code spans.
|
|
63
|
+
const TYPE_SCALE_VARIANTS: TextVariant[] = ["caption", "label", "body", "title", "heading"]
|
|
64
|
+
|
|
65
|
+
// The font styles the theme's type scale draws in, as warmText takes them.
|
|
66
|
+
// Reactive like typeStyle: a theme or policy change yields the new set.
|
|
67
|
+
export function typeScaleStyles(): MeasureTextOptions[] {
|
|
68
|
+
let styles: MeasureTextOptions[] = []
|
|
69
|
+
for (let variant of TYPE_SCALE_VARIANTS) {
|
|
70
|
+
for (let onDark of [false, true]) {
|
|
71
|
+
let style = typeStyle(variant, onDark)
|
|
72
|
+
styles.push({ fontFamily: style.fontFamily, fontSize: style.fontSize, fontWeight: style.fontWeight })
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
let body = typeStyle("body")
|
|
76
|
+
styles.push({ fontFamily: theme.text.monoFamily, fontSize: body.fontSize, fontWeight: body.fontWeight })
|
|
77
|
+
return styles
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Warm the text engine for the theme's type scale (see warmText in
|
|
81
|
+
// @solidrt/core): the components' Window does this on mount and on every
|
|
82
|
+
// theme change; an app without one calls it at startup.
|
|
83
|
+
export function warmTypeScale(): void {
|
|
84
|
+
warmText(typeScaleStyles())
|
|
85
|
+
}
|
package/src/window.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { displayScale } from "@solidrt/core"
|
|
1
|
+
import { createEffect, displayScale, warmText } from "@solidrt/core"
|
|
2
2
|
import type { LayoutProps, PointerProps, WindowShaderProps } from "@solidrt/core"
|
|
3
3
|
import type { StyleProps } from "./types"
|
|
4
4
|
import { colorFade } from "./motion"
|
|
5
5
|
import { theme } from "./theme"
|
|
6
|
+
import { typeScaleStyles } from "./typography"
|
|
6
7
|
|
|
7
8
|
export interface WindowProps extends PointerProps {
|
|
8
9
|
children?: any
|
|
@@ -35,6 +36,13 @@ function themeFinish(): WindowShaderProps | null {
|
|
|
35
36
|
// the paint-only backgroundColor from style applies here. Its finish is the
|
|
36
37
|
// theme's, or the app's own (`shader`).
|
|
37
38
|
export function Window(props: WindowProps) {
|
|
39
|
+
// The theme's type scale warmed ahead of the first screen, and again
|
|
40
|
+
// when the theme or the text policy changes it (a warmed style costs
|
|
41
|
+
// nothing twice).
|
|
42
|
+
createEffect(
|
|
43
|
+
() => typeScaleStyles(),
|
|
44
|
+
styles => warmText(styles),
|
|
45
|
+
)
|
|
38
46
|
return (
|
|
39
47
|
<window
|
|
40
48
|
{...props.layout}
|