Ir al contenido

Thumbnail

Una vista previa pequeña y cuadrada de una imagen o un archivo. Con onOpen es un botón que abre lo completo; un archivo que no es imagen muestra su tipo y su nombre.

import { Thumbnail, ThumbnailSkeleton } from '@sypnia/ui/react'

En esta página
  1. Adjuntos de un reporte
  2. Skeleton
  3. Cuándo usarlo
  4. Para todos
  5. Props

Adjuntos de un reporte

invoice-1042.pdfprices.csv
The checkout page with the errorThe console with the failing request
Código
import { useState } from 'react';
import { Lightbox, Thumbnail, ThumbnailSkeleton } from '@sypnia/ui/react';

// Pictures open in a Lightbox; a file that is not a picture shows its kind and its name.
const shot = (hue: number) => 'data:image/svg+xml;utf8,' + encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="800"><rect width="1280" height="800" fill="hsl(${hue} 30% 88%)"/><rect x="60" y="60" width="1160" height="80" rx="14" fill="hsl(${hue} 30% 76%)"/><rect x="60" y="180" width="520" height="560" rx="14" fill="hsl(${hue} 30% 80%)"/></svg>`);
const images = [{ src: shot(10), alt: 'The checkout page with the error' }, { src: shot(200), alt: 'The console with the failing request' }];
export default function Attachments() {
  const [at, setAt] = useState<number | null>(null);
  return (
    <div className="sy-stack">
      <div className="sy-row">
        {images.map((img, i) => <Thumbnail key={i} src={img.src} alt={img.alt} onOpen={() => setAt(i)} />)}
        <Thumbnail alt="Invoice 1042" name="invoice-1042.pdf" />
        <Thumbnail alt="Prices" name="prices.csv" />
        <ThumbnailSkeleton />
      </div>
      <div className="sy-row"><Thumbnail size="sm" src={images[0].src} alt={images[0].alt} /><Thumbnail size="lg" src={images[1].src} alt={images[1].alt} /></div>
      <Lightbox label="Attachments of the report" images={images} index={at ?? 0} open={at !== null} onIndex={setAt} onClose={() => setAt(null)} />
    </div>
  );
}

Skeleton

invoice-1042.pdf
Código
import { Thumbnail, ThumbnailSkeleton } from '@sypnia/ui/react';

// A thumbnail and its skeleton.
export default function Skeleton() {
  return (
    <div className="sy-cols sy-cols--stack">
      <span><Thumbnail alt="Invoice" name="invoice-1042.pdf" /></span>
      <span><ThumbnailSkeleton /></span>
    </div>
  );
}

Cuándo usarlo

Úsalo cuando

  • Adjuntos, archivos subidos, las imágenes de un bucket.

No lo uses cuando

  • La imagen principal de una página: usa Image.

Para todos

  • Como botón se llama «Abrir» y lo que muestra la imagen.
  • El Lightbox que abre le devuelve el foco.

Props

ThumbnailTipoPor defecto
altobligatorio string
name

The file name, for files that are not pictures: «invoice-1042.pdf».

string
onOpen (() => void)
size "sm" | "md" | "lg" md
src

The picture. Without it the thumbnail shows the icon of the file's kind.

string
ThumbnailSkeletonTipoPor defecto
size "sm" | "md" | "lg" md
  1. Adjuntos de un reporte
  2. Skeleton
  3. Cuándo usarlo
  4. Para todos
  5. Props

    Busca páginas, secciones y términos