Pular para o conteúdo

Exemplos

Cartão de compartilhamento de documento

Um link de compartilhamento copiável acima de uma lista de pessoas, com um seletor compacto que define a permissão de cada pessoa.

Pré-visualização

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>

Como funciona

A ação de cópia lê o link do campo de entrada no estado, grava-o na área de transferência e, pelo contexto, troca o rótulo do botão para Copiado por dois segundos. Cada seletor de permissão confirma diretamente na lista de acessos mantida no armazenamento.

Todo comportamento nesta página vem da WordPress Interactivity API: cada componente registra seu próprio armazenamento, inicializa seu estado em um contexto renderizado no servidor e conecta eventos com diretivas na marcação acima. Não há JavaScript específico para a página.