Skip to content

Commit

Permalink
everything is running again
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Mar 11, 2024
1 parent 57ad5c4 commit 754aa58
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/controls/NewPal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
function newPal(newPal: StringPalette) {
const colors = newPal.colors.map((x) => {
const color = Color.colorFromString(x.color, colorSpace);
return { ...x, color };
return wrapInBlankSemantics(color);
});
const pal = {
...newPal,
Expand Down
5 changes: 4 additions & 1 deletion src/lib/api-calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ export function lint(pal: Palette, computeMessage: boolean) {
content: JSON.stringify({
...pal,
background: pal.background.toString(),
colors: pal.colors.map((x) => x.color.toString()),
colors: pal.colors.map((x) => ({
...x,
color: x.color.toString(),
})),
}),
}).then((x) => {
return x as unknown as any[];
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export function newGenericPal(name: string): StringPalette {
return {
...defaultHexPal,
name,
colors: pick(outfits),
colors: pick(outfits).map((x: string) => wrapInBlankStringSemantics(x)),
};
}
export function makePalFromString(
Expand Down
7 changes: 3 additions & 4 deletions src/stores/color-store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { writable } from "svelte/store";
import { Color } from "../lib/Color";
import { deDup, newGenericPal, wrapInBlankStringSemantics } from "../lib/utils";
import { deDup, newGenericPal, wrapInBlankSemantics } from "../lib/utils";

import type {
Palette,
Expand All @@ -27,12 +27,11 @@ function stringPalToColorPal(pal: StringPalette): Palette {
...pal,
background: Color.colorFromString(pal.background, pal.colorSpace),
colors: pal.colors.map((x) => {
let colorWrap = x;
const color = Color.colorFromString(x.color, pal.colorSpace);
// catch old versions
if (typeof x === "string") {
colorWrap = wrapInBlankStringSemantics(x);
return wrapInBlankSemantics(Color.colorFromString(x, pal.colorSpace));
}
const color = Color.colorFromString(x.color, pal.colorSpace);
return { ...x, color };
}),
};
Expand Down
8 changes: 4 additions & 4 deletions src/stores/lint-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function serializePalette(pal: Palette): StringPalette {
background: pal.background.toString(),
colors: pal.colors.map((x) => ({
...x,
color: x.toString(),
color: x.color.toString(),
})),
};
}
Expand All @@ -51,10 +51,10 @@ function deserializePalette(pal: StringPalette): Palette {
...pal,
background: Color.colorFromString(pal.background, pal.colorSpace),
colors: pal.colors.map((x) => {
const color = Color.colorFromString(x.color, pal.colorSpace);
if (typeof x.color === "string") {
return wrapInBlankSemantics(color);
if (typeof x === "string") {
return wrapInBlankSemantics(Color.colorFromString(x, pal.colorSpace));
}
const color = Color.colorFromString(x.color, pal.colorSpace);
return { ...x, color };
}),
};
Expand Down

0 comments on commit 754aa58

Please sign in to comment.