topographic-react 0.1.0 → 0.2.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 CHANGED
@@ -22,6 +22,8 @@ export function Hero() {
22
22
  }
23
23
  ```
24
24
 
25
+ For the 3D terrain, add `mode="3d"`, and optionally `elevation`, `extent`, `detail` and `camera`.
26
+
25
27
  To put the background on your own element, use `useTopographicBackground(settings)`, which returns a ref.
26
28
 
27
29
  - [Project README](https://github.com/yahyabedirhan/topographic#readme)
@@ -9,6 +9,12 @@ export interface TopographicBackgroundSettingsProps {
9
9
  motion?: SettingsInput['motion'];
10
10
  layout?: SettingsInput['layout'];
11
11
  theme?: SettingsInput['theme'];
12
+ /** '2d' is the map. '3d' is the same map as a terrain. */
13
+ mode?: SettingsInput['mode'];
14
+ elevation?: number;
15
+ extent?: SettingsInput['extent'];
16
+ detail?: number;
17
+ camera?: SettingsInput['camera'];
12
18
  }
13
19
  export interface TopographicBackgroundRef<T extends HTMLElement = HTMLDivElement> extends MutableRefObject<T | null> {
14
20
  /** The live instance while mounted (for snapshot, or imperative updates). */
@@ -24,12 +24,13 @@ function useTopographicBackground(settings = {}, options) {
24
24
  ref.topographic = null;
25
25
  };
26
26
  }, [ref, stableOptions]);
27
- const { styleName, seed } = settings;
27
+ const { styleName, seed, mode, elevation, extent, detail } = settings;
28
28
  const lines = useByValue(settings.lines);
29
29
  const terrain = useByValue(settings.terrain);
30
30
  const motion = useByValue(settings.motion);
31
31
  const layout = useByValue(settings.layout);
32
32
  const theme = useByValue(settings.theme);
33
+ const camera = useByValue(settings.camera);
33
34
  useEffect(() => {
34
35
  if (styleName !== void 0) ref.topographic?.update({ style: styleName });
35
36
  }, [ref, styleName]);
@@ -51,10 +52,25 @@ function useTopographicBackground(settings = {}, options) {
51
52
  useEffect(() => {
52
53
  if (theme) ref.topographic?.update({ theme });
53
54
  }, [ref, theme]);
55
+ useEffect(() => {
56
+ if (mode !== void 0) ref.topographic?.update({ mode });
57
+ }, [ref, mode]);
58
+ useEffect(() => {
59
+ if (elevation !== void 0) ref.topographic?.update({ elevation });
60
+ }, [ref, elevation]);
61
+ useEffect(() => {
62
+ if (extent !== void 0) ref.topographic?.update({ extent });
63
+ }, [ref, extent]);
64
+ useEffect(() => {
65
+ if (detail !== void 0) ref.topographic?.update({ detail });
66
+ }, [ref, detail]);
67
+ useEffect(() => {
68
+ if (camera) ref.topographic?.update({ camera });
69
+ }, [ref, camera]);
54
70
  return ref;
55
71
  }
56
- const TopographicBackground = forwardRef(function TopographicBackground2({ styleName, seed, lines, terrain, motion, layout, theme, options, onReady, style, children, ...div }, forwarded) {
57
- const ref = useTopographicBackground({ styleName, seed, lines, terrain, motion, layout, theme }, options);
72
+ const TopographicBackground = forwardRef(function TopographicBackground2({ styleName, seed, lines, terrain, motion, layout, theme, mode, elevation, extent, detail, camera, options, onReady, style, children, ...div }, forwarded) {
73
+ const ref = useTopographicBackground({ styleName, seed, lines, terrain, motion, layout, theme, mode, elevation, extent, detail, camera }, options);
58
74
  const stableOptions = useByValue(options);
59
75
  const ready = useRef(onReady);
60
76
  ready.current = onReady;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "topographic-react",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "React component and hook for topographic backgrounds.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -39,7 +39,7 @@
39
39
  "LICENSE"
40
40
  ],
41
41
  "dependencies": {
42
- "topographic": "^0.1.0"
42
+ "topographic": "^0.2.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "react": "^18 || ^19"