@dxos/react-ui-geo 0.8.4-main.c1de068 → 0.8.4-main.fd6878d
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/lib/browser/index.mjs +171 -143
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +171 -143
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Globe/Globe.d.ts +1 -1
- package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
- package/dist/types/src/components/Map/Map.d.ts +25 -12
- package/dist/types/src/components/Map/Map.d.ts.map +1 -1
- package/dist/types/src/components/Map/Map.stories.d.ts +3 -3
- package/dist/types/src/components/Map/Map.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Controls.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/context.d.ts +7 -7
- package/dist/types/src/hooks/context.d.ts.map +1 -1
- package/dist/types/src/hooks/useGlobeZoomHandler.d.ts +1 -1
- package/dist/types/src/hooks/useGlobeZoomHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useMapZoomHandler.d.ts +1 -1
- package/dist/types/src/hooks/useMapZoomHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useSpinner.d.ts +1 -1
- package/dist/types/src/hooks/useSpinner.d.ts.map +1 -1
- package/dist/types/src/hooks/useTour.d.ts +4 -3
- package/dist/types/src/hooks/useTour.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +2 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util/path.d.ts +5 -8
- package/dist/types/src/util/path.d.ts.map +1 -1
- package/dist/types/src/util/render.d.ts +4 -4
- package/dist/types/src/util/render.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -11
- package/src/components/Globe/Globe.stories.tsx +25 -20
- package/src/components/Globe/Globe.tsx +50 -30
- package/src/components/Map/Map.stories.tsx +16 -7
- package/src/components/Map/Map.tsx +206 -91
- package/src/components/Toolbar/Controls.tsx +2 -6
- package/src/components/index.ts +0 -2
- package/src/hooks/context.tsx +10 -10
- package/src/hooks/useGlobeZoomHandler.ts +3 -3
- package/src/hooks/useMapZoomHandler.ts +1 -1
- package/src/hooks/useSpinner.ts +2 -1
- package/src/hooks/useTour.ts +9 -8
- package/src/types.ts +3 -1
- package/src/util/inertia.ts +1 -1
- package/src/util/path.ts +5 -6
- package/src/util/render.ts +5 -3
- package/dist/types/src/components/types.d.ts +0 -15
- package/dist/types/src/components/types.d.ts.map +0 -1
- package/src/components/types.ts +0 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-geo",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.fd6878d",
|
|
4
4
|
"description": "Geo components.",
|
|
5
5
|
"homepage": "https://github.com/dxos",
|
|
6
6
|
"bugs": "https://github.com/dxos/issues",
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
"./data": {
|
|
13
|
+
"source": "./src/data.ts",
|
|
13
14
|
"types": "./dist/types/src/data.d.ts",
|
|
14
15
|
"browser": "./dist/lib/browser/data.mjs",
|
|
15
16
|
"node": "./dist/lib/node-esm/data.mjs"
|
|
16
17
|
},
|
|
17
18
|
".": {
|
|
19
|
+
"source": "./src/index.ts",
|
|
18
20
|
"types": "./dist/types/src/index.d.ts",
|
|
19
21
|
"browser": "./dist/lib/browser/index.mjs",
|
|
20
22
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
@@ -35,6 +37,7 @@
|
|
|
35
37
|
],
|
|
36
38
|
"dependencies": {
|
|
37
39
|
"@preact-signals/safe-react": "^0.9.0",
|
|
40
|
+
"@radix-ui/react-context": "^1.0.5",
|
|
38
41
|
"d3": "^7.9.0",
|
|
39
42
|
"d3-geo-projection": "^4.0.0",
|
|
40
43
|
"d3-hexbin": "^0.2.2",
|
|
@@ -46,11 +49,11 @@
|
|
|
46
49
|
"topojson-client": "^3.1.0",
|
|
47
50
|
"topojson-simplify": "^3.0.3",
|
|
48
51
|
"versor": "^0.2.0",
|
|
49
|
-
"@dxos/async": "0.8.4-main.
|
|
50
|
-
"@dxos/debug": "0.8.4-main.
|
|
51
|
-
"@dxos/log": "0.8.4-main.
|
|
52
|
-
"@dxos/node-std": "0.8.4-main.
|
|
53
|
-
"@dxos/util": "0.8.4-main.
|
|
52
|
+
"@dxos/async": "0.8.4-main.fd6878d",
|
|
53
|
+
"@dxos/debug": "0.8.4-main.fd6878d",
|
|
54
|
+
"@dxos/log": "0.8.4-main.fd6878d",
|
|
55
|
+
"@dxos/node-std": "0.8.4-main.fd6878d",
|
|
56
|
+
"@dxos/util": "0.8.4-main.fd6878d"
|
|
54
57
|
},
|
|
55
58
|
"devDependencies": {
|
|
56
59
|
"@react-three/drei": "^9.99.0",
|
|
@@ -70,15 +73,15 @@
|
|
|
70
73
|
"react": "~18.2.0",
|
|
71
74
|
"react-dom": "~18.2.0",
|
|
72
75
|
"three": "0.165.0",
|
|
73
|
-
"@dxos/react-ui
|
|
74
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
75
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
76
|
+
"@dxos/react-ui": "0.8.4-main.fd6878d",
|
|
77
|
+
"@dxos/react-ui-theme": "0.8.4-main.fd6878d",
|
|
78
|
+
"@dxos/storybook-utils": "0.8.4-main.fd6878d"
|
|
76
79
|
},
|
|
77
80
|
"peerDependencies": {
|
|
78
81
|
"react": "~18.2.0",
|
|
79
82
|
"react-dom": "~18.2.0",
|
|
80
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
81
|
-
"@dxos/react-ui
|
|
83
|
+
"@dxos/react-ui-theme": "0.8.4-main.fd6878d",
|
|
84
|
+
"@dxos/react-ui": "0.8.4-main.fd6878d"
|
|
82
85
|
},
|
|
83
86
|
"publishConfig": {
|
|
84
87
|
"access": "public"
|
|
@@ -11,13 +11,15 @@ import React, { useMemo, useRef, useState } from 'react';
|
|
|
11
11
|
import { type Topology } from 'topojson-specification';
|
|
12
12
|
|
|
13
13
|
import { useAsyncState } from '@dxos/react-ui';
|
|
14
|
-
import {
|
|
14
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
15
15
|
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
16
|
+
import { type Vector, useDrag, useGlobeZoomHandler, useSpinner, useTour } from '../../hooks';
|
|
17
|
+
import { type LatLngLiteral } from '../../types';
|
|
18
|
+
import { type StyleSet, closestPoint } from '../../util';
|
|
19
19
|
import { type ControlProps } from '../Toolbar';
|
|
20
20
|
|
|
21
|
+
import { Globe, type GlobeCanvasProps, type GlobeController, type GlobeRootProps } from './Globe';
|
|
22
|
+
|
|
21
23
|
// TODO(burdon): Load from JSON at runtime?
|
|
22
24
|
const useTopology = () => {
|
|
23
25
|
return useAsyncState(async () => (await import('../../../data/countries-110m.ts')).default);
|
|
@@ -95,8 +97,11 @@ const createTrip = (
|
|
|
95
97
|
routes: Record<string, string[]>,
|
|
96
98
|
points: Position[] = [],
|
|
97
99
|
) => {
|
|
98
|
-
let previousHub:
|
|
99
|
-
return Object.entries(routes).reduce<{
|
|
100
|
+
let previousHub: LatLngLiteral;
|
|
101
|
+
return Object.entries(routes).reduce<{
|
|
102
|
+
points: LatLngLiteral[];
|
|
103
|
+
lines: { source: LatLngLiteral; target: LatLngLiteral }[];
|
|
104
|
+
}>(
|
|
100
105
|
(features, [hub, regional]) => {
|
|
101
106
|
const hubAirport = airports.features.find(({ properties }) => properties.iata === hub);
|
|
102
107
|
if (hubAirport) {
|
|
@@ -125,7 +130,7 @@ const createTrip = (
|
|
|
125
130
|
);
|
|
126
131
|
};
|
|
127
132
|
|
|
128
|
-
type StoryProps = Pick<GlobeRootProps, '
|
|
133
|
+
type StoryProps = Pick<GlobeRootProps, 'zoom' | 'translation' | 'rotation'> &
|
|
129
134
|
Pick<GlobeCanvasProps, 'projection' | 'styles'> & {
|
|
130
135
|
drag?: boolean;
|
|
131
136
|
spin?: boolean;
|
|
@@ -134,7 +139,7 @@ type StoryProps = Pick<GlobeRootProps, 'scale' | 'translation' | 'rotation'> &
|
|
|
134
139
|
};
|
|
135
140
|
|
|
136
141
|
const Story = ({
|
|
137
|
-
|
|
142
|
+
zoom: _zoom = 1,
|
|
138
143
|
translation,
|
|
139
144
|
rotation = [0, 0, 0],
|
|
140
145
|
projection,
|
|
@@ -188,18 +193,18 @@ const Story = ({
|
|
|
188
193
|
break;
|
|
189
194
|
}
|
|
190
195
|
case 'zoom-in': {
|
|
191
|
-
controller.current.
|
|
196
|
+
controller.current.setZoom((scale) => scale * 1.1);
|
|
192
197
|
break;
|
|
193
198
|
}
|
|
194
199
|
case 'zoom-out': {
|
|
195
|
-
controller.current.
|
|
200
|
+
controller.current.setZoom((scale) => scale * 0.9);
|
|
196
201
|
break;
|
|
197
202
|
}
|
|
198
203
|
}
|
|
199
204
|
};
|
|
200
205
|
|
|
201
206
|
return (
|
|
202
|
-
<Globe.Root classNames='absolute inset-0'
|
|
207
|
+
<Globe.Root classNames='absolute inset-0' zoom={_zoom} translation={translation} rotation={rotation}>
|
|
203
208
|
<Globe.Canvas
|
|
204
209
|
ref={controller}
|
|
205
210
|
topology={styles?.dots ? dots : topology}
|
|
@@ -234,7 +239,7 @@ export const Earth1 = () => {
|
|
|
234
239
|
useDrag(controller);
|
|
235
240
|
|
|
236
241
|
return (
|
|
237
|
-
<Globe.Root
|
|
242
|
+
<Globe.Root zoom={1.2} rotation={[Math.random() * 360, 0, 0]}>
|
|
238
243
|
<Globe.Canvas ref={setController} topology={topology} styles={defaultStyles} />
|
|
239
244
|
<Globe.Zoom onAction={handleAction} />
|
|
240
245
|
</Globe.Root>
|
|
@@ -249,7 +254,7 @@ export const Earth2 = () => {
|
|
|
249
254
|
|
|
250
255
|
return (
|
|
251
256
|
<div className='absolute bottom-0 left-0 right-0 '>
|
|
252
|
-
<Globe.Root classNames='h-[400px]'
|
|
257
|
+
<Globe.Root classNames='h-[400px]' zoom={2.8} translation={{ x: 0, y: 400 }}>
|
|
253
258
|
<Globe.Canvas ref={setController} topology={topology} styles={defaultStyles} />
|
|
254
259
|
<Globe.Zoom onAction={handleAction} />
|
|
255
260
|
</Globe.Root>
|
|
@@ -283,7 +288,7 @@ export const Mercator = () => {
|
|
|
283
288
|
useDrag(controller);
|
|
284
289
|
|
|
285
290
|
return (
|
|
286
|
-
<Globe.Root classNames='flex grow overflow-hidden'
|
|
291
|
+
<Globe.Root classNames='flex grow overflow-hidden' zoom={0.7} rotation={initialRotation}>
|
|
287
292
|
<Globe.Canvas ref={setController} topology={topology} projection='mercator' styles={monochrome} />
|
|
288
293
|
<Globe.Zoom onAction={handleAction} />
|
|
289
294
|
</Globe.Root>
|
|
@@ -291,25 +296,25 @@ export const Mercator = () => {
|
|
|
291
296
|
};
|
|
292
297
|
|
|
293
298
|
export const Globe1 = () => {
|
|
294
|
-
return <Story drag projection='mercator'
|
|
299
|
+
return <Story drag projection='mercator' zoom={0.8} rotation={initialRotation} styles={defaultStyles} />;
|
|
295
300
|
};
|
|
296
301
|
|
|
297
302
|
export const Globe2 = () => {
|
|
298
|
-
return <Story drag projection='transverse-mercator'
|
|
303
|
+
return <Story drag projection='transverse-mercator' zoom={0.8} rotation={initialRotation} styles={defaultStyles} />;
|
|
299
304
|
};
|
|
300
305
|
|
|
301
306
|
export const Globe3 = () => {
|
|
302
|
-
return <Story drag spin
|
|
307
|
+
return <Story drag spin zoom={1.5} rotation={initialRotation} styles={defaultStyles} />;
|
|
303
308
|
};
|
|
304
309
|
|
|
305
310
|
export const Globe4 = () => {
|
|
306
|
-
return <Story drag tour
|
|
311
|
+
return <Story drag tour zoom={2} rotation={initialRotation} styles={defaultStyles} />;
|
|
307
312
|
};
|
|
308
313
|
|
|
309
314
|
export const Globe5 = () => {
|
|
310
|
-
return <Story drag tour
|
|
315
|
+
return <Story drag tour zoom={0.9} rotation={initialRotation} styles={dotStyles} />;
|
|
311
316
|
};
|
|
312
317
|
|
|
313
318
|
export const Globe6 = () => {
|
|
314
|
-
return <Story drag xAxis tour
|
|
319
|
+
return <Story drag xAxis tour zoom={2} translation={{ x: 0, y: 600 }} rotation={[0, -20, 0]} styles={dotStyles} />;
|
|
315
320
|
};
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
type GeoProjection,
|
|
7
|
+
easeLinear,
|
|
8
|
+
easeSinOut,
|
|
7
9
|
geoMercator,
|
|
8
10
|
geoOrthographic,
|
|
9
11
|
geoPath,
|
|
10
12
|
geoTransverseMercator,
|
|
11
13
|
interpolateNumber,
|
|
12
14
|
transition,
|
|
13
|
-
easeLinear,
|
|
14
|
-
easeSinOut,
|
|
15
15
|
} from 'd3';
|
|
16
16
|
import { type ControlPosition } from 'leaflet';
|
|
17
17
|
import React, {
|
|
@@ -26,7 +26,7 @@ import React, {
|
|
|
26
26
|
import { useResizeDetector } from 'react-resize-detector';
|
|
27
27
|
import { type Topology } from 'topojson-specification';
|
|
28
28
|
|
|
29
|
-
import { type
|
|
29
|
+
import { type ThemeMode, type ThemedClassName, useDynamicRef, useThemeContext } from '@dxos/react-ui';
|
|
30
30
|
import { mx } from '@dxos/react-ui-theme';
|
|
31
31
|
|
|
32
32
|
import {
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
renderLayers,
|
|
45
45
|
timer,
|
|
46
46
|
} from '../../util';
|
|
47
|
-
import {
|
|
47
|
+
import { ActionControls, type ControlProps, ZoomControls, controlPositions } from '../Toolbar';
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
|
|
@@ -103,7 +103,7 @@ const defaultStyles: Record<ThemeMode, StyleSet> = {
|
|
|
103
103
|
export type GlobeController = {
|
|
104
104
|
canvas: HTMLCanvasElement;
|
|
105
105
|
projection: GeoProjection;
|
|
106
|
-
} & Pick<GlobeContextType, '
|
|
106
|
+
} & Pick<GlobeContextType, 'zoom' | 'translation' | 'rotation' | 'setZoom' | 'setTranslation' | 'setRotation'>;
|
|
107
107
|
|
|
108
108
|
export type ProjectionType = 'orthographic' | 'mercator' | 'transverse-mercator';
|
|
109
109
|
|
|
@@ -154,6 +154,7 @@ type GlobeCanvasProps = {
|
|
|
154
154
|
* Basic globe renderer.
|
|
155
155
|
* https://github.com/topojson/world-atlas
|
|
156
156
|
*/
|
|
157
|
+
// TODO(burdon): Move controller to root.
|
|
157
158
|
const GlobeCanvas = forwardRef<GlobeController, GlobeCanvasProps>(
|
|
158
159
|
({ projection: _projection, topology, features, styles: _styles }, forwardRef) => {
|
|
159
160
|
const { themeMode } = useThemeContext();
|
|
@@ -173,15 +174,14 @@ const GlobeCanvas = forwardRef<GlobeController, GlobeCanvasProps>(
|
|
|
173
174
|
}, [topology, features, styles]);
|
|
174
175
|
|
|
175
176
|
// State.
|
|
176
|
-
const { size, center,
|
|
177
|
+
const { size, center, zoom, translation, rotation, setCenter, setZoom, setTranslation, setRotation } =
|
|
177
178
|
useGlobeContext();
|
|
178
|
-
|
|
179
|
-
const scaleRef = useDynamicRef(scale);
|
|
179
|
+
const zoomRef = useDynamicRef(zoom);
|
|
180
180
|
|
|
181
181
|
// Update rotation.
|
|
182
182
|
useEffect(() => {
|
|
183
183
|
if (center) {
|
|
184
|
-
|
|
184
|
+
setZoom(1);
|
|
185
185
|
setRotation(positionToRotation(geoToPosition(center)));
|
|
186
186
|
}
|
|
187
187
|
}, [center]);
|
|
@@ -193,25 +193,25 @@ const GlobeCanvas = forwardRef<GlobeController, GlobeCanvasProps>(
|
|
|
193
193
|
canvas,
|
|
194
194
|
projection,
|
|
195
195
|
center,
|
|
196
|
-
get
|
|
197
|
-
return
|
|
196
|
+
get zoom() {
|
|
197
|
+
return zoomRef.current;
|
|
198
198
|
},
|
|
199
199
|
translation,
|
|
200
200
|
rotation,
|
|
201
201
|
setCenter,
|
|
202
|
-
|
|
202
|
+
setZoom: (s) => {
|
|
203
203
|
if (typeof s === 'function') {
|
|
204
|
-
const is = interpolateNumber(
|
|
204
|
+
const is = interpolateNumber(zoomRef.current, s(zoomRef.current));
|
|
205
205
|
// Stop easing if already zooming.
|
|
206
206
|
transition()
|
|
207
207
|
.ease(zooming.current ? easeLinear : easeSinOut)
|
|
208
208
|
.duration(200)
|
|
209
|
-
.tween('scale', () => (t) =>
|
|
209
|
+
.tween('scale', () => (t) => setZoom(is(t)))
|
|
210
210
|
.on('end', () => {
|
|
211
211
|
zooming.current = false;
|
|
212
212
|
});
|
|
213
213
|
} else {
|
|
214
|
-
|
|
214
|
+
setZoom(s);
|
|
215
215
|
}
|
|
216
216
|
},
|
|
217
217
|
setTranslation,
|
|
@@ -232,14 +232,14 @@ const GlobeCanvas = forwardRef<GlobeController, GlobeCanvasProps>(
|
|
|
232
232
|
timer(() => {
|
|
233
233
|
// https://d3js.org/d3-geo/projection
|
|
234
234
|
projection
|
|
235
|
-
.scale((Math.min(size.width, size.height) / 2) *
|
|
235
|
+
.scale((Math.min(size.width, size.height) / 2) * zoom)
|
|
236
236
|
.translate([size.width / 2 + (translation?.x ?? 0), size.height / 2 + (translation?.y ?? 0)])
|
|
237
237
|
.rotate(rotation ?? [0, 0, 0]);
|
|
238
238
|
|
|
239
|
-
renderLayers(generator, layers,
|
|
239
|
+
renderLayers(generator, layers, zoom, styles);
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
|
-
}, [generator, size,
|
|
242
|
+
}, [generator, size, zoom, translation, rotation, layers]);
|
|
243
243
|
|
|
244
244
|
if (!size.width || !size.height) {
|
|
245
245
|
return null;
|
|
@@ -249,8 +249,12 @@ const GlobeCanvas = forwardRef<GlobeController, GlobeCanvasProps>(
|
|
|
249
249
|
},
|
|
250
250
|
);
|
|
251
251
|
|
|
252
|
+
//
|
|
253
|
+
// Debug
|
|
254
|
+
//
|
|
255
|
+
|
|
252
256
|
const GlobeDebug = ({ position = 'topleft' }: { position?: ControlPosition }) => {
|
|
253
|
-
const { size,
|
|
257
|
+
const { size, zoom, translation, rotation } = useGlobeContext();
|
|
254
258
|
return (
|
|
255
259
|
<div
|
|
256
260
|
className={mx(
|
|
@@ -259,12 +263,16 @@ const GlobeDebug = ({ position = 'topleft' }: { position?: ControlPosition }) =>
|
|
|
259
263
|
)}
|
|
260
264
|
>
|
|
261
265
|
<pre className='font-mono text-xs text-green-700'>
|
|
262
|
-
{JSON.stringify({ size,
|
|
266
|
+
{JSON.stringify({ size, zoom, translation, rotation }, null, 2)}
|
|
263
267
|
</pre>
|
|
264
268
|
</div>
|
|
265
269
|
);
|
|
266
270
|
};
|
|
267
271
|
|
|
272
|
+
//
|
|
273
|
+
// Panel
|
|
274
|
+
//
|
|
275
|
+
|
|
268
276
|
const GlobePanel = ({
|
|
269
277
|
position,
|
|
270
278
|
classNames,
|
|
@@ -273,25 +281,37 @@ const GlobePanel = ({
|
|
|
273
281
|
return <div className={mx('z-10 absolute overflow-hidden', controlPositions[position], classNames)}>{children}</div>;
|
|
274
282
|
};
|
|
275
283
|
|
|
284
|
+
//
|
|
285
|
+
// Controls
|
|
286
|
+
//
|
|
287
|
+
|
|
276
288
|
const CustomControl = ({ position, children }: PropsWithChildren<{ position: ControlPosition }>) => {
|
|
277
289
|
return <div className={mx('z-10 absolute overflow-hidden', controlPositions[position])}>{children}</div>;
|
|
278
290
|
};
|
|
279
291
|
|
|
280
292
|
type GlobeControlProps = { position?: ControlPosition } & Pick<ControlProps, 'onAction'>;
|
|
281
293
|
|
|
294
|
+
const GlobeZoom = ({ onAction, position = 'bottomleft', ...props }: GlobeControlProps) => (
|
|
295
|
+
<CustomControl position={position} {...props}>
|
|
296
|
+
<ZoomControls onAction={onAction} />
|
|
297
|
+
</CustomControl>
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
const GlobeAction = ({ onAction, position = 'bottomright', ...props }: GlobeControlProps) => (
|
|
301
|
+
<CustomControl position={position} {...props}>
|
|
302
|
+
<ActionControls onAction={onAction} />
|
|
303
|
+
</CustomControl>
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
//
|
|
307
|
+
// Globe
|
|
308
|
+
//
|
|
309
|
+
|
|
282
310
|
export const Globe = {
|
|
283
311
|
Root: GlobeRoot,
|
|
284
312
|
Canvas: GlobeCanvas,
|
|
285
|
-
Zoom:
|
|
286
|
-
|
|
287
|
-
<ZoomControls onAction={onAction} />
|
|
288
|
-
</CustomControl>
|
|
289
|
-
),
|
|
290
|
-
Action: ({ onAction, position = 'bottomright', ...props }: GlobeControlProps) => (
|
|
291
|
-
<CustomControl position={position} {...props}>
|
|
292
|
-
<ActionControls onAction={onAction} />
|
|
293
|
-
</CustomControl>
|
|
294
|
-
),
|
|
313
|
+
Zoom: GlobeZoom,
|
|
314
|
+
Action: GlobeAction,
|
|
295
315
|
Debug: GlobeDebug,
|
|
296
316
|
Panel: GlobePanel,
|
|
297
317
|
};
|
|
@@ -4,22 +4,24 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import React, { useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
11
11
|
|
|
12
|
-
import { Map, type MapController } from './Map';
|
|
13
12
|
import { useMapZoomHandler } from '../../hooks';
|
|
14
|
-
import { type
|
|
13
|
+
import { type GeoMarker } from '../../types';
|
|
14
|
+
|
|
15
|
+
import { Map, type MapController } from './Map';
|
|
15
16
|
|
|
16
|
-
const DefaultStory = ({ markers = [] }: { markers?:
|
|
17
|
+
const DefaultStory = ({ markers = [] }: { markers?: GeoMarker[] }) => {
|
|
17
18
|
const [controller, setController] = useState<MapController>();
|
|
18
19
|
const handleZoomAction = useMapZoomHandler(controller);
|
|
19
20
|
|
|
20
21
|
return (
|
|
21
|
-
<Map.Root>
|
|
22
|
-
<Map.
|
|
22
|
+
<Map.Root ref={setController}>
|
|
23
|
+
<Map.Tiles />
|
|
24
|
+
<Map.Markers markers={markers} />
|
|
23
25
|
<Map.Zoom position='bottomleft' onAction={handleZoomAction} />
|
|
24
26
|
<Map.Action position='bottomright' />
|
|
25
27
|
</Map.Root>
|
|
@@ -41,6 +43,13 @@ export const Default: Story = {};
|
|
|
41
43
|
export const WithMarkers: Story = {
|
|
42
44
|
args: {
|
|
43
45
|
markers: [
|
|
46
|
+
{ id: 'los angeles', title: 'Los Angeles', location: { lat: 34.0522, lng: -118.2437 } },
|
|
47
|
+
{ id: 'new york', title: 'New York', location: { lat: 40.7128, lng: -74.006 } },
|
|
48
|
+
{ id: 'warsaw', title: 'Warsaw', location: { lat: 52.2297, lng: 21.0122 } },
|
|
49
|
+
{ id: 'london', title: 'London', location: { lat: 51.5074, lng: -0.1278 } },
|
|
50
|
+
{ id: 'toronto', title: 'Toronto', location: { lat: 43.6532, lng: -79.3832 } },
|
|
51
|
+
{ id: 'seattle', title: 'Seattle', location: { lat: 47.6062, lng: -122.3321 } },
|
|
52
|
+
{ id: 'barcelona', title: 'Barcelona', location: { lat: 41.3851, lng: 2.1734 } },
|
|
44
53
|
{ id: 'tokyo', title: 'Tokyo', location: { lat: 35.6762, lng: 139.6503 } },
|
|
45
54
|
{ id: 'sydney', title: 'Sydney', location: { lat: -33.8688, lng: 151.2093 } },
|
|
46
55
|
{ id: 'auckland', title: 'Auckland', location: { lat: -36.8509, lng: 174.7645 } },
|
|
@@ -56,6 +65,6 @@ export const WithMarkers: Story = {
|
|
|
56
65
|
{ id: 'phnom-penh', title: 'Phnom Penh', location: { lat: 11.5564, lng: 104.9282 } },
|
|
57
66
|
{ id: 'vientiane', title: 'Vientiane', location: { lat: 17.9757, lng: 102.6331 } },
|
|
58
67
|
{ id: 'yangon', title: 'Yangon', location: { lat: 16.8661, lng: 96.1951 } },
|
|
59
|
-
] as
|
|
68
|
+
] as GeoMarker[],
|
|
60
69
|
},
|
|
61
70
|
};
|