diff --git a/.dprint.jsonc b/.dprint.jsonc index ac227f6..acb637a 100644 --- a/.dprint.jsonc +++ b/.dprint.jsonc @@ -40,7 +40,7 @@ }, "excludes": [ "**/node_modules", - "**/*-lock.json" + "**/*-lock.yaml" ], "plugins": [ "https://plugins.dprint.dev/typescript-0.95.13.wasm", diff --git a/app/src/lib/graph-interface/keymaps.ts b/app/src/lib/graph-interface/keymaps.ts index 667dbfd..9fd9b54 100644 --- a/app/src/lib/graph-interface/keymaps.ts +++ b/app/src/lib/graph-interface/keymaps.ts @@ -1,16 +1,15 @@ -import { animate, lerp } from "$lib/helpers"; -import type { createKeyMap } from "$lib/helpers/createKeyMap"; -import FileSaver from "file-saver"; -import type { GraphManager } from "./graph-manager.svelte"; -import type { GraphState } from "./graph-state.svelte"; +import { animate, lerp } from '$lib/helpers'; +import type { createKeyMap } from '$lib/helpers/createKeyMap'; +import { panelState } from '$lib/sidebar/PanelState.svelte'; +import FileSaver from 'file-saver'; +import type { GraphManager } from './graph-manager.svelte'; +import type { GraphState } from './graph-state.svelte'; type Keymap = ReturnType; export function setupKeymaps(keymap: Keymap, graph: GraphManager, graphState: GraphState) { - - keymap.addShortcut({ - key: "l", - description: "Select linked nodes", + key: 'l', + description: 'Select linked nodes', callback: () => { const activeNode = graph.getNode(graphState.activeNodeId); if (activeNode) { @@ -20,56 +19,54 @@ export function setupKeymaps(keymap: Keymap, graph: GraphManager, graphState: Gr graphState.selectedNodes.add(node.id); } } - }, + } }); - keymap.addShortcut({ - key: "?", - description: "Toggle Help", + key: '?', + description: 'Toggle Help', callback: () => { - // TODO: fix this - // showHelp = !showHelp; - }, + panelState.setActivePanel('shortcuts'); + } }); keymap.addShortcut({ - key: "c", + key: 'c', ctrl: true, - description: "Copy active nodes", - callback: () => graphState.copyNodes(), + description: 'Copy active nodes', + callback: () => graphState.copyNodes() }); keymap.addShortcut({ - key: "v", + key: 'v', ctrl: true, - description: "Paste nodes", - callback: () => graphState.pasteNodes(), + description: 'Paste nodes', + callback: () => graphState.pasteNodes() }); keymap.addShortcut({ - key: "Escape", - description: "Deselect nodes", + key: 'Escape', + description: 'Deselect nodes', callback: () => { graphState.activeNodeId = -1; graphState.clearSelection(); graphState.edgeEndPosition = null; (document.activeElement as HTMLElement)?.blur(); - }, + } }); keymap.addShortcut({ - key: "A", + key: 'A', shift: true, - description: "Add new Node", + description: 'Add new Node', callback: () => { graphState.addMenuPosition = [graphState.mousePosition[0], graphState.mousePosition[1]]; - }, + } }); keymap.addShortcut({ - key: ".", - description: "Center camera", + key: '.', + description: 'Center camera', callback: () => { if (!graphState.isBodyFocused()) return; @@ -90,67 +87,67 @@ export function setupKeymaps(keymap: Keymap, graph: GraphManager, graphState: Gr animate(500, (a: number) => { graphState.cameraPosition[0] = lerp(camX, average[0], ease(a)); graphState.cameraPosition[1] = lerp(camY, average[1], ease(a)); - graphState.cameraPosition[2] = lerp(camZ, 2, ease(a)) + graphState.cameraPosition[2] = lerp(camZ, 2, ease(a)); if (graphState.mouseDown) return false; }); - }, + } }); keymap.addShortcut({ - key: "a", + key: 'a', ctrl: true, preventDefault: true, - description: "Select all nodes", + description: 'Select all nodes', callback: () => { if (!graphState.isBodyFocused()) return; for (const node of graph.nodes.keys()) { graphState.selectedNodes.add(node); } - }, + } }); keymap.addShortcut({ - key: "z", + key: 'z', ctrl: true, - description: "Undo", + description: 'Undo', callback: () => { if (!graphState.isBodyFocused()) return; graph.undo(); for (const node of graph.nodes.values()) { graphState.updateNodePosition(node); } - }, + } }); keymap.addShortcut({ - key: "y", + key: 'y', ctrl: true, - description: "Redo", + description: 'Redo', callback: () => { graph.redo(); for (const node of graph.nodes.values()) { graphState.updateNodePosition(node); } - }, + } }); keymap.addShortcut({ - key: "s", + key: 's', ctrl: true, - description: "Save", + description: 'Save', preventDefault: true, callback: () => { const state = graph.serialize(); const blob = new Blob([JSON.stringify(state)], { - type: "application/json;charset=utf-8", + type: 'application/json;charset=utf-8' }); - FileSaver.saveAs(blob, "nodarium-graph.json"); - }, + FileSaver.saveAs(blob, 'nodarium-graph.json'); + } }); keymap.addShortcut({ - key: ["Delete", "Backspace", "x"], - description: "Delete selected nodes", + key: ['Delete', 'Backspace', 'x'], + description: 'Delete selected nodes', callback: (event) => { if (!graphState.isBodyFocused()) return; graph.startUndoGroup(); @@ -171,20 +168,18 @@ export function setupKeymaps(keymap: Keymap, graph: GraphManager, graphState: Gr graphState.clearSelection(); } graph.saveUndoGroup(); - }, + } }); keymap.addShortcut({ - key: "f", - description: "Smart Connect Nodes", + key: 'f', + description: 'Smart Connect Nodes', callback: () => { const nodes = [...graphState.selectedNodes.values()] .map((g) => graph.getNode(g)) .filter((n) => !!n); const edge = graph.smartConnect(nodes[0], nodes[1]); if (!edge) graph.smartConnect(nodes[1], nodes[0]); - }, + } }); - - } diff --git a/app/src/lib/sidebar/Panel.svelte b/app/src/lib/sidebar/Panel.svelte index 925dd87..19d90c0 100644 --- a/app/src/lib/sidebar/Panel.svelte +++ b/app/src/lib/sidebar/Panel.svelte @@ -1,6 +1,6 @@ diff --git a/packages/ui/src/lib/Input.svelte b/packages/ui/src/lib/Input.svelte index 49feb93..f916dd1 100644 --- a/packages/ui/src/lib/Input.svelte +++ b/packages/ui/src/lib/Input.svelte @@ -2,11 +2,9 @@ import type { NodeInput } from '@nodarium/types'; import Checkbox from './inputs/Checkbox.svelte'; - import Float from './inputs/Float.svelte'; - import Integer from './inputs/Integer.svelte'; + import Number from './inputs/Number.svelte'; import Select from './inputs/Select.svelte'; import Vec3 from './inputs/Vec3.svelte'; - // import Number from './inputs/Number.svelte'; interface Props { input: NodeInput; @@ -18,9 +16,9 @@ {#if input.type === 'float'} - + {:else if input.type === 'integer'} - + {:else if input.type === 'boolean'} {:else if input.type === 'select'} diff --git a/packages/ui/src/lib/inputs/Integer.svelte b/packages/ui/src/lib/inputs/Integer.svelte index 083e621..1446b99 100644 --- a/packages/ui/src/lib/inputs/Integer.svelte +++ b/packages/ui/src/lib/inputs/Integer.svelte @@ -112,23 +112,25 @@ onmousedown={handleMouseDown} onmouseup={handleMouseUp} > +
+ + + + +
{#if typeof min !== 'undefined' && typeof max !== 'undefined'} {/if} - - - -