@solidrt/components 0.0.66 → 0.0.68
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/carousel.tsx +5 -0
- package/src/context-menu.tsx +1 -0
- package/src/dismissible.tsx +4 -0
- package/src/editor-field.tsx +4 -2
- package/src/image.tsx +1 -0
- package/src/index.ts +1 -1
- package/src/press.ts +7 -1
- package/src/pressable.tsx +1 -0
- package/src/scroll-view.tsx +4 -0
- package/src/segmented-control.tsx +1 -0
- package/src/slider.tsx +4 -2
- package/src/text.tsx +1 -0
- package/src/typography.ts +29 -1
- package/src/view.tsx +1 -0
- package/src/window.tsx +10 -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.68",
|
|
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.68"
|
|
25
25
|
}
|
|
26
26
|
}
|
package/src/carousel.tsx
CHANGED
|
@@ -66,6 +66,11 @@ export function Carousel(props: CarouselProps) {
|
|
|
66
66
|
setDrag(0)
|
|
67
67
|
setDragging(false)
|
|
68
68
|
},
|
|
69
|
+
// The page in view stays: the drag snaps back.
|
|
70
|
+
onSwipeCancel: () => {
|
|
71
|
+
setDrag(0)
|
|
72
|
+
setDragging(false)
|
|
73
|
+
},
|
|
69
74
|
})
|
|
70
75
|
|
|
71
76
|
let split = () => splitTransition(props.transition)
|
package/src/context-menu.tsx
CHANGED
|
@@ -184,6 +184,7 @@ export function ContextMenu(props: ContextMenuProps) {
|
|
|
184
184
|
onPointerDown={handleDown}
|
|
185
185
|
onPointerMove={longPress.handlers.onPointerMove}
|
|
186
186
|
onPointerUp={longPress.handlers.onPointerUp}
|
|
187
|
+
onPointerCancel={longPress.handlers.onPointerCancel}
|
|
187
188
|
{...props.layout}
|
|
188
189
|
>
|
|
189
190
|
{props.children}
|
package/src/dismissible.tsx
CHANGED
package/src/editor-field.tsx
CHANGED
|
@@ -235,7 +235,8 @@ export function EditorField(props: EditorFieldProps) {
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
// A lift or a cancel: the selection drag ends where it is.
|
|
239
|
+
let handleViewportPointerEnd = (e: PointerEvent) => {
|
|
239
240
|
if (dragArmed === e.pointerId) dragArmed = null
|
|
240
241
|
if (dragActive === e.pointerId) {
|
|
241
242
|
arena.release(e.pointerId, dragOwner)
|
|
@@ -523,7 +524,8 @@ export function EditorField(props: EditorFieldProps) {
|
|
|
523
524
|
scrollY={editor.scrollY()}
|
|
524
525
|
onPointerDown={handleViewportPointerDown}
|
|
525
526
|
onPointerMove={handleViewportPointerMove}
|
|
526
|
-
onPointerUp={
|
|
527
|
+
onPointerUp={handleViewportPointerEnd}
|
|
528
|
+
onPointerCancel={handleViewportPointerEnd}
|
|
527
529
|
>
|
|
528
530
|
{showPlaceholder() ? (
|
|
529
531
|
<d-text w={PLACEHOLDER_SHAPE_WIDTH} {...font()} color={theme.color.textMuted} maxLines={1}>
|
package/src/image.tsx
CHANGED
|
@@ -89,6 +89,7 @@ export function Image(props: ImageProps) {
|
|
|
89
89
|
onPointerLeave={props.onPointerLeave}
|
|
90
90
|
onPointerDown={props.onPointerDown}
|
|
91
91
|
onPointerUp={props.onPointerUp}
|
|
92
|
+
onPointerCancel={props.onPointerCancel}
|
|
92
93
|
onPointerMove={props.onPointerMove}
|
|
93
94
|
onWheel={props.onWheel}
|
|
94
95
|
onFocus={props.onFocus}
|
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/press.ts
CHANGED
|
@@ -19,6 +19,7 @@ export interface PressOptions {
|
|
|
19
19
|
disabled?: boolean
|
|
20
20
|
onPointerDown?: (e: PointerEvent) => void
|
|
21
21
|
onPointerUp?: (e: PointerEvent) => void
|
|
22
|
+
onPointerCancel?: (e: PointerEvent) => void
|
|
22
23
|
onPointerMove?: (e: PointerEvent) => void
|
|
23
24
|
onPointerEnter?: (e: PointerEvent) => void
|
|
24
25
|
onPointerLeave?: (e: PointerEvent) => void
|
|
@@ -43,7 +44,8 @@ export interface PressOptions {
|
|
|
43
44
|
// when the firing waits for that recognizer to fail (the double-tap
|
|
44
45
|
// window passing) and is dropped when it wins. Enter/leave drive hover
|
|
45
46
|
// alone. Non-primary buttons (right/middle) do not start a press. cancel() is
|
|
46
|
-
// the external-cancel hook; it
|
|
47
|
+
// the external-cancel hook; it and a pointer cancel (the system taking the
|
|
48
|
+
// touch away) end the press without firing. Options are read
|
|
47
49
|
// at event time, so passing a component's reactive props object keeps handler
|
|
48
50
|
// changes live. The host view must attach `ref` for retention bounds; without
|
|
49
51
|
// it every position counts as inside (the up always fires).
|
|
@@ -190,6 +192,10 @@ export function createPress(options: PressOptions) {
|
|
|
190
192
|
}
|
|
191
193
|
options.onPointerUp?.(e)
|
|
192
194
|
},
|
|
195
|
+
onPointerCancel: (e: PointerEvent) => {
|
|
196
|
+
if (active === e.pointerId) cancel()
|
|
197
|
+
options.onPointerCancel?.(e)
|
|
198
|
+
},
|
|
193
199
|
onPointerEnter: (e: PointerEvent) => {
|
|
194
200
|
setHovered(true)
|
|
195
201
|
options.onPointerEnter?.(e)
|
package/src/pressable.tsx
CHANGED
|
@@ -80,6 +80,7 @@ export function Pressable(props: PressableProps) {
|
|
|
80
80
|
onPointerLeave={press.handlers.onPointerLeave}
|
|
81
81
|
onPointerDown={press.handlers.onPointerDown}
|
|
82
82
|
onPointerUp={press.handlers.onPointerUp}
|
|
83
|
+
onPointerCancel={press.handlers.onPointerCancel}
|
|
83
84
|
onPointerMove={press.handlers.onPointerMove}
|
|
84
85
|
onWheel={props.onWheel}
|
|
85
86
|
onFocus={press.handlers.onFocus}
|
package/src/scroll-view.tsx
CHANGED
|
@@ -97,6 +97,8 @@ export function ScrollView(props: ScrollViewProps) {
|
|
|
97
97
|
setFling(true)
|
|
98
98
|
scroll.scrollTo(props.horizontal ? { x: dest } : { y: dest })
|
|
99
99
|
},
|
|
100
|
+
// The content stays where the finger left it: nothing flings.
|
|
101
|
+
onPanCancel: () => setDragging(false),
|
|
100
102
|
})
|
|
101
103
|
// A finger landing (any down, a tap included) holds a moving list where
|
|
102
104
|
// it is: the animated offset, read back from the boxes (window-relative,
|
|
@@ -193,6 +195,7 @@ export function ScrollView(props: ScrollViewProps) {
|
|
|
193
195
|
onPointerLeave={props.onPointerLeave}
|
|
194
196
|
onPointerDown={props.onPointerDown}
|
|
195
197
|
onPointerUp={props.onPointerUp}
|
|
198
|
+
onPointerCancel={props.onPointerCancel}
|
|
196
199
|
onPointerMove={props.onPointerMove}
|
|
197
200
|
onWheel={props.onWheel}
|
|
198
201
|
pointerEvents={props.pointerEvents}
|
|
@@ -221,6 +224,7 @@ export function ScrollView(props: ScrollViewProps) {
|
|
|
221
224
|
onPointerDown={hold}
|
|
222
225
|
onPointerMove={pan.handlers.onPointerMove}
|
|
223
226
|
onPointerUp={pan.handlers.onPointerUp}
|
|
227
|
+
onPointerCancel={pan.handlers.onPointerCancel}
|
|
224
228
|
onWheel={onWheel}
|
|
225
229
|
>
|
|
226
230
|
<view ref={(n: { id: number }) => (content = n)} flexShrink={0} flexDirection={direction()}>
|
|
@@ -208,6 +208,7 @@ export function SegmentedControl<T>(props: SegmentedControlProps<T>) {
|
|
|
208
208
|
onPress: () => select(opt.value),
|
|
209
209
|
onPointerDown: () => setPressedValue(() => opt.value),
|
|
210
210
|
onPointerUp: () => setPressedValue(undefined),
|
|
211
|
+
onPointerCancel: () => setPressedValue(undefined),
|
|
211
212
|
})
|
|
212
213
|
onCleanup(() => segs.delete(opt.value))
|
|
213
214
|
return (
|
package/src/slider.tsx
CHANGED
|
@@ -122,7 +122,8 @@ export function Slider(props: SliderProps) {
|
|
|
122
122
|
if (active !== e.pointerId) return
|
|
123
123
|
setFromLocalX(e.localX)
|
|
124
124
|
}
|
|
125
|
-
|
|
125
|
+
// A lift or a cancel: the drag ends where the thumb is.
|
|
126
|
+
let handleEnd = (e: PointerEvent) => {
|
|
126
127
|
if (active === e.pointerId) endDrag()
|
|
127
128
|
}
|
|
128
129
|
|
|
@@ -161,7 +162,8 @@ export function Slider(props: SliderProps) {
|
|
|
161
162
|
focusable={!props.disabled}
|
|
162
163
|
onPointerDown={handleDown}
|
|
163
164
|
onPointerMove={handleMove}
|
|
164
|
-
onPointerUp={
|
|
165
|
+
onPointerUp={handleEnd}
|
|
166
|
+
onPointerCancel={handleEnd}
|
|
165
167
|
onKeyDown={handleKeyDown}
|
|
166
168
|
>
|
|
167
169
|
{/* Colors fade with the theme; the fill's w and the thumb's x never
|
package/src/text.tsx
CHANGED
|
@@ -68,6 +68,7 @@ export function Text(props: TextProps) {
|
|
|
68
68
|
onPointerLeave={props.onPointerLeave}
|
|
69
69
|
onPointerDown={props.onPointerDown}
|
|
70
70
|
onPointerUp={props.onPointerUp}
|
|
71
|
+
onPointerCancel={props.onPointerCancel}
|
|
71
72
|
onPointerMove={props.onPointerMove}
|
|
72
73
|
onWheel={props.onWheel}
|
|
73
74
|
onFocus={props.onFocus}
|
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/view.tsx
CHANGED
|
@@ -40,6 +40,7 @@ export function View(props: ViewProps) {
|
|
|
40
40
|
onPointerLeave={props.onPointerLeave}
|
|
41
41
|
onPointerDown={props.onPointerDown}
|
|
42
42
|
onPointerUp={props.onPointerUp}
|
|
43
|
+
onPointerCancel={props.onPointerCancel}
|
|
43
44
|
onPointerMove={props.onPointerMove}
|
|
44
45
|
onWheel={props.onWheel}
|
|
45
46
|
onFocus={props.onFocus}
|
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}
|
|
@@ -45,6 +53,7 @@ export function Window(props: WindowProps) {
|
|
|
45
53
|
onPointerLeave={props.onPointerLeave}
|
|
46
54
|
onPointerDown={props.onPointerDown}
|
|
47
55
|
onPointerUp={props.onPointerUp}
|
|
56
|
+
onPointerCancel={props.onPointerCancel}
|
|
48
57
|
onPointerMove={props.onPointerMove}
|
|
49
58
|
onWheel={props.onWheel}
|
|
50
59
|
onFocus={props.onFocus}
|