diff --git a/src/example/ExampleWrapper.svelte b/src/example/ExampleWrapper.svelte index a5644997..f15cfcc8 100644 --- a/src/example/ExampleWrapper.svelte +++ b/src/example/ExampleWrapper.svelte @@ -9,9 +9,9 @@ export let idx: number; export let bg: string; export let clickExample: (example: any, idx: number) => void; - - let operations = [ - { name: "Edit", action: () => clickExample(example, idx), condition: true }, + $: size = example.size || 250; + $: operations = [ + { name: "Edit", action: () => clickExample(example, idx) }, { name: "Delete", action: () => exampleStore.deleteExample(idx), @@ -22,11 +22,7 @@ action: () => exampleStore.toggleHidden(idx), condition: true, }, - { - name: "Expand", - action: () => exampleStore.setExampleSize(idx, 600), - condition: true, - }, + { name: "Focus (expand and hide others)", action: () => { @@ -35,10 +31,20 @@ }, condition: true, }, + { + name: "Expand", + action: () => exampleStore.setExampleSize(idx, 600), + condition: size !== 600, + }, + { + name: "Reset size", + action: () => exampleStore.setExampleSize(idx, 250), + condition: size !== 250, + }, { name: "Shrink", action: () => exampleStore.setExampleSize(idx, 50), - condition: true, + condition: size !== 50, }, ].filter((x) => x.condition); @@ -60,7 +66,7 @@ -
+
{#each operations as { name, action }} {/each} diff --git a/src/example/Examples.svelte b/src/example/Examples.svelte index 6969ac7f..accecbda 100644 --- a/src/example/Examples.svelte +++ b/src/example/Examples.svelte @@ -87,19 +87,6 @@ $: groupsHidden = Object.keys(sections).filter((x) => !sections[x]).length; $: hiddenExamples = $exampleStore.examples.filter((x: any) => x.hidden); $: numberHidden = hiddenExamples.length + groupsHidden; - - $: numToShow = $exampleStore.examples.filter((x: any) => { - if (x.hidden) { - return false; - } - if (sections.svg && x?.svg) { - return true; - } - if (sections.vega && x.vega) { - return true; - } - return false; - }).length;
@@ -171,49 +158,14 @@ class="flex flex-wrap overflow-auto p-4 w-full bg-stone-100" style={`height: calc(100% - 100px)`} > + {#if $exampleStore.sections["swatches"]} + + {/if} {#each examples as example, idx} {#if exampleShowMap[idx]} {/if} {/each} - {#if $exampleStore.sections["swatches"]} -
-
- Swatches - - -
- - {#if numToShow > 1} - - {/if} -
-
-
- -
- {/if}
{#if modalState !== "closed"} { + if (x.hidden) { + return false; + } + if (sections.svg && x?.svg) { + return true; + } + if (sections.vega && x.vega) { + return true; + } + return false; + }).length; -
-
- -
- {#each classes as { className, styleMap, selectionClass }} -
- {#each colors as color, idx} - -
- -
+
+
+ Swatches + + +
+ + {#if numToShow > 1} + {/if} +
+
+
+
+ {#each classes as { className, styleMap, selectionClass }} +
+ {#each colors as color, idx} + +
+ +
+ -
+ }} + > + + {/each} +
+ {/each} +
+ {#each colors as color, i} + {/each}
- {/each} -
- {#each colors as color, i} - - {/each}