From d71de0a92d8c16c780d869a66de0a80dacb73c63 Mon Sep 17 00:00:00 2001 From: Braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Mon, 10 Jun 2024 23:36:55 +0200 Subject: [PATCH] chore(docs): update example styles (#1469) * chore(docs): update basic example styles * chore(docs): update confirm delete example styles * chore(docs): update dnd example styles * chore(docs): update hidden example * chore(docs): update update node example * chore(docs): update node toolbar example styles * chore(docs): update transition example styles * chore(docs): cleanup basic example els * chore(docs): cleanup examples --- docs/examples/basic/App.vue | 23 +++--- docs/examples/basic/initial-elements.js | 63 ++++++++++++-- docs/examples/basic/style.css | 30 ++++--- docs/examples/confirm-delete/App.vue | 34 +++++--- docs/examples/confirm-delete/Dialog.vue | 34 +++++++- docs/examples/confirm-delete/useDialog.js | 3 + docs/examples/connection-radius/App.vue | 6 +- docs/examples/connectionline/App.vue | 2 +- docs/examples/custom-node/App.vue | 19 ++--- .../custom-node/ColorSelectorNode.vue | 14 +++- docs/examples/custom-node/OutputNode.vue | 6 +- docs/examples/custom-node/style.css | 38 ++++++--- docs/examples/dnd/App.vue | 6 +- docs/examples/dnd/DropzoneBackground.vue | 8 +- docs/examples/dnd/style.css | 43 +++++++--- docs/examples/dnd/useDnD.js | 2 +- docs/examples/hidden/App.vue | 39 +++++++-- docs/examples/interaction/App.vue | 30 +++++-- docs/examples/intersection/App.vue | 40 ++++++--- docs/examples/multi/Flow.vue | 29 ++++++- docs/examples/nested/App.vue | 30 ++++--- docs/examples/node-resizer/App.vue | 4 +- docs/examples/node-resizer/ResizableNode.vue | 4 +- docs/examples/node-toolbar/App.vue | 82 ++++++++++++------- docs/examples/node-toolbar/ToolbarNode.vue | 30 ++++--- docs/examples/save-restore/App.vue | 2 +- docs/examples/stress/utils.js | 2 +- docs/examples/teleport/App.vue | 9 +- docs/examples/transition/App.vue | 23 ++++-- docs/examples/update-edge/App.vue | 6 +- docs/examples/update-node/App.vue | 52 ++++++------ docs/examples/update-node/style.css | 36 ++++---- docs/examples/validation/App.vue | 21 ++++- docs/src/.vitepress/config.mts | 2 +- 34 files changed, 528 insertions(+), 244 deletions(-) diff --git a/docs/examples/basic/App.vue b/docs/examples/basic/App.vue index 32022936..afb5322e 100644 --- a/docs/examples/basic/App.vue +++ b/docs/examples/basic/App.vue @@ -8,10 +8,12 @@ import { initialEdges, initialNodes } from './initial-elements.js' import Icon from './Icon.vue' /** - * useVueFlow provides all event handlers and store properties - * You can pass the composable an object that has the same properties as the VueFlow component props + * `useVueFlow` provides: + * 1. a set of methods to interact with the VueFlow instance (like `fitView`, `setViewport`, `addEdges`, etc) + * 2. a set of event-hooks to listen to VueFlow events (like `onInit`, `onNodeDragStop`, `onConnect`, etc) + * 3. the internal state of the VueFlow instance (like `nodes`, `edges`, `viewport`, etc) */ -const { onPaneReady, onNodeDragStop, onConnect, addEdges, setViewport, toObject } = useVueFlow() +const { onInit, onNodeDragStop, onConnect, addEdges, setViewport, toObject } = useVueFlow() const nodes = ref(initialNodes) @@ -24,10 +26,11 @@ const dark = ref(false) * This is a Vue Flow event-hook which can be listened to from anywhere you call the composable, instead of only on the main component * Any event that is available as `@event-name` on the VueFlow component is also available as `onEventName` on the composable and vice versa * - * onPaneReady is called when viewpane & nodes have visible dimensions + * onInit is called when the VueFlow viewport is initialized */ -onPaneReady(({ fitView }) => { - fitView() +onInit((vueFlowInstance) => { + // instance is the same as the return of `useVueFlow` + vueFlowInstance.fitView() }) /** @@ -39,8 +42,8 @@ onPaneReady(({ fitView }) => { * 3. the node that initiated the drag * 4. any intersections with other nodes */ -onNodeDragStop(({ event, nodes, node, intersections }) => { - console.log('Node Drag Stop', { event, nodes, node, intersections }) +onNodeDragStop(({ event, nodes, node }) => { + console.log('Node Drag Stop', { event, nodes, node }) }) /** @@ -94,7 +97,7 @@ function toggleDarkMode() { :nodes="nodes" :edges="edges" :class="{ dark }" - class="basicflow" + class="basic-flow" :default-viewport="{ zoom: 1.5 }" :min-zoom="0.2" :max-zoom="4" @@ -103,7 +106,7 @@ function toggleDarkMode() { - + diff --git a/docs/examples/basic/initial-elements.js b/docs/examples/basic/initial-elements.js index 7938ede6..250e06fd 100644 --- a/docs/examples/basic/initial-elements.js +++ b/docs/examples/basic/initial-elements.js @@ -1,24 +1,69 @@ import { MarkerType } from '@vue-flow/core' export const initialNodes = [ - { id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 0 }, class: 'light' }, - { id: '2', type: 'output', label: 'Node 2', position: { x: 100, y: 100 }, class: 'light' }, - { id: '3', label: 'Node 3', position: { x: 400, y: 100 }, class: 'light' }, - { id: '4', label: 'Node 4', position: { x: 150, y: 200 }, class: 'light' }, - { id: '5', type: 'output', label: 'Node 5', position: { x: 300, y: 300 }, class: 'light' }, + { + id: '1', + type: 'input', + data: { label: 'Node 1' }, + position: { x: 250, y: 0 }, + class: 'light', + }, + { + id: '2', + type: 'output', + data: { label: 'Node 2' }, + position: { x: 100, y: 100 }, + class: 'light', + }, + { + id: '3', + data: { label: 'Node 3' }, + position: { x: 400, y: 100 }, + class: 'light', + }, + { + id: '4', + data: { label: 'Node 4' }, + position: { x: 150, y: 200 }, + class: 'light', + }, + { + id: '5', + type: 'output', + data: { label: 'Node 5' }, + position: { x: 300, y: 300 }, + class: 'light', + }, ] export const initialEdges = [ - { id: 'e1-2', source: '1', target: '2', animated: true }, - { id: 'e1-3', label: 'edge with arrowhead', source: '1', target: '3', markerEnd: MarkerType.ArrowClosed }, + { + id: 'e1-2', + source: '1', + target: '2', + animated: true, + }, + { + id: 'e1-3', + source: '1', + target: '3', + label: 'edge with arrowhead', + markerEnd: MarkerType.ArrowClosed, + }, { id: 'e4-5', type: 'step', - label: 'step-edge', source: '4', target: '5', + label: 'Node 2', style: { stroke: 'orange' }, labelBgStyle: { fill: 'orange' }, }, - { id: 'e3-4', type: 'smoothstep', label: 'smoothstep-edge', source: '3', target: '4' }, + { + id: 'e3-4', + type: 'smoothstep', + source: '3', + target: '4', + label: 'smoothstep-edge', + }, ] diff --git a/docs/examples/basic/style.css b/docs/examples/basic/style.css index 144a63eb..057bc84e 100644 --- a/docs/examples/basic/style.css +++ b/docs/examples/basic/style.css @@ -1,48 +1,52 @@ -.basicflow.dark { - background: #000000; +.basic-flow.dark { + background: #2d3748; color: #FFFFFB; } -.basicflow.dark .vue-flow__node { - background: hsl(0, 0%, 10%); +.basic-flow.dark .vue-flow__node { + background: #4a5568; color: #FFFFFB; } -.basicflow.dark .vue-flow__node.selected { +.basic-flow.dark .vue-flow__node.selected { background: hsl(0, 0%, 20%); - border: 1px solid hotpink; + box-shadow: 0 0 0 2px #2563eb; } -.basicflow .vue-flow__controls { +.basic-flow .vue-flow__controls { display: flex; flex-wrap: wrap; justify-content: center; } -.basicflow.dark .vue-flow__controls { +.basic-flow.dark .vue-flow__controls { border: 1px solid #FFFFFB; } -.basicflow .vue-flow__controls .vue-flow__controls-button { +.basic-flow .vue-flow__controls .vue-flow__controls-button { border: none; border-right: 1px solid #eee; } +.basic-flow .vue-flow__controls .vue-flow__controls-button svg { + height: 100%; + width: 100%; +} -.basicflow.dark .vue-flow__controls .vue-flow__controls-button { +.basic-flow.dark .vue-flow__controls .vue-flow__controls-button { background: hsl(0, 0%, 20%); fill: #FFFFFB; border: none; } -.basicflow.dark .vue-flow__controls .vue-flow__controls-button:hover { +.basic-flow.dark .vue-flow__controls .vue-flow__controls-button:hover { background: hsl(0, 0%, 30%); } -.basicflow.dark .vue-flow__edge-textbg { +.basic-flow.dark .vue-flow__edge-textbg { fill: #292524; } -.basicflow.dark .vue-flow__edge-text { +.basic-flow.dark .vue-flow__edge-text { fill: #FFFFFB; } diff --git a/docs/examples/confirm-delete/App.vue b/docs/examples/confirm-delete/App.vue index b77b6dbd..376c9855 100644 --- a/docs/examples/confirm-delete/App.vue +++ b/docs/examples/confirm-delete/App.vue @@ -1,5 +1,5 @@