Skip to content

Commit

Permalink
Remove legacy runs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnw committed Nov 1, 2024
1 parent 74a15b4 commit 72a6ab3
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/lib/components/SpaceSelect.svelte
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
<script lang="ts">
import { to } from 'colorjs.io/fn';
import { run } from 'svelte/legacy';
import { FORMATS } from '$lib/constants';
import { bg, ColorSpace, fg, format } from '$lib/stores';
import { getSpaceFromFormatId } from '$lib/utils';
let spaces: ColorSpace[] = $state([]);
run(() => {
spaces = FORMATS.map((s) => {
if (s === 'hex') return { id: 'hex', name: 'Hex' } as ColorSpace;
return ColorSpace.get(s);
});
let spaces: ColorSpace[] = FORMATS.map((s) => {
if (s === 'hex') return { id: 'hex', name: 'Hex' } as ColorSpace;
return ColorSpace.get(s);
});
let targetSpace = $derived(getSpaceFromFormatId($format));
// Update color formats when space selection changes
run(() => {
// Use $effect.pre to change colors before the $format update is applied.
$effect.pre(() => {
let targetSpace = getSpaceFromFormatId($format);
if ($bg.space.id !== targetSpace) {
$bg = to($bg, targetSpace, { inGamut: true });
}
Expand Down

0 comments on commit 72a6ab3

Please sign in to comment.