Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

scale > zoom

Oleg Isonenaf11c8f15f2e
diff --git a/app/canvas/shared/use-shortcuts.ts b/app/canvas/shared/use-shortcuts.ts
index 15c24551ef..197a7725b1 100644
--- a/app/canvas/shared/use-shortcuts.ts
+++ b/app/canvas/shared/use-shortcuts.ts
@@ -22,11 +22,11 @@ const publishSelectBreakpoint = ({ key }: HandlerEvent) => {
});
};
-const publishScale = (event: HandlerEvent) => {
+const publishZoom = (event: HandlerEvent) => {
if (event.preventDefault !== undefined) event.preventDefault();
publish({
- type: "scale",
- payload: event.key === "-" ? "scaleOut" : "scaleIn",
+ type: "zoom",
+ payload: event.key === "-" ? "zoomOut" : "zoomIn",
});
};
@@ -63,7 +63,7 @@ export const useShortcuts = () => {
paste,
breakpointsMenu: publishOpenBreakpointsMenu,
breakpoint: publishSelectBreakpoint,
- scale: publishScale,
+ zoom: publishZoom,
} as const;
useHotkeys(
@@ -97,7 +97,7 @@ export const useShortcuts = () => {
useHotkeys(shortcuts.paste, shortcutHandlerMap.paste, options, []);
useHotkeys(shortcuts.breakpoint, shortcutHandlerMap.breakpoint, options, []);
- useHotkeys(shortcuts.scale, shortcutHandlerMap.scale, options, []);
+ useHotkeys(shortcuts.zoom, shortcutHandlerMap.zoom, options, []);
useHotkeys(
shortcuts.breakpointsMenu,
shortcutHandlerMap.breakpointsMenu,
diff --git a/app/designer/designer.tsx b/app/designer/designer.tsx
index 6fe48ce833..fe357f2e38 100644
--- a/app/designer/designer.tsx
+++ b/app/designer/designer.tsx
@@ -12,7 +12,7 @@ import { CanvasIframe, useSubscribe, usePublish } from "./shared/canvas-iframe";
import {
useIsPreviewMode,
useRootInstance,
- useScale,
+ useZoom,
useSelectedInstanceData,
useSyncStatus,
useCanvasWidth,
@@ -113,7 +113,7 @@ const Main = ({ children }: { children: Array<JSX.Element> }) => (
);
const Workspace = ({ children }: { children: JSX.Element }) => {
- const [scale] = useScale();
+ const [zoom] = useZoom();
return (
<Box
@@ -134,7 +134,7 @@ const Workspace = ({ children }: { children: JSX.Element }) => {
width: "100%",
}}
style={{
- transform: `scale(${scale / 100})`,
+ transform: `scale(${zoom / 100})`,
}}
>
{children}
diff --git a/app/designer/features/breakpoints/breakpoints.tsx b/app/designer/features/breakpoints/breakpoints.tsx
index 3979eeb7b7..e3ba40065c 100644
--- a/app/designer/features/breakpoints/breakpoints.tsx
+++ b/app/designer/features/breakpoints/breakpoints.tsx
@@ -20,12 +20,12 @@ import {
import { willRender } from "~/designer/shared/breakpoints";
import { BreakpointsEditor } from "./breakpoints-editor";
import { Preview } from "./preview";
-import { ScaleSetting } from "./scale-setting";
+import { ZoomSetting } from "./zoom-setting";
import { TriggerButton } from "./trigger-button";
import { WidthSetting } from "./width-setting";
import { sort } from "./sort";
import {
- useSubscribeScaleFromShortcut,
+ useSubscribeZoomFromShortcut,
useSubscribeSelectBreakpointFromShortcut,
} from "./use-subscribe-shortcuts";
import { ConfirmationDialog } from "./confirmation-dialog";
@@ -76,7 +76,7 @@ export const Breakpoints = ({ publish }: BreakpointsProps) => {
const [breakpointPreview, setBreakpointPreview] =
useState(selectedBreakpoint);
useSubscribeSelectBreakpointFromShortcut();
- useSubscribeScaleFromShortcut();
+ useSubscribeZoomFromShortcut();
useEffect(() => {
setBreakpointPreview(selectedBreakpoint);
@@ -178,7 +178,7 @@ export const Breakpoints = ({ publish }: BreakpointsProps) => {
})}
<DropdownMenuSeparator />
<form>
- <ScaleSetting />
+ <ZoomSetting />
<WidthSetting />
</form>
<DropdownMenuSeparator />
diff --git a/app/designer/features/breakpoints/trigger-button.tsx b/app/designer/features/breakpoints/trigger-button.tsx
index 5c95162d8c..44f3349cbf 100644
--- a/app/designer/features/breakpoints/trigger-button.tsx
+++ b/app/designer/features/breakpoints/trigger-button.tsx
@@ -2,7 +2,7 @@ import { forwardRef, type ComponentProps, type ElementRef } from "react";
import { type Breakpoint } from "@webstudio-is/sdk";
import {
useCanvasWidth,
- useScale,
+ useZoom,
useSelectedBreakpoint,
} from "~/designer/shared/nano-values";
import { willRender } from "~/designer/shared/breakpoints";
@@ -34,7 +34,7 @@ export const TriggerButton = forwardRef<
ElementRef<typeof Button>,
TriggerButtonProps
>((props, ref) => {
- const [scale] = useScale();
+ const [zoom] = useZoom();
const [breakpoint] = useSelectedBreakpoint();
const [canvasWidth = 0] = useCanvasWidth();
if (breakpoint === undefined) return null;
@@ -50,7 +50,7 @@ export const TriggerButton = forwardRef<
>
{renderIcon(breakpoint, variant)}
<Text size="1" variant={variant}>
- {`${breakpoint.label} ${canvasWidth}px / ${scale}%`}
+ {`${breakpoint.label} ${canvasWidth}px / ${zoom}%`}
</Text>
</Button>
);
diff --git a/app/designer/features/breakpoints/use-subscribe-shortcuts.ts b/app/designer/features/breakpoints/use-subscribe-shortcuts.ts
index dde3fd0671..4c6ce6664e 100644
--- a/app/designer/features/breakpoints/use-subscribe-shortcuts.ts
+++ b/app/designer/features/breakpoints/use-subscribe-shortcuts.ts
@@ -1,11 +1,11 @@
import { useSubscribe } from "~/designer/shared/canvas-iframe";
import {
useBreakpoints,
- useScale,
+ useZoom,
useSelectedBreakpoint,
} from "../../shared/nano-values";
import { sort } from "./sort";
-import { minScale } from "./scale-setting";
+import { minZoom } from "./zoom-setting";
export const useSubscribeSelectBreakpointFromShortcut = () => {
const [breakpoints] = useBreakpoints();
@@ -19,16 +19,16 @@ export const useSubscribeSelectBreakpointFromShortcut = () => {
);
};
-const scaleStep = 20;
+const zoomStep = 20;
-export const useSubscribeScaleFromShortcut = () => {
- const [scale, setScale] = useScale();
- useSubscribe<"scale", "scaleIn" | "scaleOut">("scale", (direction) => {
- if (direction === "scaleIn") {
- setScale(Math.min(scale + scaleStep, 100));
+export const useSubscribeZoomFromShortcut = () => {
+ const [zoom, setZoom] = useZoom();
+ useSubscribe<"zoom", "zoomIn" | "zoomOut">("zoom", (direction) => {
+ if (direction === "zoomIn") {
+ setZoom(Math.min(zoom + zoomStep, 100));
return;
}
- setScale(Math.max(scale - scaleStep, minScale));
+ setZoom(Math.max(zoom - zoomStep, minZoom));
});
};
diff --git a/app/designer/features/breakpoints/width-setting.tsx b/app/designer/features/breakpoints/width-setting.tsx
index 98fd6cb5ae..3a61e4274f 100644
--- a/app/designer/features/breakpoints/width-setting.tsx
+++ b/app/designer/features/breakpoints/width-setting.tsx
@@ -10,7 +10,7 @@ export const WidthSetting = () => {
return (
<Flex css={{ px: "$5", py: "$1" }} gap="1" direction="column">
- <Text size="1">Width</Text>
+ <Text size="1">Canvas width</Text>
<Flex gap="3" align="center">
<Slider
min={minWidth}
diff --git a/app/designer/features/breakpoints/scale-setting.tsx b/app/designer/features/breakpoints/zoom-setting.tsx
similarity index 63%
rename from app/designer/features/breakpoints/scale-setting.tsx
rename to app/designer/features/breakpoints/zoom-setting.tsx
index 23af7f66d1..0df51c4e02 100644
--- a/app/designer/features/breakpoints/scale-setting.tsx
+++ b/app/designer/features/breakpoints/zoom-setting.tsx
@@ -1,16 +1,16 @@
-import { useScale } from "~/designer/shared/nano-values";
+import { useZoom } from "~/designer/shared/nano-values";
import { Slider, Text, Flex } from "~/shared/design-system";
-export const minScale = 10;
+export const minZoom = 10;
-export const ScaleSetting = () => {
- const [value, setValue] = useScale();
+export const ZoomSetting = () => {
+ const [value, setValue] = useZoom();
return (
<Flex css={{ px: "$5", py: "$1" }} gap="1" direction="column">
- <Text size="1">Scale</Text>
+ <Text size="1">Zoom</Text>
<Flex gap="3" align="center">
<Slider
- min={minScale}
+ min={minZoom}
value={[value]}
onValueChange={([value]) => {
setValue(value);
diff --git a/app/designer/shared/nano-values/index.ts b/app/designer/shared/nano-values/index.ts
index 9c1e739c65..f9b685d095 100644
--- a/app/designer/shared/nano-values/index.ts
+++ b/app/designer/shared/nano-values/index.ts
@@ -31,8 +31,8 @@ export const useSelectedBreakpoint = () =>
export const breakpointsContainer = createValueContainer<Array<Breakpoint>>([]);
export const useBreakpoints = () => useValue(breakpointsContainer);
-const scaleContainer = createValueContainer<number>(100);
-export const useScale = () => useValue(scaleContainer);
+const zoomContainer = createValueContainer<number>(100);
+export const useZoom = () => useValue(zoomContainer);
const canvasWidthContainer = createValueContainer<number | undefined>();
export const useCanvasWidth = () => useValue(canvasWidthContainer);
diff --git a/app/shared/shortcuts/index.ts b/app/shared/shortcuts/index.ts
index 0b9674d402..63c9010a6c 100644
--- a/app/shared/shortcuts/index.ts
+++ b/app/shared/shortcuts/index.ts
@@ -8,7 +8,7 @@ export const shortcuts = {
breakpoint: Array.from(new Array(9))
.map((_, index) => `cmd+${index + 1}, ctrl+${index + 1}`)
.join(", "),
- scale: "cmd+=, ctrl+=, cmd+-, ctrl+-",
+ zoom: "cmd+=, ctrl+=, cmd+-, ctrl+-",
} as const;
export const options = { splitKey: "+", keydown: true };