From d06b33f50807945ba44edb42194fade4225c96c7 Mon Sep 17 00:00:00 2001 From: Max Richter Date: Fri, 26 Apr 2024 01:13:08 +0200 Subject: [PATCH] feat: add icons --- app/src/lib/graph-interface/AddMenu.svelte | 2 +- app/src/lib/icons/graph.svg | 6 ++++++ app/src/lib/settings/Panel.svelte | 3 +-- app/src/routes/+page.svelte | 2 +- app/uno.config.ts | 11 ++++++++++- packages/ui/src/lib/elements/Float.svelte | 8 ++++++++ packages/ui/src/lib/index.ts | 2 ++ packages/utils/src/flatTree.ts | 3 --- pnpm-lock.yaml | 2 ++ 9 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 app/src/lib/icons/graph.svg diff --git a/app/src/lib/graph-interface/AddMenu.svelte b/app/src/lib/graph-interface/AddMenu.svelte index b3c47ac..3b11502 100644 --- a/app/src/lib/graph-interface/AddMenu.svelte +++ b/app/src/lib/graph-interface/AddMenu.svelte @@ -109,7 +109,7 @@ activeNodeId = node.id; }} > - {node.id} + {node.id.split("/").at(-1)} {/each} diff --git a/app/src/lib/icons/graph.svg b/app/src/lib/icons/graph.svg new file mode 100644 index 0000000..edba024 --- /dev/null +++ b/app/src/lib/icons/graph.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/app/src/lib/settings/Panel.svelte b/app/src/lib/settings/Panel.svelte index 271ea34..12025bc 100644 --- a/app/src/lib/settings/Panel.svelte +++ b/app/src/lib/settings/Panel.svelte @@ -6,7 +6,7 @@ export let icon: string = ""; export let title = ""; export let classes = ""; - export let hidden: boolean; + export let hidden: boolean | undefined = undefined; const setVisibility = getContext<(id: string, visible: boolean) => void>("setVisibility"); @@ -21,7 +21,6 @@ >("registerPanel"); let visible = registerPanel(id, icon, classes); - console.log(id, $visible, hidden); {#if $visible} diff --git a/app/src/routes/+page.svelte b/app/src/routes/+page.svelte index 7666101..e5dbe9b 100644 --- a/app/src/routes/+page.svelte +++ b/app/src/routes/+page.svelte @@ -183,7 +183,7 @@ id="graph-settings" title="Graph Settings" classes="text-blue-400" - icon="i-tabler-brand-git" + icon="i-custom-graph" > {#if Object.keys(graphSettingTypes).length > 0} diff --git a/app/uno.config.ts b/app/uno.config.ts index 0dd1a89..44dd6b4 100644 --- a/app/uno.config.ts +++ b/app/uno.config.ts @@ -2,10 +2,19 @@ import { defineConfig } from 'unocss' import presetIcons from '@unocss/preset-icons' import { presetUno } from 'unocss' +import fs from 'fs' + +const icons = Object.fromEntries(fs.readdirSync('./src/lib/icons') + .map(name => [name.replace(".svg", ""), fs.readFileSync(`./src/lib/icons/${name}`, 'utf-8')])) + export default defineConfig({ presets: [ presetUno(), - presetIcons(), + presetIcons({ + collections: { + custom: icons + } + }), ] }) diff --git a/packages/ui/src/lib/elements/Float.svelte b/packages/ui/src/lib/elements/Float.svelte index d14fbf8..2b63386 100644 --- a/packages/ui/src/lib/elements/Float.svelte +++ b/packages/ui/src/lib/elements/Float.svelte @@ -64,6 +64,14 @@ inputEl.focus(); } + if (value > max) { + max = value; + } + + if (value < min) { + min = value; + } + // setTimeout(() => { // if (value >= 0) { // max = getBoundingValue(value); diff --git a/packages/ui/src/lib/index.ts b/packages/ui/src/lib/index.ts index b9229e1..48684f7 100644 --- a/packages/ui/src/lib/index.ts +++ b/packages/ui/src/lib/index.ts @@ -7,6 +7,8 @@ import Select from "./elements/Select.svelte"; import Checkbox from "./elements/Checkbox.svelte"; import Details from "./Details.svelte"; +export const icons = import.meta.glob('./icons/*.svg?raw', { eager: true }) + export { Float, Integer, Select, Checkbox, Input, Details }; export default Input; diff --git a/packages/utils/src/flatTree.ts b/packages/utils/src/flatTree.ts index 729d11d..a42f101 100644 --- a/packages/utils/src/flatTree.ts +++ b/packages/utils/src/flatTree.ts @@ -54,9 +54,7 @@ export function encodeNestedArray(array: SparseArray): number[] { encoded.push(0, 1, 1, 1); } else { // Recursively encode non-empty arrays - console.log("recursing", item); const child = encodeNestedArray(item); - console.log("recursed", child); encoded.push(...child); } // Update missingBracketIndex to the position of the newly added bracket @@ -67,7 +65,6 @@ export function encodeNestedArray(array: SparseArray): number[] { // Update the distance for the last opened bracket if (missingBracketIndex) encoded[missingBracketIndex] = index + 2; } - console.log(encoded, item); } return [...encoded, 1, 1]; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d3477bb..b4d1e13 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -108,6 +108,8 @@ importers: nodes/max/plantarium/float: {} + nodes/max/plantarium/gravity: {} + nodes/max/plantarium/math: {} nodes/max/plantarium/noise: {}