app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

ConfirmPanel.svelte (961B)


      1 <script lang="ts">
      2   import Button from './Button.svelte';
      3   let {
      4     id,
      5     title,
      6     impact,
      7     confirmLabel,
      8     cancelLabel,
      9     onconfirm,
     10     oncancel,
     11     returnFocus,
     12     pending = false
     13   }: {
     14     id: string;
     15     title: string;
     16     impact: string;
     17     confirmLabel: string;
     18     cancelLabel: string;
     19     onconfirm: () => void;
     20     oncancel: () => void;
     21     returnFocus?: () => void;
     22     pending?: boolean;
     23   } = $props();
     24   function cancel() {
     25     oncancel();
     26     returnFocus?.();
     27   }
     28   function confirm() {
     29     if (!pending) onconfirm();
     30   }
     31 </script>
     32 
     33 <section
     34   class="notice stack"
     35   aria-labelledby={`${id}-title`}
     36   aria-describedby={`${id}-impact`}
     37 >
     38   <h2 id={`${id}-title`}>{title}</h2>
     39   <p id={`${id}-impact`}>{impact}</p>
     40   <div class="cluster">
     41     <Button label={cancelLabel} onclick={cancel} />
     42     <Button
     43       label={confirmLabel}
     44       variant="primary"
     45       disabled={pending}
     46       onclick={confirm}
     47     />
     48   </div>
     49 </section>