各种笔记 – Snippets - the-dissidents/subtle GitHub Wiki

Template for Dialogs

<script lang="ts">
import DialogBase from '../DialogBase.svelte';
import { Debug } from '../Debug';
import { DialogHandler } from '../frontend/Dialogs';

import { _ } from 'svelte-i18n';

interface Props {
  handler: DialogHandler<void, /* return type here */>;
}
    
let {
  handler = $bindable(),
}: Props = $props();

let inner = new DialogHandler<void>();
handler.showModal = async () => {
  Debug.assert(inner !== undefined);
  /* insert preparation here */
  let btn = await inner.showModal!();
  /* insert processing here */
  return /* result */;
}
</script>

<DialogBase handler={inner}>
  {#snippet header()}
    <h3><!-- dialog title --></h3>
  {/snippet}
  <!-- content here -->
</DialogBase>
⚠️ **GitHub.com Fallback** ⚠️