Skip to content

Commit

Permalink
refactor the palete top
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Sep 19, 2024
1 parent ece20b0 commit a6421b8
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 90 deletions.
1 change: 1 addition & 0 deletions apps/color-buddy/src/components/Nav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
on:click={() => selectTab(tab)}
>
{formatter(tab)}
<slot name="menu" {tab} />
</button>
</li>
{/each}
Expand Down
87 changes: 36 additions & 51 deletions apps/color-buddy/src/content-modules/Manage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -173,65 +173,50 @@
}}
>
<div class="bg-stone-200 p-4 text-xl font-bold">Palettes</div>
<div class="bg-stone-100 flex h-full py-2 px-4">
<div class="flex flex-col">
<div class="text-sm uppercase font-bold">My Folders</div>
<div class="flex">
{#each folders as folder}
<div
class="flex duration-150 px-1 items-center"
class:border-stone-400={selectedFolder?.name !== folder}
class:border-b={selectedFolder?.name !== folder}
class:border-black={selectedFolder?.name === folder}
class:border-b-2={selectedFolder?.name === folder}
>
<button
class={"whitespace-nowrap "}
on:click={() =>
configStore.setSelectedFolder({
isPreMade: false,
name: folder,
})}
>
{folder.length ? `${folder}` : "Home"}
</button>
{#if folder !== ""}
<div class="bg-stone-100 flex flex-col h-full py-2 px-4">
<div class="flex w-full">
<div class="flex flex-col">
<div class="text-sm uppercase font-bold">My Folders</div>
<Nav
tabs={folders}
isTabSelected={(tab) => selectedFolder?.name === tab}
formatter={(x) => x || "Home"}
selectTab={(tab) => {
configStore.setSelectedFolder({
isPreMade: false,
name: tab,
});
}}
>
<div slot="menu" let:tab>
{#if tab !== ""}
<div class="px-1">
<FolderConfig {folder} />
<FolderConfig folder={tab} />
</div>
{/if}
</div>
{/each}
<button
class="px-1"
on:click={() => {
folders = [...folders, newVersionName("new folder", folders)];
</Nav>
</div>
<div class="flex flex-col mx-2">
<div class="text-sm uppercase font-bold">Samples</div>
<Nav
tabs={["sequential", "categorical", "diverging"]}
isTabSelected={(tab) => selectedFolder?.name === tab}
selectTab={(tab) => {
configStore.setSelectedFolder({
isPreMade: true,
name: tab,
});
}}
>
<Plus />
</button>
/>
</div>
<GenerateNewNames />
<div class="flex justify-between items-center">
<span class="whitespace-nowrap mr-2 ml-4">Thumbnail Style:</span>
<PreviewSelector exampleName={example?.name || "Discs"} />
</div>
</div>
<div class="flex flex-col mx-2">
<div class="text-sm uppercase font-bold">Samples</div>
<Nav
tabs={["sequential", "categorical", "diverging"]}
isTabSelected={(tab) => selectedFolder?.name === tab}
selectTab={(tab) => {
configStore.setSelectedFolder({
isPreMade: true,
name: tab,
});
}}
/>
</div>
<GenerateNewNames />
<div class="flex justify-between items-center">
<span class="whitespace-nowrap mr-2 ml-4">Thumbnail Style:</span>
<PreviewSelector exampleName={example?.name || "Discs"} />
</div>
</div>

<div
class="flex flex-wrap h-full overflow-auto p-4 content-baseline min-h-96"
>
Expand Down
39 changes: 0 additions & 39 deletions apps/color-buddy/src/controls/Config.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -87,48 +87,9 @@
</button>
<div slot="content">
<div class="flex mb-4">
<button
class={buttonStyle}
on:click={() => {
const pals = $colorStore.palettes.map((x) => {
const { colors, background, name, colorSpace, type } = x;
return {
background: background.toHex(),
colorSpace,
colors: colors.map((c) => c.toHex()),
name,
type,
};
});
const blob = new Blob([JSON.stringify(pals)], {
type: "application/json",
});

const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.style.display = "none";
a.href = url;

// the filename you want
a.download = "palettes-export.json";
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
}}
>
Export Palettes
</button>
<button class={buttonStyle} on:click={() => importPals()}>
Import Palettes
</button>
<button
class={buttonStyle}
on:click={() => {
colorStore.clearPalettes();
}}
>
Clear Palettes
</button>
</div>
<div class="font-bold">Configurations</div>
<div>Pick AI Provider</div>
Expand Down
33 changes: 33 additions & 0 deletions apps/color-buddy/src/controls/FolderConfig.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,39 @@
}}
>
<div slot="content" class="flex flex-col">
<button
class={simpleTooltipRowStyle}
on:click={() => {
const pals = $colorStore.palettes
.filter((x) => x.folder === folder)
.map((x) => {
const { colors, background, name, colorSpace, type } = x;
return {
background: background.toHex(),
colorSpace,
colors: colors.map((c) => c.toHex()),
name,
type,
};
});
const blob = new Blob([JSON.stringify(pals)], {
type: "application/json",
});

const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.style.display = "none";
a.href = url;

// the filename you want
a.download = "palettes-export.json";
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
}}
>
Export Palettes
</button>
<button
class={simpleTooltipRowStyle}
on:click={() => {
Expand Down

0 comments on commit a6421b8

Please sign in to comment.