docs: update intro component

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-01-05 14:02:02 +01:00
parent 6364d07fa1
commit 09aa4ee7b6
+5 -8
View File
@@ -15,10 +15,8 @@ const animatedBackground = ref(false)
onMounted(() => { onMounted(() => {
const html = document.getElementsByTagName('html')![0] const html = document.getElementsByTagName('html')![0]
const observer = new MutationObserver((mutations) => { const observer = new MutationObserver(() => {
for (const m of mutations) {
dark.value = html.classList.contains('dark') dark.value = html.classList.contains('dark')
}
}) })
observer.observe(html, { observer.observe(html, {
@@ -54,8 +52,7 @@ const initialEdges = [
style: { strokeWidth: 4, stroke: '#0ea5e9' }, style: { strokeWidth: 4, stroke: '#0ea5e9' },
}, },
] ]
const { dimensions, onNodeClick, getNodes, fitView, getNode, getEdge, updateEdge, edges, setEdges, updateNodeInternals } = const { onNodeClick, getNodes, fitView, findNode, setEdges, updateNodeInternals } = useVueFlow({
useVueFlow({
nodes: [ nodes: [
{ id: 'intro', type: 'box', position: { x: 0, y: 0 } }, { id: 'intro', type: 'box', position: { x: 0, y: 0 } },
{ id: 'examples', type: 'box', position: { x: -50, y: 400 } }, { id: 'examples', type: 'box', position: { x: -50, y: 400 } },
@@ -121,7 +118,7 @@ const el = templateRef<HTMLDivElement>('el', null)
const setNodes = () => { const setNodes = () => {
if (breakpoints.isSmaller('md')) { if (breakpoints.isSmaller('md')) {
const mainNode = getNode.value('intro')! const mainNode = findNode('intro')!
getNodes.value.forEach((node) => { getNodes.value.forEach((node) => {
switch (node.id) { switch (node.id) {
@@ -177,7 +174,7 @@ const setNodes = () => {
}) })
} else { } else {
getNodes.value.forEach((node) => { getNodes.value.forEach((node) => {
const mainNode = getNode.value('intro')! const mainNode = findNode('intro')!
switch (node.id) { switch (node.id) {
case 'intro': case 'intro':
node.position = { x: 0, y: 0 } node.position = { x: 0, y: 0 }
@@ -203,9 +200,9 @@ const setNodes = () => {
setEdges(initialEdges) setEdges(initialEdges)
} }
nextTick(() => {
updateNodeInternals(getNodes.value.map((n) => n.id)) updateNodeInternals(getNodes.value.map((n) => n.id))
nextTick(() => {
fitView() fitView()
}) })
} }