docs: update node positions

This commit is contained in:
Braks
2022-04-11 11:30:10 +02:00
parent 969dd87e71
commit 07ee6eddf7
+13 -9
View File
@@ -71,16 +71,20 @@ onPaneReady(({ fitView }) => {
const setNodes = () => { const setNodes = () => {
if (breakpoints.isSmaller('md')) { if (breakpoints.isSmaller('md')) {
const mainNode = getNode.value('intro')!
getNodes.value.forEach((node) => { getNodes.value.forEach((node) => {
switch (node.id) { switch (node.id) {
case 'intro': case 'intro':
node.position = { x: 0, y: -50 } node.position = { x: 0, y: 0 }
break break
case 'examples': case 'examples':
node.position = { x: getNode.value('intro')!.dimensions.width / 2 - node.dimensions.width / 2, y: 300 } node.position = { x: mainNode.dimensions.width / 2 - node.dimensions.width / 2, y: mainNode.dimensions.height * 1.5 }
break break
case 'documentation': case 'documentation':
node.position = { x: getNode.value('intro')!.dimensions.width / 2 - node.dimensions.width / 2, y: 500 } node.position = {
x: mainNode.dimensions.width / 2 - node.dimensions.width / 2,
y: mainNode.dimensions.height * 2 + 50,
}
break break
} }
}) })
@@ -88,21 +92,23 @@ onPaneReady(({ fitView }) => {
const newEdge = updateEdge(getEdge.value(edgeId.value)!, { const newEdge = updateEdge(getEdge.value(edgeId.value)!, {
source: 'examples', source: 'examples',
target: 'documentation', target: 'documentation',
sourceHandle: null,
targetHandle: null,
}) })
if (newEdge) edgeId.value = newEdge.id if (newEdge) edgeId.value = newEdge.id
} else { } else {
getNodes.value.forEach((node) => { getNodes.value.forEach((node) => {
const mainNode = getNode.value('intro')!
switch (node.id) { switch (node.id) {
case 'intro': case 'intro':
node.position = { x: 0, y: 0 } node.position = { x: 0, y: 0 }
break break
case 'examples': case 'examples':
node.position = { x: -node.dimensions.width / 2, y: 400 } node.position = { x: -node.dimensions.width / 2, y: mainNode.dimensions.height * 1.5 }
break break
case 'documentation': case 'documentation':
node.position = { x: getNode.value('intro')!.dimensions.width / 2 + node.dimensions.width / 2, y: 400 } node.position = {
x: mainNode.dimensions.width - node.dimensions.width / 2,
y: mainNode.dimensions.height * 1.5,
}
break break
} }
}) })
@@ -110,8 +116,6 @@ onPaneReady(({ fitView }) => {
const newEdge = updateEdge(getEdge.value(edgeId.value)!, { const newEdge = updateEdge(getEdge.value(edgeId.value)!, {
source: 'intro', source: 'intro',
target: 'documentation', target: 'documentation',
sourceHandle: null,
targetHandle: null,
}) })
if (newEdge) edgeId.value = newEdge.id if (newEdge) edgeId.value = newEdge.id
} }