Playing with Svelte

This commit is contained in:
2025-08-16 20:52:33 -07:00
parent 78a727519a
commit 5796663486
9 changed files with 368 additions and 58 deletions
+6
View File
@@ -0,0 +1,6 @@
import { mount } from 'svelte';
import App from './components/App.svelte';
const app = document.getElementById('app')!;
mount(App, { target: app });
+13
View File
@@ -0,0 +1,13 @@
<script lang="ts">
import Chooser from "./Chooser.svelte";
import Editor from "./Editor.svelte";
let currentFile: string | null = $state(null);
</script>
{#if currentFile === null}
<Chooser bind:file={currentFile}/>
{:else}
<button onclick={() => currentFile = null}>Back</button>
<Editor file={currentFile}/>
{/if}
+25
View File
@@ -0,0 +1,25 @@
<script lang="ts">
const files = ["foo", "bar", "baz"];
let { file = $bindable() } = $props();
</script>
<style>
.file {
border: none;
background: none;
text-align: left;
width: 100%;
}
.file:hover {
cursor: pointer;
background-color: #ddd;
}
</style>
{#each files as availableFile (availableFile)}
<button class="file" onclick={() => file = availableFile}>
{availableFile}
{availableFile === file ? "(*)" : ""}
</button>
{/each}
+5
View File
@@ -0,0 +1,5 @@
<script lang="ts">
const { file } = $props();
</script>
<p>You are editing {file}.</p>