app

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

primitives.svelte (2556B)


      1 <script lang="ts">
      2   import FormField from '../../../src/lib/components/primitives/FormField.svelte';
      3   import Button from '../../../src/lib/components/primitives/Button.svelte';
      4   import Disclosure from '../../../src/lib/components/primitives/Disclosure.svelte';
      5   import PageHeading from '../../../src/lib/components/primitives/PageHeading.svelte';
      6   import ActionGroup from '../../../src/lib/components/primitives/ActionGroup.svelte';
      7   import EmptyState from '../../../src/lib/components/primitives/EmptyState.svelte';
      8   import ConfirmPanel from '../../../src/lib/components/primitives/ConfirmPanel.svelte';
      9   let commands = $state(0);
     10   let open = $state(false);
     11   let pending = $state(false);
     12   const reference = 'TEST_PUBLIC_REFERENCE_' + '0123456789abcdef'.repeat(32);
     13 </script>
     14 
     15 <div class="page page--reading stack">
     16   <PageHeading
     17     title="Primitive qualification fixture"
     18     description="Trusted test presentation only"
     19   />
     20   <FormField
     21     id="terms"
     22     label="Public terms"
     23     hint="Describe the public offer"
     24     error="Enter public terms"
     25   >
     26     {#snippet control({ id, describedby, invalid })}
     27       <input
     28         class="input"
     29         {id}
     30         aria-describedby={describedby}
     31         aria-invalid={invalid}
     32         value={reference}
     33       />
     34     {/snippet}
     35   </FormField>
     36   <ActionGroup>
     37     <Button
     38       label="Fixture command"
     39       variant="primary"
     40       onclick={() => commands++}
     41     />
     42     <Button label="Disabled command" disabled onclick={() => commands++} />
     43     <Button kind="link" href="#fixture-empty" label="Fixture navigation" />
     44   </ActionGroup>
     45   <p role="status" aria-live="polite">Commands: {commands}</p>
     46   <Disclosure summary="Public fixture details"
     47     ><p class="key">{reference}</p></Disclosure
     48   >
     49   <div id="fixture-empty">
     50     <EmptyState
     51       title="No fixture results"
     52       description="Try another fixture query"
     53     />
     54   </div>
     55   <button
     56     type="button"
     57     class="button button--secondary"
     58     id="fixture-review"
     59     onclick={() => (open = true)}>Review discard</button
     60   >
     61   {#if open}
     62     <ConfirmPanel
     63       id="discard"
     64       title="Discard this draft?"
     65       impact="This removes this browser draft. Remote copies remain."
     66       confirmLabel="Discard draft"
     67       cancelLabel="Keep editing"
     68       {pending}
     69       onconfirm={() => {
     70         commands++;
     71         pending = true;
     72       }}
     73       oncancel={() => {
     74         open = false;
     75         pending = false;
     76       }}
     77       returnFocus={() =>
     78         globalThis.document.getElementById('fixture-review')?.focus()}
     79     />
     80   {/if}
     81 </div>