Skip to content

Commit 1b70250

Browse files
authored
feat(Frontend v2): Viewport Background (#99)
1 parent 6f5b1f2 commit 1b70250

4 files changed

Lines changed: 43 additions & 5 deletions

File tree

frontend/package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"format": "prettier --write src/"
1414
},
1515
"dependencies": {
16+
"@vue-flow/background": "^1.3.2",
1617
"@vue-flow/core": "^1.45.0",
1718
"cytoscape": "^3.32.1",
1819
"pinia": "^3.0.3",

frontend/src/components/schema_editor/CustomNode.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ const closeNodeActions = () => {
8080
border-radius: 6px;
8181
width: 250px;
8282
overflow: hidden;
83+
background-color: white;
8384
}
8485
8586
.custom-node-header {

frontend/src/components/schema_editor/SchemaEditor.vue

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@
88
</div>
99

1010
<div class="vue-flow-viewport">
11+
<div class="toggle-grid-button" @click="showGrid = !showGrid">#</div>
12+
1113
<VueFlow
1214
v-model:nodes="projectStore.nodes"
1315
v-model:edges="projectStore.edges"
1416
:default-viewport="{ zoom: 2 }"
1517
:max-zoom="2"
1618
:min-zoom="0.1"
1719
:fit-view-on-init="true"
18-
:snap-to-grid="true"
1920
>
20-
<!-- <Background
21-
variant="lines"
22-
style="{z-index: -1}"
23-
/> -->
21+
<Background v-if="showGrid" variant="lines" :size="51" :gap="51" />
2422
<div class="create-wrapper">
2523
<div v-if="showInput" class="floating-create-expanded">
2624
<button class="collapse-btn" @click="showInput = false">
@@ -82,12 +80,14 @@ import { useProjectStore } from "@/stores/useProjectStore"
8280
import { VueFlow } from "@vue-flow/core"
8381
import { useModalStore } from "@/stores/useModalStore"
8482
import type { RelationalRelationField, RelationalField } from "@/types.types"
83+
import { Background } from "@vue-flow/background"
8584
8685
const projectStore = useProjectStore()
8786
const modalStore = useModalStore()
8887
8988
const modelName = ref("")
9089
const showInput = ref(false)
90+
const showGrid = ref(false)
9191
9292
const handleCreateClick = () => {
9393
if (modelName.value.trim() === "") return
@@ -167,6 +167,30 @@ const openEditRelationModal = (id: string, relation: RelationalRelationField) =>
167167
height: calc(100% - 42px);
168168
}
169169
170+
.toggle-grid-button {
171+
caret-color: transparent;
172+
position: absolute;
173+
top: 10px;
174+
right: 10px;
175+
background-color: var(--color-primary);
176+
color: black;
177+
border: 2px solid black;
178+
padding: 3px 6px;
179+
font-weight: bold;
180+
border-radius: 8px;
181+
cursor: pointer;
182+
z-index: 10;
183+
box-shadow: 2px 2px 0px rgba(0, 0, 0, 1);
184+
transition:
185+
transform 0.1s ease-out,
186+
box-shadow 0.1s;
187+
}
188+
189+
.toggle-grid-button:hover {
190+
box-shadow: 0px 0px 0px rgba(0, 0, 0, 1);
191+
transform: translate(2px, 2px);
192+
}
193+
170194
.create-wrapper {
171195
position: absolute;
172196
top: 10px;
@@ -247,6 +271,7 @@ const openEditRelationModal = (id: string, relation: RelationalRelationField) =>
247271
cursor: pointer;
248272
font-weight: bold;
249273
}
274+
250275
.create-model-btn:hover {
251276
background-color: var(--color-success);
252277
}

0 commit comments

Comments
 (0)