@mailwoman/react 10.6.0 → 10.8.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 +6 -3
- package/fonts.css +7 -129
- package/lib/map/Geocoder.tsx +35 -18
- package/lib/map/GeocoderControls.tsx +27 -14
- package/lib/map/MapCanvas.tsx +25 -1
- package/lib/map/PlaceMarker.tsx +4 -2
- package/lib/map/ResultOverlay.tsx +5 -2
- package/lib/map/StarfieldLayer.tsx +114 -0
- package/lib/map/starfield.ts +335 -0
- package/lib/map/types.ts +7 -3
- package/lib/pipeline/CandidatePicker.tsx +8 -1
- package/lib/pipeline/ResolvedPlace.tsx +1 -1
- package/lib/pipeline/presets.ts +4 -3
- package/lib/poi/runtime.ts +1 -1
- package/lib/search/SearchModal.tsx +56 -9
- package/lib/search/search.css +62 -62
- package/out/map/Geocoder.d.ts.map +1 -1
- package/out/map/Geocoder.js +16 -3
- package/out/map/Geocoder.js.map +1 -1
- package/out/map/GeocoderControls.d.ts.map +1 -1
- package/out/map/GeocoderControls.js +26 -14
- package/out/map/GeocoderControls.js.map +1 -1
- package/out/map/MapCanvas.d.ts +11 -1
- package/out/map/MapCanvas.d.ts.map +1 -1
- package/out/map/MapCanvas.js +34 -3
- package/out/map/MapCanvas.js.map +1 -1
- package/out/map/PlaceMarker.d.ts.map +1 -1
- package/out/map/PlaceMarker.js +17 -2
- package/out/map/PlaceMarker.js.map +1 -1
- package/out/map/ResultOverlay.d.ts.map +1 -1
- package/out/map/ResultOverlay.js +10 -2
- package/out/map/ResultOverlay.js.map +1 -1
- package/out/map/StarfieldLayer.d.ts +24 -0
- package/out/map/StarfieldLayer.d.ts.map +1 -0
- package/out/map/StarfieldLayer.js +75 -0
- package/out/map/StarfieldLayer.js.map +1 -0
- package/out/map/starfield.d.ts +124 -0
- package/out/map/starfield.d.ts.map +1 -0
- package/out/map/starfield.js +200 -0
- package/out/map/starfield.js.map +1 -0
- package/out/map/types.d.ts +7 -3
- package/out/map/types.d.ts.map +1 -1
- package/out/pipeline/CandidatePicker.d.ts.map +1 -1
- package/out/pipeline/CandidatePicker.js +7 -1
- package/out/pipeline/CandidatePicker.js.map +1 -1
- package/out/pipeline/ResolvedPlace.js +1 -1
- package/out/pipeline/ResolvedPlace.js.map +1 -1
- package/out/pipeline/presets.d.ts.map +1 -1
- package/out/pipeline/presets.js +4 -3
- package/out/pipeline/presets.js.map +1 -1
- package/out/poi/runtime.js +1 -1
- package/out/poi/runtime.js.map +1 -1
- package/out/search/SearchModal.d.ts.map +1 -1
- package/out/search/SearchModal.js +39 -9
- package/out/search/SearchModal.js.map +1 -1
- package/package.json +23 -21
- package/styles.css +436 -450
- package/tokens/index.css +600 -129
- package/tokens/tokens.json +1736 -539
- package/tokens/tokens.resolver.json +272 -138
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mailwoman/react
|
|
2
2
|
|
|
3
|
-
This package provides React components and headless hooks for [mailwoman](https://mailwoman.
|
|
3
|
+
This package provides React components and headless hooks for [mailwoman](https://mailwoman.post). It
|
|
4
4
|
packages the parse/geocode/POI explorers from the docs site as smaller parts for use in any React app.
|
|
5
5
|
|
|
6
6
|
## What's in the box
|
|
@@ -29,8 +29,11 @@ import "@mailwoman/react/styles.css"
|
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
The stylesheet ships as a standalone file (`@mailwoman/react/styles.css`). It is plain CSS with a `mw-`
|
|
32
|
-
prefix
|
|
33
|
-
|
|
32
|
+
prefix. It reads the Sister Software brand tokens (`--ss-*`, from `@sister.software/theme`) plus
|
|
33
|
+
Mailwoman's own (`--mw-*`), and pulls `tokens.css` in itself, so it renders the same inside Docusaurus
|
|
34
|
+
and standalone. Set `data-theme="dark"` on `<html>` for the dark theme. Load `@mailwoman/react/fonts.css`
|
|
35
|
+
for Archivo display, Go Musubi reading and small caps, Fira Code, and the M PLUS U Japanese companion. Font binaries
|
|
36
|
+
load from `public.sister.software`. No component imports CSS, so the bare package import stays safe to load in Node.
|
|
34
37
|
|
|
35
38
|
## Development
|
|
36
39
|
|
package/fonts.css
CHANGED
|
@@ -1,134 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The brand typefaces
|
|
2
|
+
* The brand typefaces come from `@sister.software/fonts`, served from public.sister.software.
|
|
3
3
|
*
|
|
4
|
-
* The token layer binds
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* being synthesized.
|
|
4
|
+
* The token layer binds the faces (`--ss-font-family-base`, `--ss-font-family-monospace`, …); a rule names a role,
|
|
5
|
+
* never a family. Archivo sets display text, Go Musubi sets reading text and small caps, and Fira Code sets code.
|
|
6
|
+
* M PLUS U supplies Japanese alongside Archivo and Go Musubi. Map labels use SDF glyph ranges and retain the
|
|
7
|
+
* `--mw-font-family-map` stack.
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
* Cyrillic, math), and the browser downloads the extended file only when a page uses one of its codepoints.
|
|
12
|
-
* "Bliss Pro Fallback" scales Arial to Bliss Pro's average advance and vertical metrics, so text keeps its line
|
|
13
|
-
* breaks when the web font swaps in.
|
|
14
|
-
*
|
|
15
|
-
* A rule never names a family here — it names a scale role from `tokens.css`, which names one of the five face
|
|
16
|
-
* roles. Replacing the typeface is an edit to `--font-family-*` in `styleframe.config.ts` plus this file.
|
|
9
|
+
* Kept as `@mailwoman/react/fonts.css` so the apps and Storybook import one path.
|
|
17
10
|
*/
|
|
18
11
|
|
|
19
|
-
@
|
|
20
|
-
font-family: "Bliss Pro Fallback";
|
|
21
|
-
src: local("Arial");
|
|
22
|
-
size-adjust: 92%;
|
|
23
|
-
ascent-override: 103.6%;
|
|
24
|
-
descent-override: 26.2%;
|
|
25
|
-
line-gap-override: 0%;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@font-face {
|
|
29
|
-
font-family: "Bliss Pro Web";
|
|
30
|
-
font-display: swap;
|
|
31
|
-
font-weight: 400;
|
|
32
|
-
font-style: normal;
|
|
33
|
-
src: url("https://public.mailwoman.ai/fonts/BlissPro/WOFF2/BlissPro-Latin.woff2") format("woff2");
|
|
34
|
-
unicode-range:
|
|
35
|
-
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC,
|
|
36
|
-
U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD, U+FB01-FB02;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@font-face {
|
|
40
|
-
font-family: "Bliss Pro Web";
|
|
41
|
-
font-display: swap;
|
|
42
|
-
font-weight: 400;
|
|
43
|
-
font-style: normal;
|
|
44
|
-
src: url("https://public.mailwoman.ai/fonts/BlissPro/WOFF2/BlissPro-Extended.woff2") format("woff2");
|
|
45
|
-
unicode-range:
|
|
46
|
-
U+0100-0129, U+012B-012C, U+012E-0130, U+0132-0137, U+0139-0148, U+014A-0151, U+0154-017E, U+0192, U+01FA-01FF,
|
|
47
|
-
U+0218-0219, U+02C7, U+02D8-02D9, U+02DB, U+02DD, U+0315, U+0326, U+0386, U+0388-038A, U+038C, U+038E-0393,
|
|
48
|
-
U+0395-03A1, U+03A3-03CE, U+0400-045F, U+0462-0463, U+0472-0475, U+0490-0491, U+1E80-1E85, U+1EF2-1EF3, U+2070,
|
|
49
|
-
U+2074-2089, U+208D-208E, U+2113, U+2116-2117, U+212E, U+2153-2154, U+215B-215E, U+2202, U+2206, U+220F, U+2211,
|
|
50
|
-
U+221A, U+221E, U+222B, U+2248, U+2260, U+2264-2265, U+25CA;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@font-face {
|
|
54
|
-
font-family: "Bliss Pro Web";
|
|
55
|
-
font-display: swap;
|
|
56
|
-
font-weight: 400;
|
|
57
|
-
font-style: italic;
|
|
58
|
-
src: url("https://public.mailwoman.ai/fonts/BlissPro/WOFF2/BlissPro-Italic-Latin.woff2") format("woff2");
|
|
59
|
-
unicode-range:
|
|
60
|
-
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC,
|
|
61
|
-
U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD, U+FB01-FB02;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
@font-face {
|
|
65
|
-
font-family: "Bliss Pro Web";
|
|
66
|
-
font-display: swap;
|
|
67
|
-
font-weight: 400;
|
|
68
|
-
font-style: italic;
|
|
69
|
-
src: url("https://public.mailwoman.ai/fonts/BlissPro/WOFF2/BlissPro-Italic-Extended.woff2") format("woff2");
|
|
70
|
-
unicode-range:
|
|
71
|
-
U+0100-0129, U+012B-012C, U+012E-0130, U+0132-0137, U+0139-0148, U+014A-0151, U+0154-017E, U+0192, U+01FA-01FF,
|
|
72
|
-
U+0218-0219, U+02C7, U+02D8-02D9, U+02DB, U+02DD, U+0315, U+0326, U+0386, U+0388-038A, U+038C, U+038E-0393,
|
|
73
|
-
U+0395-03A1, U+03A3-03CE, U+0400-045F, U+0462-0463, U+0472-0475, U+0490-0491, U+1E80-1E85, U+1EF2-1EF3, U+2070,
|
|
74
|
-
U+2074-2089, U+208D-208E, U+2113, U+2116-2117, U+212E, U+2153-2154, U+215B-215E, U+2202, U+2206, U+220F, U+2211,
|
|
75
|
-
U+221A, U+221E, U+222B, U+2248, U+2260, U+2264-2265, U+25CA;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
@font-face {
|
|
79
|
-
font-family: "Bliss Pro Web";
|
|
80
|
-
font-display: swap;
|
|
81
|
-
font-weight: 500;
|
|
82
|
-
font-style: normal;
|
|
83
|
-
src: url("https://public.mailwoman.ai/fonts/BlissPro/WOFF2/BlissPro-Medium-Latin.woff2") format("woff2");
|
|
84
|
-
unicode-range:
|
|
85
|
-
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC,
|
|
86
|
-
U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD, U+FB01-FB02;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@font-face {
|
|
90
|
-
font-family: "Bliss Pro Web";
|
|
91
|
-
font-display: swap;
|
|
92
|
-
font-weight: 500;
|
|
93
|
-
font-style: normal;
|
|
94
|
-
src: url("https://public.mailwoman.ai/fonts/BlissPro/WOFF2/BlissPro-Medium-Extended.woff2") format("woff2");
|
|
95
|
-
unicode-range:
|
|
96
|
-
U+0100-0129, U+012B-012C, U+012E-0130, U+0132-0137, U+0139-0148, U+014A-0151, U+0154-017E, U+0192, U+01FA-01FF,
|
|
97
|
-
U+0218-0219, U+02C7, U+02D8-02D9, U+02DB, U+02DD, U+0315, U+0326, U+0386, U+0388-038A, U+038C, U+038E-0393,
|
|
98
|
-
U+0395-03A1, U+03A3-03CE, U+0400-045F, U+0462-0463, U+0472-0475, U+0490-0491, U+1E80-1E85, U+1EF2-1EF3, U+2070,
|
|
99
|
-
U+2074-2089, U+208D-208E, U+2113, U+2116-2117, U+212E, U+2153-2154, U+215B-215E, U+2202, U+2206, U+220F, U+2211,
|
|
100
|
-
U+221A, U+221E, U+222B, U+2248, U+2260, U+2264-2265, U+25CA;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
@font-face {
|
|
104
|
-
font-family: "Bliss Pro Web";
|
|
105
|
-
font-display: swap;
|
|
106
|
-
font-weight: 700;
|
|
107
|
-
font-style: normal;
|
|
108
|
-
src: url("https://public.mailwoman.ai/fonts/BlissPro/WOFF2/BlissPro-Bold-Latin.woff2") format("woff2");
|
|
109
|
-
unicode-range:
|
|
110
|
-
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC,
|
|
111
|
-
U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD, U+FB01-FB02;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
@font-face {
|
|
115
|
-
font-family: "Bliss Pro Web";
|
|
116
|
-
font-display: swap;
|
|
117
|
-
font-weight: 700;
|
|
118
|
-
font-style: normal;
|
|
119
|
-
src: url("https://public.mailwoman.ai/fonts/BlissPro/WOFF2/BlissPro-Bold-Extended.woff2") format("woff2");
|
|
120
|
-
unicode-range:
|
|
121
|
-
U+0100-0129, U+012B-012C, U+012E-0130, U+0132-0137, U+0139-0148, U+014A-0151, U+0154-017E, U+0192, U+01FA-01FF,
|
|
122
|
-
U+0218-0219, U+02C7, U+02D8-02D9, U+02DB, U+02DD, U+0315, U+0326, U+0386, U+0388-038A, U+038C, U+038E-0393,
|
|
123
|
-
U+0395-03A1, U+03A3-03CE, U+0400-045F, U+0462-0463, U+0472-0475, U+0490-0491, U+1E80-1E85, U+1EF2-1EF3, U+2070,
|
|
124
|
-
U+2074-2089, U+208D-208E, U+2113, U+2116-2117, U+212E, U+2153-2154, U+215B-215E, U+2202, U+2206, U+220F, U+2211,
|
|
125
|
-
U+221A, U+221E, U+222B, U+2248, U+2260, U+2264-2265, U+25CA;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
@font-face {
|
|
129
|
-
font-family: "Fira Code Web";
|
|
130
|
-
font-display: swap;
|
|
131
|
-
font-weight: 300 700;
|
|
132
|
-
font-style: normal;
|
|
133
|
-
src: url("https://public.mailwoman.ai/fonts/FiraCode/WOFF2/FiraCode-VF.woff2") format("woff2");
|
|
134
|
-
}
|
|
12
|
+
@import "@sister.software/fonts/apply.css";
|
package/lib/map/Geocoder.tsx
CHANGED
|
@@ -167,24 +167,32 @@ function GeocoderInner({
|
|
|
167
167
|
return (
|
|
168
168
|
<div className="mw-geocoder-demo">
|
|
169
169
|
<div className="mw-geocoder-demo__map">
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
170
|
+
{runtime.mapStyle ? (
|
|
171
|
+
<MapCanvas
|
|
172
|
+
mapStyle={runtime.mapStyle}
|
|
173
|
+
mapRef={mapRef}
|
|
174
|
+
initialViewState={{
|
|
175
|
+
longitude: runtime.initialCenter[0],
|
|
176
|
+
latitude: runtime.initialCenter[1],
|
|
177
|
+
zoom: runtime.initialZoom ?? 3,
|
|
178
|
+
}}
|
|
179
|
+
style={{ width: "100%", height: "100%" }}
|
|
180
|
+
starfield
|
|
181
|
+
// The attribution is compact.
|
|
182
|
+
// The MapLibre logo is hidden.
|
|
183
|
+
mapProps={{
|
|
184
|
+
attributionControl: { compact: true },
|
|
185
|
+
maplibreLogo: false,
|
|
186
|
+
onLoad: onMapLoad,
|
|
187
|
+
maxTileCacheSize: TILE_CACHE_SIZE,
|
|
188
|
+
}}
|
|
189
|
+
>
|
|
190
|
+
<GraticuleLayer beforeID={baseLayerID} />
|
|
191
|
+
<OverlayLayers overlays={runtime.overlays} beforeID={labelLayerID} />
|
|
192
|
+
<ResolvedPlaceLayers spec={spec} applyCamera={applyResultCamera} />
|
|
193
|
+
{panels.mapControls}
|
|
194
|
+
</MapCanvas>
|
|
195
|
+
) : null}
|
|
188
196
|
</div>
|
|
189
197
|
|
|
190
198
|
<GeocoderControls
|
|
@@ -206,6 +214,15 @@ function GeocoderInner({
|
|
|
206
214
|
)
|
|
207
215
|
}
|
|
208
216
|
|
|
217
|
+
/**
|
|
218
|
+
* The most tiles MapLibre keeps per source for tiles that have left the view.
|
|
219
|
+
*
|
|
220
|
+
* MapLibre otherwise sizes this cache from the viewport.
|
|
221
|
+
* On a tilted street view over dense building extrusions that kept about 1.2 MB of buffers
|
|
222
|
+
* per cached tile, 64 MB for 52 tiles over central Osaka, all of them out of view.
|
|
223
|
+
*/
|
|
224
|
+
const TILE_CACHE_SIZE = 16
|
|
225
|
+
|
|
209
226
|
// These defaults are module constants so each render sees the same reference and memo dependencies stay stable.
|
|
210
227
|
const NO_PANELS: GeocoderPanels = {}
|
|
211
228
|
const NO_PRESETS: ReadonlyArray<Preset> = []
|
|
@@ -24,7 +24,7 @@ import { MapCompass } from "./MapCompass.tsx"
|
|
|
24
24
|
import { MapControlButton, MapControlGroup, MapControlStack } from "./MapControlStack.tsx"
|
|
25
25
|
import { MapProgressBar } from "./MapProgressBar.tsx"
|
|
26
26
|
import { MapSearchBar, SearchGlyph } from "./MapSearchBar.tsx"
|
|
27
|
-
import { MapSheet
|
|
27
|
+
import { MapSheet } from "./MapSheet.tsx"
|
|
28
28
|
import { PlaceAutocomplete } from "./PlaceAutocomplete.tsx"
|
|
29
29
|
import { ResultPanel } from "./ResultPanel.tsx"
|
|
30
30
|
import { VersionPicker } from "./VersionPicker.tsx"
|
|
@@ -139,7 +139,7 @@ export function GeocoderControls({
|
|
|
139
139
|
|
|
140
140
|
// Drag gestures apply only in the drawer layout.
|
|
141
141
|
// The desktop column is sized by its content.
|
|
142
|
-
const isDrawerLayout = () => globalThis.window
|
|
142
|
+
const isDrawerLayout = () => globalThis.window && globalThis.matchMedia(DRAWER_LAYOUT).matches
|
|
143
143
|
|
|
144
144
|
const beginSheetDrag = useCallback((clientY: number, pointerId: number) => {
|
|
145
145
|
const sheet = sheetRef.current
|
|
@@ -300,6 +300,14 @@ export function GeocoderControls({
|
|
|
300
300
|
[onSubmitQuery, geocode]
|
|
301
301
|
)
|
|
302
302
|
|
|
303
|
+
// An emptied field removes the result and its pin.
|
|
304
|
+
// It also tells the host to drop the query from its URL.
|
|
305
|
+
const clearQuery = useCallback(() => {
|
|
306
|
+
geocode.reset()
|
|
307
|
+
setSheetHeight(null)
|
|
308
|
+
onSubmitQuery?.("")
|
|
309
|
+
}, [onSubmitQuery, geocode])
|
|
310
|
+
|
|
303
311
|
// The initial query waits for `runtime.ready` because the parse pipeline drops
|
|
304
312
|
// a submit made before the model loads.
|
|
305
313
|
// The ref makes it run once, so a later render cannot overwrite the user's own query.
|
|
@@ -387,8 +395,7 @@ export function GeocoderControls({
|
|
|
387
395
|
|
|
388
396
|
// The control rail hides while the drawer is raised above its collapsed height.
|
|
389
397
|
const drawerRaised =
|
|
390
|
-
showSheet &&
|
|
391
|
-
(sheetHeight === null || (globalThis.window !== undefined && sheetHeight > sheetDetents().collapsedBelow))
|
|
398
|
+
showSheet && (sheetHeight === null || (globalThis.window && sheetHeight > sheetDetents().collapsedBelow))
|
|
392
399
|
|
|
393
400
|
const bundleLoading = Boolean(loading && !runtime.ready)
|
|
394
401
|
const steps = loading?.stepLabels.length ?? 0
|
|
@@ -441,14 +448,6 @@ export function GeocoderControls({
|
|
|
441
448
|
}}
|
|
442
449
|
/>
|
|
443
450
|
) : null}
|
|
444
|
-
|
|
445
|
-
{showSheet ? (
|
|
446
|
-
<SheetClose
|
|
447
|
-
label="Close the result"
|
|
448
|
-
className="mw-map-sheet__close--floating"
|
|
449
|
-
onClose={() => setResultDismissed(true)}
|
|
450
|
-
/>
|
|
451
|
-
) : null}
|
|
452
451
|
</div>
|
|
453
452
|
|
|
454
453
|
<form
|
|
@@ -458,14 +457,28 @@ export function GeocoderControls({
|
|
|
458
457
|
runQuery(geocode.text)
|
|
459
458
|
}}
|
|
460
459
|
>
|
|
461
|
-
{/*
|
|
460
|
+
{/*
|
|
461
|
+
* The search bar has no trailing control because `type="search"`
|
|
462
|
+
* provides a native clear button.
|
|
463
|
+
*
|
|
464
|
+
* An empty field clears the result, its pin and the URL's query,
|
|
465
|
+
* so that button is the one way to clear a search.
|
|
466
|
+
*/}
|
|
462
467
|
<MapSearchBar label="Search addresses" leading={<SearchGlyph />} busy={busy}>
|
|
463
468
|
<input
|
|
464
469
|
id="mw-pipeline-input"
|
|
465
470
|
type="search"
|
|
466
471
|
aria-label="Address"
|
|
467
472
|
value={geocode.text}
|
|
468
|
-
onChange={(event) =>
|
|
473
|
+
onChange={(event) => {
|
|
474
|
+
const text = event.target.value
|
|
475
|
+
|
|
476
|
+
geocode.setText(text)
|
|
477
|
+
|
|
478
|
+
if (text === "") {
|
|
479
|
+
clearQuery()
|
|
480
|
+
}
|
|
481
|
+
}}
|
|
469
482
|
// Focus selects the value only while it equals the placeholder, so typing replaces it.
|
|
470
483
|
onFocus={(event) => {
|
|
471
484
|
if (placeholder && event.currentTarget.value === placeholder) {
|
package/lib/map/MapCanvas.tsx
CHANGED
|
@@ -21,10 +21,14 @@
|
|
|
21
21
|
* composed `Geocoder` will in a later phase.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
+
import { useState } from "react"
|
|
24
25
|
import type { CSSProperties, ReactNode, Ref } from "react"
|
|
25
26
|
import { Map } from "react-map-gl/maplibre"
|
|
26
27
|
import type { MapProps, MapRef, ViewStateChangeEvent } from "react-map-gl/maplibre"
|
|
27
28
|
|
|
29
|
+
import type { StarfieldOptions } from "#map/starfield"
|
|
30
|
+
import { StarfieldLayer } from "#map/StarfieldLayer"
|
|
31
|
+
|
|
28
32
|
/**
|
|
29
33
|
* The style a `<MapCanvas>` renders — a style URL or an inline/composed `StyleSpecification`.
|
|
30
34
|
*/
|
|
@@ -89,10 +93,25 @@ export interface MapCanvasProps {
|
|
|
89
93
|
* Other `<Map>` props that MapCanvas does not surface explicitly.
|
|
90
94
|
*/
|
|
91
95
|
mapProps?: MapCanvasExtraProps
|
|
96
|
+
/**
|
|
97
|
+
* Draw a procedural star sky around the globe.
|
|
98
|
+
*
|
|
99
|
+
* `true` uses the default sky, and an options object shapes it.
|
|
100
|
+
* The sky draws only while the projection is globe.
|
|
101
|
+
*
|
|
102
|
+
* @defaultValue `false`
|
|
103
|
+
*/
|
|
104
|
+
starfield?: boolean | StarfieldOptions
|
|
92
105
|
}
|
|
93
106
|
|
|
94
107
|
const FILL: CSSProperties = { width: "100%", height: "100%" }
|
|
95
108
|
|
|
109
|
+
// The sky canvas fills `.mw-demo-map`, which is positioned.
|
|
110
|
+
// The map follows it in document order, so it stacks above the sky,
|
|
111
|
+
// and its canvas stays transparent outside the globe.
|
|
112
|
+
const SKY: CSSProperties = { position: "absolute", inset: 0, width: "100%", height: "100%", pointerEvents: "none" }
|
|
113
|
+
const FILL_ABOVE_SKY: CSSProperties = { ...FILL, position: "relative" }
|
|
114
|
+
|
|
96
115
|
/**
|
|
97
116
|
* The controlled-viewport map shell.
|
|
98
117
|
*
|
|
@@ -111,11 +130,15 @@ export function MapCanvas({
|
|
|
111
130
|
className,
|
|
112
131
|
style,
|
|
113
132
|
mapProps,
|
|
133
|
+
starfield = false,
|
|
114
134
|
}: MapCanvasProps): ReactNode {
|
|
115
135
|
const wrapperClassName = className ? `mw-demo-map ${className}` : "mw-demo-map"
|
|
136
|
+
const [skyCanvas, setSkyCanvas] = useState<HTMLCanvasElement | null>(null)
|
|
137
|
+
const starfieldOptions = starfield === true ? {} : starfield || null
|
|
116
138
|
|
|
117
139
|
return (
|
|
118
140
|
<div className={wrapperClassName} style={style}>
|
|
141
|
+
{starfieldOptions ? <canvas ref={setSkyCanvas} style={SKY} aria-hidden="true" /> : null}
|
|
119
142
|
<Map
|
|
120
143
|
{...mapProps}
|
|
121
144
|
ref={mapRef}
|
|
@@ -124,8 +147,9 @@ export function MapCanvas({
|
|
|
124
147
|
viewState={viewState}
|
|
125
148
|
onMove={onMove}
|
|
126
149
|
projection={projection}
|
|
127
|
-
style={FILL}
|
|
150
|
+
style={starfieldOptions ? FILL_ABOVE_SKY : FILL}
|
|
128
151
|
>
|
|
152
|
+
{starfieldOptions ? <StarfieldLayer {...starfieldOptions} canvas={skyCanvas} /> : null}
|
|
129
153
|
{children}
|
|
130
154
|
</Map>
|
|
131
155
|
</div>
|
package/lib/map/PlaceMarker.tsx
CHANGED
|
@@ -12,13 +12,15 @@
|
|
|
12
12
|
* the `@mailwoman/react/map` subpath, never the package root.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import { Tokens } from "@sister.software/theme"
|
|
15
16
|
import type { ReactNode } from "react"
|
|
16
17
|
import { Marker } from "react-map-gl/maplibre"
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
|
-
* The
|
|
20
|
+
* The brand's selection accent (`--ss-color-cyan-electric`), which reads on
|
|
21
|
+
* both the light and dark basemaps.
|
|
20
22
|
*/
|
|
21
|
-
const MARKER_COLOR = "
|
|
23
|
+
const MARKER_COLOR = Tokens.resolve("color.cyan-electric")
|
|
22
24
|
|
|
23
25
|
export interface PlaceMarkerProps {
|
|
24
26
|
/**
|
|
@@ -4,15 +4,18 @@
|
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { Tokens } from "@sister.software/theme"
|
|
7
8
|
import type { ReactNode } from "react"
|
|
8
9
|
import { Layer, Source } from "react-map-gl/maplibre"
|
|
9
10
|
|
|
10
11
|
import type { PlaceGeometry } from "#map/geometry"
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* The
|
|
14
|
+
* The brand's selection accent, matched to {@link PlaceMarker}.
|
|
15
|
+
*
|
|
16
|
+
* MapLibre paint takes a literal color, so it is read from the theme's data rather than a custom property.
|
|
14
17
|
*/
|
|
15
|
-
const OUTLINE_COLOR = "
|
|
18
|
+
const OUTLINE_COLOR = Tokens.resolve("color.cyan-electric")
|
|
16
19
|
|
|
17
20
|
export interface ResultOverlayProps {
|
|
18
21
|
/**
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Paints the procedural star sky onto a canvas that sits behind the map.
|
|
7
|
+
*
|
|
8
|
+
* Under globe projection MapLibre leaves its canvas transparent outside the sphere, so a canvas stacked beneath it
|
|
9
|
+
* shows through around the globe. This component renders as a `<Map>` child so it can read the map instance.
|
|
10
|
+
* It redraws the sky canvas that `<MapCanvas>` owns on every camera move.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { useEffect, useMemo } from "react"
|
|
14
|
+
import type { ReactNode } from "react"
|
|
15
|
+
import { useMap } from "react-map-gl/maplibre"
|
|
16
|
+
|
|
17
|
+
import { drawStarfield, generateStarfield } from "#map/starfield"
|
|
18
|
+
import type { StarfieldOptions } from "#map/starfield"
|
|
19
|
+
|
|
20
|
+
export interface StarfieldLayerProps extends StarfieldOptions {
|
|
21
|
+
/**
|
|
22
|
+
* The canvas behind the map that receives the sky.
|
|
23
|
+
*/
|
|
24
|
+
canvas: HTMLCanvasElement | null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Keeps the sky canvas in step with the map camera.
|
|
29
|
+
*/
|
|
30
|
+
export function StarfieldLayer({
|
|
31
|
+
canvas,
|
|
32
|
+
count,
|
|
33
|
+
seed,
|
|
34
|
+
bandShare,
|
|
35
|
+
background = "#02030a",
|
|
36
|
+
}: StarfieldLayerProps): ReactNode {
|
|
37
|
+
const { current: mapRef } = useMap()
|
|
38
|
+
const map = mapRef?.getMap()
|
|
39
|
+
const catalog = useMemo(() => generateStarfield({ count, seed, bandShare }), [count, seed, bandShare])
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!map || !canvas) return
|
|
43
|
+
|
|
44
|
+
const context = canvas.getContext("2d")
|
|
45
|
+
|
|
46
|
+
if (!context) return
|
|
47
|
+
|
|
48
|
+
let frame = 0
|
|
49
|
+
|
|
50
|
+
const paint = () => {
|
|
51
|
+
frame = 0
|
|
52
|
+
|
|
53
|
+
const width = canvas.clientWidth
|
|
54
|
+
const height = canvas.clientHeight
|
|
55
|
+
const ratio = window.devicePixelRatio || 1
|
|
56
|
+
const pixelWidth = Math.round(width * ratio)
|
|
57
|
+
const pixelHeight = Math.round(height * ratio)
|
|
58
|
+
|
|
59
|
+
if (canvas.width !== pixelWidth || canvas.height !== pixelHeight) {
|
|
60
|
+
canvas.width = pixelWidth
|
|
61
|
+
canvas.height = pixelHeight
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
context.setTransform(ratio, 0, 0, ratio, 0, 0)
|
|
65
|
+
|
|
66
|
+
// Mercator fills the canvas edge to edge, so the sky shows only around a globe.
|
|
67
|
+
if (map.getProjection()?.type !== "globe") {
|
|
68
|
+
context.clearRect(0, 0, width, height)
|
|
69
|
+
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const center = map.getCenter()
|
|
74
|
+
|
|
75
|
+
drawStarfield(
|
|
76
|
+
context,
|
|
77
|
+
catalog,
|
|
78
|
+
{
|
|
79
|
+
lng: center.lng,
|
|
80
|
+
lat: center.lat,
|
|
81
|
+
bearing: map.getBearing(),
|
|
82
|
+
pitch: map.getPitch(),
|
|
83
|
+
fov: map.getVerticalFieldOfView(),
|
|
84
|
+
},
|
|
85
|
+
width,
|
|
86
|
+
height,
|
|
87
|
+
background
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const schedule = () => {
|
|
92
|
+
if (!frame) {
|
|
93
|
+
frame = requestAnimationFrame(paint)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
schedule()
|
|
98
|
+
map.on("move", schedule)
|
|
99
|
+
map.on("resize", schedule)
|
|
100
|
+
map.on("styledata", schedule)
|
|
101
|
+
|
|
102
|
+
return () => {
|
|
103
|
+
if (frame) {
|
|
104
|
+
cancelAnimationFrame(frame)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
map.off("move", schedule)
|
|
108
|
+
map.off("resize", schedule)
|
|
109
|
+
map.off("styledata", schedule)
|
|
110
|
+
}
|
|
111
|
+
}, [map, canvas, catalog, background])
|
|
112
|
+
|
|
113
|
+
return null
|
|
114
|
+
}
|