Skip to content
This repository was archived by the owner on Aug 24, 2024. It is now read-only.

Commit 101deff

Browse files
authored
Remove icky subscribe (#2)
1 parent 0297449 commit 101deff

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

frontend/src/components/PropertyEditor.svelte

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@
88
24: 'Floats',
99
32: 'Enable gravity',
1010
};
11-
12-
let propertyValues = $store.brushColour.split('').map((v) => v === '1');
13-
14-
store.subscribe((value) => {
15-
propertyValues = value.brushColour.split('').map((v) => v === '1');
16-
});
17-
18-
$: {
19-
$store.brushColour = propertyValues.map((v) => (v ? '1' : '0')).join('');
20-
}
2111
</script>
2212

2313
<div class="col-span-2 flex flex-col items-center">
@@ -26,10 +16,20 @@
2616
{#each Array(4) as _, groupIndex}
2717
<div class="flex flex-1 justify-between">
2818
{#each Array(8) as _, i}
19+
{@const index = 8 * groupIndex + i}
20+
{@const checked = $store.brushColour[index] === '1'}
2921
<div class="flex flex-col items-center gap-2">
30-
<input type="checkbox" bind:checked={propertyValues[8 * groupIndex + i]} />
22+
<input
23+
type="checkbox"
24+
{checked}
25+
on:change={() => {
26+
const arr = $store.brushColour.split('');
27+
arr[index] = checked ? '0' : '1';
28+
$store.brushColour = arr.join('');
29+
}}
30+
/>
3131
<div style:writing-mode="vertical-lr">
32-
{propertyDescriptions[8 * groupIndex + i + 1] || ''}
32+
{propertyDescriptions[index] || ''}
3333
</div>
3434
</div>
3535
{/each}

0 commit comments

Comments
 (0)