feat: refactor how frontend was structured
Some checks failed
Deploy to GitHub Pages / build_site (push) Failing after 1m16s
Some checks failed
Deploy to GitHub Pages / build_site (push) Failing after 1m16s
This commit is contained in:
40
app/src/lib/settings/panels/GraphSettings.svelte
Normal file
40
app/src/lib/settings/panels/GraphSettings.svelte
Normal file
@@ -0,0 +1,40 @@
|
||||
<script lang="ts">
|
||||
import type { NodeInput } from "@nodes/types";
|
||||
import NestedSettings from "./NestedSettings.svelte";
|
||||
import type { Writable } from "svelte/store";
|
||||
|
||||
interface Nested {
|
||||
[key: string]: NodeInput | Nested;
|
||||
}
|
||||
|
||||
export let type: Record<string, NodeInput>;
|
||||
|
||||
export let store: Writable<Record<string, any>>;
|
||||
|
||||
function constructNested(type: Record<string, NodeInput>) {
|
||||
const nested: Nested = {};
|
||||
|
||||
for (const key in type) {
|
||||
const parts = key.split(".");
|
||||
let current = nested;
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
if (i === parts.length - 1) {
|
||||
current[parts[i]] = type[key];
|
||||
} else {
|
||||
current[parts[i]] = current[parts[i]] || {};
|
||||
current = current[parts[i]] as Nested;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nested;
|
||||
}
|
||||
|
||||
$: settings = constructNested({
|
||||
randomSeed: { type: "boolean", value: false },
|
||||
...type,
|
||||
});
|
||||
</script>
|
||||
|
||||
{#key settings}
|
||||
<NestedSettings id="graph-settings" {settings} {store} />
|
||||
{/key}
|
||||
Reference in New Issue
Block a user