diff --git a/src/components/GraphViewport.tsx b/src/components/GraphViewport.tsx
index 0e50c1a5..8d8b615d 100644
--- a/src/components/GraphViewport.tsx
+++ b/src/components/GraphViewport.tsx
@@ -1,9 +1,14 @@
import Box from '@mui/material/Box';
+import IconButton from '@mui/material/IconButton';
+import Stack from '@mui/material/Stack';
import { Component, createRef } from 'react';
import { renderSvg } from '../graph/svg-renderer';
import { TypeGraph } from '../graph/type-graph';
import { Viewport } from '../graph/viewport';
+import ZoomInIcon from './icons/zoom-in.svg';
+import ZoomOutIcon from './icons/zoom-out.svg';
+import ZoomResetIcon from './icons/zoom-reset.svg';
import LoadingAnimation from './utils/LoadingAnimation';
interface GraphViewportProps {
@@ -119,6 +124,7 @@ export default class GraphViewport extends Component<
render() {
const isLoading = this.state.svgViewport == null;
+ const { svgViewport } = this.state;
return (
({
@@ -145,6 +151,41 @@ export default class GraphViewport extends Component<
},
}}
/>
+ {!isLoading && (
+
+ svgViewport?.zoomIn()}
+ >
+
+
+ svgViewport?.reset()}
+ >
+
+
+ svgViewport?.zoomOut()}
+ >
+
+
+
+ )}
{isLoading && }
);
diff --git a/src/components/icons/zoom-in.svg b/src/components/icons/zoom-in.svg
new file mode 100644
index 00000000..2883f416
--- /dev/null
+++ b/src/components/icons/zoom-in.svg
@@ -0,0 +1,11 @@
+
diff --git a/src/components/icons/zoom-out.svg b/src/components/icons/zoom-out.svg
new file mode 100644
index 00000000..a3cec696
--- /dev/null
+++ b/src/components/icons/zoom-out.svg
@@ -0,0 +1,11 @@
+
diff --git a/src/components/icons/zoom-reset.svg b/src/components/icons/zoom-reset.svg
new file mode 100644
index 00000000..7e5bd959
--- /dev/null
+++ b/src/components/icons/zoom-reset.svg
@@ -0,0 +1,14 @@
+
diff --git a/src/components/viewport.css b/src/components/viewport.css
index 4b20fd57..4cb021d9 100644
--- a/src/components/viewport.css
+++ b/src/components/viewport.css
@@ -4,13 +4,6 @@ g.graph > polygon {
fill: transparent;
}
-#svg-pan-zoom-controls {
- & path {
- fill-opacity: 0.75;
- fill: var(--field-name-color);
- }
-}
-
/* Nodes Styling */
.node {
pointer-events: bounding-box;
diff --git a/src/graph/viewport.ts b/src/graph/viewport.ts
index 29a349c1..c5845abc 100644
--- a/src/graph/viewport.ts
+++ b/src/graph/viewport.ts
@@ -12,6 +12,9 @@ interface Point {
interface Instance {
resize(): Instance;
zoom(scale: number): void;
+ zoomIn(): void;
+ zoomOut(): void;
+ reset(): void;
getPan(): Point;
getZoom(): number;
pan(point: Point): Instance;
@@ -73,7 +76,6 @@ export class Viewport {
zoomScaleSensitivity: 0.25,
minZoom: 0.95,
maxZoom: this.maxZoom,
- controlIconsEnabled: true,
});
this.zoomer.zoom(0.95);
}
@@ -220,6 +222,18 @@ export class Viewport {
});
}
+ zoomIn() {
+ this.zoomer.zoomIn();
+ }
+
+ zoomOut() {
+ this.zoomer.zoomOut();
+ }
+
+ reset() {
+ this.zoomer.reset();
+ }
+
destroy() {
this.resizeObserver.disconnect();
try {
diff --git a/tests/demo.spec.ts-snapshots/choose-github-preset-Demo-linux.png b/tests/demo.spec.ts-snapshots/choose-github-preset-Demo-linux.png
index 1a425e1b..3fe22777 100644
Binary files a/tests/demo.spec.ts-snapshots/choose-github-preset-Demo-linux.png and b/tests/demo.spec.ts-snapshots/choose-github-preset-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/choose-shopify-storefront-preset-Demo-linux.png b/tests/demo.spec.ts-snapshots/choose-shopify-storefront-preset-Demo-linux.png
index 0bacdb41..89adfb2f 100644
Binary files a/tests/demo.spec.ts-snapshots/choose-shopify-storefront-preset-Demo-linux.png and b/tests/demo.spec.ts-snapshots/choose-shopify-storefront-preset-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/choose-star-wars-preset-Demo-linux.png b/tests/demo.spec.ts-snapshots/choose-star-wars-preset-Demo-linux.png
index 4d879542..851346ad 100644
Binary files a/tests/demo.spec.ts-snapshots/choose-star-wars-preset-Demo-linux.png and b/tests/demo.spec.ts-snapshots/choose-star-wars-preset-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/choose-yelp-preset-Demo-linux.png b/tests/demo.spec.ts-snapshots/choose-yelp-preset-Demo-linux.png
index 68eb9fb7..94b30497 100644
Binary files a/tests/demo.spec.ts-snapshots/choose-yelp-preset-Demo-linux.png and b/tests/demo.spec.ts-snapshots/choose-yelp-preset-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/copy-introspection-button-click-Demo-linux.png b/tests/demo.spec.ts-snapshots/copy-introspection-button-click-Demo-linux.png
index 00e1fd8f..1a93e9cd 100644
Binary files a/tests/demo.spec.ts-snapshots/copy-introspection-button-click-Demo-linux.png and b/tests/demo.spec.ts-snapshots/copy-introspection-button-click-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/demo-after-resize-Demo-linux.png b/tests/demo.spec.ts-snapshots/demo-after-resize-Demo-linux.png
index d52cbd38..7060b416 100644
Binary files a/tests/demo.spec.ts-snapshots/demo-after-resize-Demo-linux.png and b/tests/demo.spec.ts-snapshots/demo-after-resize-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/demo-before-resize-Demo-linux.png b/tests/demo.spec.ts-snapshots/demo-before-resize-Demo-linux.png
index 7eed9339..d15df07e 100644
Binary files a/tests/demo.spec.ts-snapshots/demo-before-resize-Demo-linux.png and b/tests/demo.spec.ts-snapshots/demo-before-resize-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/display-introspection-Demo-linux.png b/tests/demo.spec.ts-snapshots/display-introspection-Demo-linux.png
index bd4d8f87..7dfb9f66 100644
Binary files a/tests/demo.spec.ts-snapshots/display-introspection-Demo-linux.png and b/tests/demo.spec.ts-snapshots/display-introspection-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/display-schema-from-url-Demo-linux.png b/tests/demo.spec.ts-snapshots/display-schema-from-url-Demo-linux.png
index bd4d8f87..7dfb9f66 100644
Binary files a/tests/demo.spec.ts-snapshots/display-schema-from-url-Demo-linux.png and b/tests/demo.spec.ts-snapshots/display-schema-from-url-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/display-sdl-Demo-linux.png b/tests/demo.spec.ts-snapshots/display-sdl-Demo-linux.png
index bd4d8f87..7dfb9f66 100644
Binary files a/tests/demo.spec.ts-snapshots/display-sdl-Demo-linux.png and b/tests/demo.spec.ts-snapshots/display-sdl-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/display-sdl-with-unknown-directives-Demo-linux.png b/tests/demo.spec.ts-snapshots/display-sdl-with-unknown-directives-Demo-linux.png
index e4561e95..32a3492f 100644
Binary files a/tests/demo.spec.ts-snapshots/display-sdl-with-unknown-directives-Demo-linux.png and b/tests/demo.spec.ts-snapshots/display-sdl-with-unknown-directives-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/fill-introspection-Demo-linux.png b/tests/demo.spec.ts-snapshots/fill-introspection-Demo-linux.png
index 526c7b85..7d86364e 100644
Binary files a/tests/demo.spec.ts-snapshots/fill-introspection-Demo-linux.png and b/tests/demo.spec.ts-snapshots/fill-introspection-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/fill-sdl-Demo-linux.png b/tests/demo.spec.ts-snapshots/fill-sdl-Demo-linux.png
index 38f04203..61f259be 100644
Binary files a/tests/demo.spec.ts-snapshots/fill-sdl-Demo-linux.png and b/tests/demo.spec.ts-snapshots/fill-sdl-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/loaded-demo-Demo-linux.png b/tests/demo.spec.ts-snapshots/loaded-demo-Demo-linux.png
index bc1a9650..cb67d94d 100644
Binary files a/tests/demo.spec.ts-snapshots/loaded-demo-Demo-linux.png and b/tests/demo.spec.ts-snapshots/loaded-demo-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/open-dialog-Demo-linux.png b/tests/demo.spec.ts-snapshots/open-dialog-Demo-linux.png
index 0317acf5..ec6da2fa 100644
Binary files a/tests/demo.spec.ts-snapshots/open-dialog-Demo-linux.png and b/tests/demo.spec.ts-snapshots/open-dialog-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/show-github-preset-Demo-linux.png b/tests/demo.spec.ts-snapshots/show-github-preset-Demo-linux.png
index 2d43e0c3..3cea5393 100644
Binary files a/tests/demo.spec.ts-snapshots/show-github-preset-Demo-linux.png and b/tests/demo.spec.ts-snapshots/show-github-preset-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/show-shopify-storefront-preset-Demo-linux.png b/tests/demo.spec.ts-snapshots/show-shopify-storefront-preset-Demo-linux.png
index b5ea8c60..c26b3086 100644
Binary files a/tests/demo.spec.ts-snapshots/show-shopify-storefront-preset-Demo-linux.png and b/tests/demo.spec.ts-snapshots/show-shopify-storefront-preset-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/show-star-wars-preset-Demo-linux.png b/tests/demo.spec.ts-snapshots/show-star-wars-preset-Demo-linux.png
index bc1a9650..cb67d94d 100644
Binary files a/tests/demo.spec.ts-snapshots/show-star-wars-preset-Demo-linux.png and b/tests/demo.spec.ts-snapshots/show-star-wars-preset-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/show-yelp-preset-Demo-linux.png b/tests/demo.spec.ts-snapshots/show-yelp-preset-Demo-linux.png
index 2188c6ed..5dc0e294 100644
Binary files a/tests/demo.spec.ts-snapshots/show-yelp-preset-Demo-linux.png and b/tests/demo.spec.ts-snapshots/show-yelp-preset-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/switch-to-introspection-tab-Demo-linux.png b/tests/demo.spec.ts-snapshots/switch-to-introspection-tab-Demo-linux.png
index 94834520..2caa167f 100644
Binary files a/tests/demo.spec.ts-snapshots/switch-to-introspection-tab-Demo-linux.png and b/tests/demo.spec.ts-snapshots/switch-to-introspection-tab-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/switch-to-presets-tab-Demo-linux.png b/tests/demo.spec.ts-snapshots/switch-to-presets-tab-Demo-linux.png
index 0317acf5..ec6da2fa 100644
Binary files a/tests/demo.spec.ts-snapshots/switch-to-presets-tab-Demo-linux.png and b/tests/demo.spec.ts-snapshots/switch-to-presets-tab-Demo-linux.png differ
diff --git a/tests/demo.spec.ts-snapshots/switch-to-sdl-tab-Demo-linux.png b/tests/demo.spec.ts-snapshots/switch-to-sdl-tab-Demo-linux.png
index 115ca960..f78f12ad 100644
Binary files a/tests/demo.spec.ts-snapshots/switch-to-sdl-tab-Demo-linux.png and b/tests/demo.spec.ts-snapshots/switch-to-sdl-tab-Demo-linux.png differ
diff --git a/tests/webpack.spec.ts-snapshots/loaded-webpack-example-WebpackExample-linux.png b/tests/webpack.spec.ts-snapshots/loaded-webpack-example-WebpackExample-linux.png
index d9ddf9c4..639d3218 100644
Binary files a/tests/webpack.spec.ts-snapshots/loaded-webpack-example-WebpackExample-linux.png and b/tests/webpack.spec.ts-snapshots/loaded-webpack-example-WebpackExample-linux.png differ