Skip to content

Commit

Permalink
a couple more
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Mar 18, 2024
1 parent 599a93f commit 44e4f9f
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 57 deletions.
2 changes: 2 additions & 0 deletions src/controls/GetColorsFromString.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
const newColors = body
.split(",")
.map((x) => x.replace(/"/g, "").trim())
// remove all parens and brackets
.map((x) => x.replace(/[\(\)\[\]]/g, ""))
.filter((x) => x.length > 0)
.map((x) => Color.colorFromString(x, colorSpace as any))
.map((x, idx) => {
Expand Down
83 changes: 38 additions & 45 deletions src/linting/EvalResponse.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,13 @@
function proposeFix(useAi: boolean = false) {
requestState = "loading";
let hasRetried = false;
const getFix = () => {
if (useAi) {
return suggestLintAIFix(palette, check, engine).then((x) => {
suggestions = x;
const getFix = () =>
(useAi ? suggestLintAIFix : suggestLintFix)(palette, check, engine).then(
(x) => {
suggestions = [...suggestions, ...x];
requestState = "loaded";
});
} else {
return suggestLintFix(palette, check, engine).then((x) => {
suggestions = x;
requestState = "loaded";
});
}
};
}
);
getFix().catch((e) => {
console.log(e);
Expand Down Expand Up @@ -151,40 +145,39 @@
<div>Loading...</div>
{:else if requestState === "failed"}
<div>Failed to generate suggestions</div>
{:else if requestState === "loaded"}
{#each suggestions as suggestion}
<div class="flex">
<PalDiff beforePal={currentPal} afterPal={suggestion} />
<div class="flex flex-col justify-between">
<button
class={buttonStyle}
on:click={() => {
if (suggestion) {
colorStore.setCurrentPal(suggestion);
focusStore.clearColors();
requestState = "idle";
suggestions = [];
onClick();
}
}}
>
Use
</button>
<button
class={buttonStyle}
on:click={() => {
suggestions = suggestions.filter((x) => x !== suggestion);
if (suggestions.length === 0) {
requestState = "idle";
}
}}
>
Reject
</button>
</div>
</div>
{/each}
{/if}
{#each suggestions as suggestion}
<div class="flex">
<PalDiff beforePal={currentPal} afterPal={suggestion} />
<div class="flex flex-col justify-between">
<button
class={buttonStyle}
on:click={() => {
if (suggestion) {
colorStore.setCurrentPal(suggestion);
focusStore.clearColors();
requestState = "idle";
suggestions = [];
onClick();
}
}}
>
Use
</button>
<button
class={buttonStyle}
on:click={() => {
suggestions = suggestions.filter((x) => x !== suggestion);
if (suggestions.length === 0) {
requestState = "idle";
}
}}
>
Reject
</button>
</div>
</div>
{/each}
</div>
<button
slot="target"
Expand Down
50 changes: 38 additions & 12 deletions src/linting/LintCustomizationTab.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -459,18 +459,44 @@
<div class="flex flex-col w-1/2">
<div class="flex">
<div class="font-bold">Expected to be passing:</div>
<button
class={buttonStyle}
on:click={() => {
const newTests = [
...lint.expectedPassingTests,
makePalFromString(["steelblue"]),
];
lintStore.setCurrentLintExpectedPassingTests(newTests);
}}
>
(Add Test)
</button>
<Tooltip>
<div slot="content" let:onClick>
<button
class={buttonStyle}
on:click={() => {
const newTests = [
...lint.expectedPassingTests,
makePalFromString(["steelblue"]),
];
lintStore.setCurrentLintExpectedPassingTests(newTests);
onClick();
}}
>
From blank
</button>
<button
class={buttonStyle}
on:click={() => {
const newTests = [
...lint.expectedPassingTests,
currentPal,
];
lintStore.setCurrentLintExpectedPassingTests(newTests);
onClick();
}}
>
From current palette
</button>
</div>
<button
slot="target"
let:toggle
on:click={toggle}
class={buttonStyle}
>
(Add Test)
</button>
</Tooltip>
</div>
<div class="flex">
{#each passingTestResults as passing, idx}
Expand Down

0 comments on commit 44e4f9f

Please sign in to comment.