Skip to content

Commit 2c9dca1

Browse files
feat: Option to disable desktop breakpoint
- Command click to only show clicked breakpoint
1 parent 6f403b6 commit 2c9dca1

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

frontend/src/components/BuilderCanvas.vue

+17-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
class="w-auto cursor-pointer p-2"
2727
v-for="breakpoint in canvasProps.breakpoints"
2828
:key="breakpoint.device"
29-
@click.stop="breakpoint.visible = !breakpoint.visible">
29+
@click.stop="(ev) => selectBreakpoint(ev, breakpoint)">
3030
<FeatherIcon
3131
:name="breakpoint.icon"
3232
class="h-8 w-6"
@@ -46,7 +46,7 @@
4646
v-for="breakpoint in visibleBreakpoints"
4747
:key="breakpoint.device">
4848
<div
49-
class="cursor absolute left-0 select-none text-3xl text-gray-700 dark:text-zinc-300"
49+
class="absolute left-0 cursor-pointer select-none text-3xl text-gray-700 dark:text-zinc-300"
5050
:style="{
5151
fontSize: `calc(${12}px * 1/${canvasProps.scale})`,
5252
top: `calc(${-20}px * 1/${canvasProps.scale})`,
@@ -78,7 +78,7 @@
7878
import LoadingIcon from "@/components/Icons/Loading.vue";
7979
import { BreakpointConfig, CanvasHistory } from "@/types/Builder/BuilderCanvas";
8080
import Block from "@/utils/block";
81-
import { getBlockCopy } from "@/utils/helpers";
81+
import { getBlockCopy, isCtrlOrCmd } from "@/utils/helpers";
8282
import { useBlockEventHandlers } from "@/utils/useBlockEventHandlers";
8383
import { useBlockSelection } from "@/utils/useBlockSelection";
8484
import { useCanvasDropZone } from "@/utils/useCanvasDropZone";
@@ -182,9 +182,7 @@ const { isOverDropZone } = useCanvasDropZone(
182182
);
183183
184184
const visibleBreakpoints = computed(() => {
185-
return canvasProps.breakpoints.filter(
186-
(breakpoint) => breakpoint.visible || breakpoint.device === "desktop",
187-
);
185+
return canvasProps.breakpoints.filter((breakpoint) => breakpoint.visible);
188186
});
189187
190188
onMounted(() => {
@@ -270,4 +268,17 @@ defineExpose({
270268
removeBlock,
271269
selectBlockRange,
272270
});
271+
272+
function selectBreakpoint(ev: MouseEvent, breakpoint: BreakpointConfig) {
273+
if (isCtrlOrCmd(ev)) {
274+
canvasProps.breakpoints.forEach((bp) => {
275+
bp.visible = bp.device === breakpoint.device;
276+
});
277+
} else {
278+
breakpoint.visible = !breakpoint.visible;
279+
if (canvasProps.breakpoints.filter((bp) => bp.visible).length === 0) {
280+
breakpoint.visible = true;
281+
}
282+
}
283+
}
273284
</script>

frontend/src/utils/helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ function getBlockCopy(block: BlockOptions | Block, retainId = false): Block {
278278
return getBlockInstance(b, retainId);
279279
}
280280

281-
function isCtrlOrCmd(e: KeyboardEvent) {
281+
function isCtrlOrCmd(e: KeyboardEvent | MouseEvent) {
282282
return e.ctrlKey || e.metaKey;
283283
}
284284

0 commit comments

Comments
 (0)