Skip to content

Commit

Permalink
fix: bindable+localstorage conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
sverben committed May 3, 2024
1 parent cbc8a84 commit 4088651
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@types/w3c-web-serial": "^1.0.6",
"@types/wicg-file-system-access": "^2023.10.5",
"svelte": "5.0.0-next.121",
"svelte-check": "^3.6.7",
"svelte-check": "3.7.1",
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"vite": "^5.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/core/popups/popups/Prompt.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface Props {
confirm: string;
value?: string;
}
const { name, placeholder, confirm, value = "" }: Props = $props();
let { name, placeholder, confirm, value = $bindable("") }: Props = $props();
const popupState = getContext<Writable<PopupState>>("state");
function cancel() {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const {
icon,
}: Props = $props();
const btn: HTMLButtonElement = $state();
let btn: HTMLButtonElement = $state();
const open = setContext("open", writable(false));
function onContext() {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/ui/CodeEditor.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script lang="ts">
import { onMount, type Bindable } from "svelte";
import { onMount } from "svelte";
import * as monaco from "monaco-editor";
import { Theme, theme } from "$state/app.svelte";
interface Props {
value: Bindable<string>;
value: string;
language: string;
editable?: boolean;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/ContextItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const {
selected = false,
}: Props = $props();
const element = $state<HTMLDivElement>();
let element = $state<HTMLDivElement>();
let contextShowing = $state(false);
const open = getContext<Writable<boolean>>("open");
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/Library.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface Props {
}
const { library }: Props = $props();
const version = $state(library.versions[0]);
let version = $state(library.versions[0]);
const isInstalled = $derived(
!!$installed.find(([name]) => name === library.name),
);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/ui/Select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ interface Props {
}
let { options, value = $bindable() }: Props = $props();
const preview: HTMLButtonElement = $state();
const content: HTMLDivElement = $state();
let preview: HTMLButtonElement = $state();
let content: HTMLDivElement = $state();
let open = $state(false);
let position = $state<{ x: number; y: number }>({ x: 0, y: 0 });
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/TextInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface Props {
rounded: boolean;
focus?: boolean;
}
const {
let {
placeholder,
value = $bindable(""),
mode,
Expand Down
5 changes: 1 addition & 4 deletions src/lib/components/workspace/panels/LibraryManager.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import { _ } from "svelte-i18n";
import TextInput from "$components/ui/TextInput.svelte";
import { onMount } from "svelte";
import { libraries } from "$state/app.svelte";
import Select from "$components/ui/Select.svelte";
import Button from "$components/ui/Button.svelte";
import { installed } from "$state/workspace.svelte";
import Library from "$components/ui/Library.svelte";
const filter = $state("");
let filter = $state("");
onMount(() => {
libraries.query();
});
Expand Down
5 changes: 4 additions & 1 deletion src/lib/state/app.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ export interface Library {
versions: string[];
}

if (!["light", "dark"].includes(localStorage.getItem("theme"))) {
localStorage.setItem("theme", Theme.LIGHT)
}
export const theme = writable<Theme>(
(localStorage.getItem("theme") as Theme) || Theme.LIGHT,
(localStorage.getItem("theme") as Theme),
);
theme.subscribe((theme) => {
document.body.setAttribute("data-color-scheme", theme);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2227,10 +2227,10 @@ supports-color@^5.3.0:
dependencies:
has-flag "^3.0.0"

svelte-check@^3.6.7:
version "3.6.8"
resolved "https://registry.npmjs.org/svelte-check/-/svelte-check-3.6.8.tgz"
integrity sha512-rhXU7YCDtL+lq2gCqfJDXKTxJfSsCgcd08d7VWBFxTw6IWIbMWSaASbAOD3N0VV9TYSSLUqEBiratLd8WxAJJA==
svelte-check@3.7.1:
version "3.7.1"
resolved "https://registry.yarnpkg.com/svelte-check/-/svelte-check-3.7.1.tgz#d24d0535b22d9d9d8b50aa41f894f59544e9e577"
integrity sha512-U4uJoLCzmz2o2U33c7mPDJNhRYX/DNFV11XTUDlFxaKLsO7P+40gvJHMPpoRfa24jqZfST4/G9fGNcUGMO8NAQ==
dependencies:
"@jridgewell/trace-mapping" "^0.3.17"
chokidar "^3.4.1"
Expand Down

0 comments on commit 4088651

Please sign in to comment.