Ir al contenido

Figure

Una imagen o un diagrama con su pie, y lo mismo contado en palabras para quien no puede verlo. El gemelo React del Figure de la documentación: la misma caja.

import { Figure, FigureSkeleton } from '@sypnia/ui/react'

En esta página
  1. Un diagrama
  2. Una imagen
  3. Skeleton
  4. Cuándo usarlo
  5. Para todos
  6. Props

Un diagrama

ShopDatabaseKitchen
Figura. How an order reaches the kitchen.
Este diagrama en palabras
The customer places the order in the shop. The shop saves it in the database, which tells the kitchen screen at once.
Código
import { Figure } from '@sypnia/ui/react';

// A diagram with its caption, and the same thing in words behind «This diagram in words».
export default function Flow() {
  return (
    <Figure caption="How an order reaches the kitchen." words="The customer places the order in the shop. The shop saves it in the database, which tells the kitchen screen at once.">
      <svg className="sy-dg" viewBox="0 0 640 120" role="img" aria-label="Shop, database and kitchen, connected left to right">
        <rect className="dg-box" x="10" y="30" width="150" height="60" rx="10" /><text x="85" y="66" textAnchor="middle">Shop</text>
        <path className="dg-wire" d="M160 60 H240" />
        <rect className="dg-box" x="240" y="30" width="160" height="60" rx="10" /><text x="320" y="66" textAnchor="middle">Database</text>
        <path className="dg-wire" d="M400 60 H480" />
        <rect className="dg-box dg-box--main" x="480" y="30" width="150" height="60" rx="10" /><text x="555" y="66" textAnchor="middle">Kitchen</text>
      </svg>
    </Figure>
  );
}

Una imagen

The orders page: a header, a list on the left and a chart on the right
Figura. The orders page after the change.
Código
import { Figure, FigureSkeleton, Image } from '@sypnia/ui/react';

// A picture as a figure, and the figure's skeleton.
const shot = 'data:image/svg+xml;utf8,' + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="675"><rect width="1200" height="675" fill="hsl(210 25% 90%)"/><rect x="40" y="40" width="1120" height="70" rx="12" fill="hsl(210 25% 80%)"/><rect x="40" y="140" width="540" height="495" rx="12" fill="hsl(210 25% 84%)"/><rect x="620" y="140" width="540" height="230" rx="12" fill="hsl(210 25% 84%)"/></svg>');
export default function Picture() {
  return (
    <div className="sy-cols sy-cols--stack">
      <Figure caption="The orders page after the change."><Image src={shot} alt="The orders page: a header, a list on the left and a chart on the right" /></Figure>
      <FigureSkeleton />
    </div>
  );
}

Skeleton

Figura. The orders page.
Código
import { Figure, FigureSkeleton, ImageSkeleton } from '@sypnia/ui/react';

// A figure and its skeleton: the picture and the caption.
export default function Skeleton() {
  return (
    <div className="sy-cols sy-cols--stack">
      <Figure caption="The orders page."><ImageSkeleton /></Figure>
      <FigureSkeleton />
    </div>
  );
}

Cuándo usarlo

Úsalo cuando

  • Diagramas y capturas que explican algo.
  • words siempre: los lectores de pantalla y los agentes lo leen.

No lo uses cuando

  • Decoración: usa Image con un alt vacío.

Para todos

  • La figura se nombra con su pie; las palabras están tras un desplegable que cualquiera puede abrir.

Props

FigureTipoPor defecto
caption ReactNode
label

A name for the figure when the caption is not plain text.

string
words

The figure in words, behind «This diagram in words». Screen readers and agents always get it.

ReactNode
FigureSkeletonTipoPor defecto
caption boolean true
ratio string 16 / 9
  1. Un diagrama
  2. Una imagen
  3. Skeleton
  4. Cuándo usarlo
  5. Para todos
  6. Props

    Busca páginas, secciones y términos