Vitral 0.2.18
Mensagens

Message

Uma mensagem inline com título, ação e botão de fechar, em todas as severidades.

Importação

main.ts
import { Message } from '@vitral/vue';

InfoBar

Título e mensagem dividem uma linha enquanto couberem.

Update available
Restart the app to install version 2.4.
Backup complete
1,204 files were copied to the cloud.
<script setup lang="ts">import { Message, StackPanel } from '@vitral/vue';</script> <template>    <StackPanel spacing="0.625rem" style="width: 100%">        <Message severity="info" title="Update available">Restart the app to install version 2.4.</Message>        <Message severity="success" title="Backup complete">1,204 files were copied to the cloud.</Message>        <Message severity="warn" title="Storage almost full">You have used 92% of your 15 GB.</Message>        <Message severity="danger" title="Sync failed">The server could not be reached. Check your connection and try again.</Message>    </StackPanel></template>

Ação e fechar

O slot action recebe um botão ou link; `closable` adiciona um botão de fechar que emite `close`.

New sign-in
Someone signed in from a new device in São Paulo.
<script setup lang="ts">import { Button, Message, StackPanel } from '@vitral/vue';import { ref } from 'vue'; const shown = ref(true);const key = ref(0);</script> <template>    <StackPanel spacing="0.625rem" style="width: 100%">        <Message v-if="shown" :key="key" severity="info" title="New sign-in" closable @close="shown = false">            Someone signed in from a new device in São Paulo.            <template #action>                <Button label="Review" size="small" severity="secondary" />            </template>        </Message>        <Button v-else label="Show it again" severity="secondary" size="small" @click="(shown = true), key++" />    </StackPanel></template>

Estreita

Numa faixa estreita a ação desce para baixo do texto; `:stack-action="false"` a mantém ao lado.

<script setup lang="ts">import { Button, Message, StackPanel } from '@vitral/vue';</script> <template>    <StackPanel spacing="0.625rem" style="width: 100%; max-width: 24rem">        <Message severity="warn" title="Payment overdue" closable>            The invoice for September is five days late.            <template #action>                <Button label="Pay now" size="small" severity="secondary" />            </template>        </Message>        <Message severity="warn" title="Payment overdue" closable :stack-action="false">            The invoice for September is five days late.            <template #action>                <Button label="Pay now" size="small" severity="secondary" />            </template>        </Message>    </StackPanel></template>

Variantes

`outlined` e `simple`; todas as severidades funcionam com cada uma.

Drafts are kept for 30 days.
Username is available.
<script setup lang="ts">import { Message, StackPanel } from '@vitral/vue';</script> <template>    <StackPanel spacing="0.625rem" style="width: 100%">        <Message severity="secondary" variant="outlined">Drafts are kept for 30 days.</Message>        <Message severity="danger" variant="outlined" title="Invalid token">Sign in again to continue.</Message>        <Message severity="danger" variant="simple">Password must have at least 8 characters.</Message>        <Message severity="success" variant="simple" icon="check">Username is available.</Message>    </StackPanel></template>

API

Lido de packages/vue/src/components/Message/types.ts, então diz o que o componente aceita de fato.

Props

NomeTipoDescrição
severity SeverityO padrão é `'info'`. `danger` e `warn` são anunciados na hora, como alertas; o resto, educadamente.
title stringO título da InfoBar, em negrito antes da mensagem.
icon IconPropSubstitui o ícone da severidade.
hideIcon booleanOculta o ícone.
closable booleanMostra um botão de fechar; fechar oculta a mensagem e emite `close`.
variant MessageVariant`'subtle'` (uma faixa tingida, o padrão), `'outlined'` ou `'simple'` (só texto colorido).
life numberMilissegundos até ela se ocultar sozinha; a contagem pausa enquanto está com hover ou foco.
stackAction booleanSe a ação desce para baixo da mensagem quando a faixa é estreita, como num celular, em vez de espremer o texto numa coluna ao lado. Ligado por padrão; desligado, a ação fica no fim da linha.

Mais pt, dt e unstyled de BaseProps; veja pass-through e modo sem estilo.

Emits

EventoPayloadDescrição
close event: Event—
life-end ——

Slots

NomeProps do slotDescrição
default ——
action —A área de ação da InfoBar: um botão ou um link ao lado da mensagem.
icon ——
closeicon ——