Vitral 0.2.18
Layout

Masonry

Itens de alturas diferentes em colunas sem buracos sob os curtos, dispostos na ordem de leitura, para que teclado e leitor de tela vão da esquerda para a direita como o olho.

Importação

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

Cards

Cada item vai para a coluna mais curta até ali. Redimensione a janela: há tantas colunas quantas cabem em `min-column-width`, e um item que cresce (abra um) empurra os de baixo.

Groceries

Rice, beans, coffee, lemons.

Ideas for the talk

Open with the stained-glass metaphor. Show tokens before components. End on the theme designer, live, with the audience picking the primary colour.

Call Ana

About the release.

Reading

Chapters 4 to 6, and the notes on accessibility of drag and drop — the keyboard part especially.

Gym

Tuesday and Thursday.

Trip

Book the train to Lisboa. Check the museum hours. Ask Bruno about the restaurant near the river he mentioned.

Plants

Water on Sundays.

Budget

Rent, internet, the course, and something put aside every month however small.

<script setup lang="ts">import { Card, Masonry } from '@vitral/vue';import { ref } from 'vue'; const notes = [    { title: 'Groceries', text: 'Rice, beans, coffee, lemons.' },    { title: 'Ideas for the talk', text: 'Open with the stained-glass metaphor. Show tokens before components. End on the theme designer, live, with the audience picking the primary colour.' },    { title: 'Call Ana', text: 'About the release.' },    { title: 'Reading', text: 'Chapters 4 to 6, and the notes on accessibility of drag and drop — the keyboard part especially.' },    { title: 'Gym', text: 'Tuesday and Thursday.' },    { title: 'Trip', text: 'Book the train to Lisboa. Check the museum hours. Ask Bruno about the restaurant near the river he mentioned.' },    { title: 'Plants', text: 'Water on Sundays.' },    { title: 'Budget', text: 'Rent, internet, the course, and something put aside every month however small.' }];const open = ref<number | null>(null);</script> <template>    <Masonry min-column-width="12rem">        <Card v-for="(note, i) in notes" :key="note.title">            <template #title>{{ note.title }}</template>            <template #default>                <p style="margin: 0">{{ note.text }}</p>                <p v-if="open === i" style="margin: 0.5rem 0 0">More lines, shown on demand, push the cards below down.</p>                <button type="button" class="vt-button vt-button-text vt-button-sm" style="margin-top: 0.5rem" @click="open = open === i ? null : i">{{ open === i ? 'Less' : 'More' }}</button>            </template>        </Card>    </Masonry></template>

Um número fixo de colunas

`columns` fixa a quantidade, e `gap` o espaço entre elas. As imagens são medidas de novo conforme carregam.

Photo 1Photo 2Photo 3Photo 4Photo 5Photo 6Photo 7Photo 8Photo 9
<script setup lang="ts">import { Masonry } from '@vitral/vue'; // Blocks of colour with the proportions of photographs, drawn inline.const shapes = [    [4, 5, '#fca5a5'],    [4, 3, '#fdba74'],    [1, 1, '#fcd34d'],    [3, 4, '#86efac'],    [16, 9, '#67e8f9'],    [2, 3, '#93c5fd'],    [4, 3, '#c4b5fd'],    [1, 1, '#f9a8d4'],    [3, 4, '#a5b4fc']] as const;const src = (w: number, h: number, fill: string) =>    'data:image/svg+xml;utf8,' + encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${w * 100} ${h * 100}"><rect width="100%" height="100%" fill="${fill}"/></svg>`);</script> <template>    <Masonry :columns="3" gap="0.5rem">        <img v-for="([w, h, fill], i) in shapes" :key="i" :src="src(w, h, fill)" :alt="`Photo ${i + 1}`" style="display: block; width: 100%; border-radius: 0.5rem" />    </Masonry></template>

API

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

Props

NomeTipoDescrição
columns numberUm número fixo de colunas; caso contrário, quantas couberem em `minColumnWidth`.
minColumnWidth stringQualquer medida CSS; a do tema (`15rem`) caso contrário.
gap stringQualquer medida CSS; a do tema (`1rem`) caso contrário.

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

Slots

NomeProps do slotDescrição
default —Os itens, um elemento cada, na ordem de leitura.