Vai al contenuto

Esempi

Scheda di condivisione documento

Un link condivisibile da copiare sopra un elenco di persone, dove un select compatto imposta l'autorizzazione per ciascuna persona.

Anteprima

Share this document

Anyone with the link can view this document.

People with access
Olivia Martin b@example.com
Isabella Nguyen i@example.com
Ethan Thompson e@example.com
HTML
<bs:bsui-card>
  <bs:bsui-card-header>
    <bs:bsui-card-title label="Share this document" />
    <bs:bsui-card-description label="Anyone with the link can view this document." />
  </bs:bsui-card-header>
  <bs:bsui-card-content>
    <bs:bsui-stack direction="column" gap="4" align="stretch">
      <bs:bsui-stack direction="row" gap="2" align="center">
        <bs:bsui-input name="share_link" defaultValue="https://acme.app/d/q3-forecast" />
        <bs:bsui-button label="Copy link" variant="outline" />
      </bs:bsui-stack>
      <bs:bsui-separator />
      <bs:bsui-text content="People with access" variant="label" tag="span" />
      <bs:bsui-stack direction="row" gap="3" align="center" justify="space-between">
        <bs:bsui-stack direction="row" gap="3" align="center">
          <bs:bsui-avatar fallback="OM" alt="Olivia Martin" />
          <bs:bsui-stack direction="column" gap="1">
            <bs:bsui-text content="Olivia Martin" variant="label" tag="span" />
            <bs:bsui-text content="b@example.com" variant="muted" tag="span" />
          </bs:bsui-stack>
        </bs:bsui-stack>
        <bs:bsui-select defaultValue="edit" placeholder="Permission">
          <bs:bsui-select-trigger />
          <bs:bsui-select-popup>
            <bs:bsui-select-option value="edit" label="Can edit" />
            <bs:bsui-select-option value="view" label="Can view" />
          </bs:bsui-select-popup>
        </bs:bsui-select>
      </bs:bsui-stack>
      <bs:bsui-stack direction="row" gap="3" align="center" justify="space-between">
        <bs:bsui-stack direction="row" gap="3" align="center">
          <bs:bsui-avatar fallback="IN" alt="Isabella Nguyen" />
          <bs:bsui-stack direction="column" gap="1">
            <bs:bsui-text content="Isabella Nguyen" variant="label" tag="span" />
            <bs:bsui-text content="i@example.com" variant="muted" tag="span" />
          </bs:bsui-stack>
        </bs:bsui-stack>
        <bs:bsui-select defaultValue="view" placeholder="Permission">
          <bs:bsui-select-trigger />
          <bs:bsui-select-popup>
            <bs:bsui-select-option value="edit" label="Can edit" />
            <bs:bsui-select-option value="view" label="Can view" />
          </bs:bsui-select-popup>
        </bs:bsui-select>
      </bs:bsui-stack>
      <bs:bsui-stack direction="row" gap="3" align="center" justify="space-between">
        <bs:bsui-stack direction="row" gap="3" align="center">
          <bs:bsui-avatar fallback="ET" alt="Ethan Thompson" />
          <bs:bsui-stack direction="column" gap="1">
            <bs:bsui-text content="Ethan Thompson" variant="label" tag="span" />
            <bs:bsui-text content="e@example.com" variant="muted" tag="span" />
          </bs:bsui-stack>
        </bs:bsui-stack>
        <bs:bsui-select defaultValue="view" placeholder="Permission">
          <bs:bsui-select-trigger />
          <bs:bsui-select-popup>
            <bs:bsui-select-option value="edit" label="Can edit" />
            <bs:bsui-select-option value="view" label="Can view" />
          </bs:bsui-select-popup>
        </bs:bsui-select>
      </bs:bsui-stack>
    </bs:bsui-stack>
  </bs:bsui-card-content>
</bs:bsui-card>

Come funziona

L'azione di copia legge il link dall'input nello stato, lo scrive negli appunti e, tramite il contesto, cambia l'etichetta del pulsante in Copiato per due secondi. Ogni select delle autorizzazioni conferma direttamente le modifiche nell'elenco degli accessi dello store.

Ogni comportamento di questa pagina usa Interactivity WordPress API: ogni componente registra il proprio store, inizializza il proprio stato in un contesto renderizzato dal server e collega gli eventi con direttive nel markup qui sopra. Non esiste alcun JavaScript specifico per la pagina.