Ir al contenido

SequenceDiagram

Quién habla con quién, en orden: el navegador, la API, la base de datos y de vuelta. Cada participante tiene una línea hacia abajo; cada mensaje es una flecha numerada.

import { SequenceDiagram, DiagramSkeleton } from '@sypnia/ui/react'

En esta página
  1. Iniciar sesión con un código
  2. Skeleton
  3. Cuándo usarlo
  4. Para todos
  5. Props

Iniciar sesión con un código

BrowserAPIDatabaseMail1 POST /login2 save a code3 send the code4 202 check your mail5 POST /verify6 read the code7 401 code expired
Este diagrama en palabras
  1. Browser a API: POST /login
  2. API a Database: save a code
  3. API a Mail: send the code
  4. API responde a Browser: 202 check your mail
  5. Browser a API: POST /verify
  6. API a Database: read the code
  7. API responde a Browser: 401 code expired (falló)
Código
import { SequenceDiagram } from '@sypnia/ui/react';

// Who talks to whom, in order. Answers are dashed; what failed is in the failure colour and said in words.
export default function SignIn() {
  return (
    <SequenceDiagram label="Signing in with a code" participants={[
      { id: 'b', label: 'Browser' }, { id: 'api', label: 'API' }, { id: 'db', label: 'Database' }, { id: 'mail', label: 'Mail' },
    ]} messages={[
      { from: 'b', to: 'api', label: 'POST /login' },
      { from: 'api', to: 'db', label: 'save a code' },
      { from: 'api', to: 'mail', label: 'send the code' },
      { from: 'api', to: 'b', label: '202 check your mail', reply: true },
      { from: 'b', to: 'api', label: 'POST /verify' },
      { from: 'api', to: 'db', label: 'read the code' },
      { from: 'api', to: 'b', label: '401 code expired', reply: true, fail: true },
    ]} />
  );
}

Skeleton

Código
import { DiagramSkeleton } from '@sypnia/ui/react';

// A diagram while it loads: its stage at the height it will have.
export default function Skeleton() {
  return <DiagramSkeleton height={260} />;
}

Cuándo usarlo

Úsalo cuando

  • Explicar un inicio de sesión, un pago, un webhook.
  • Mostrar dónde falló una conversación entre servicios.

No lo uses cuando

  • Más de cinco participantes: divídelo en dos diagramas.

Para todos

  • Se cuenta en palabras como una lista numerada: quién envía qué a quién, y qué respuestas fallaron.

Props

SequenceDiagramTipoPor defecto
labelobligatorio string
messagesobligatorio SequenceMessage[]
participantsobligatorio

In order, left to right: { id, label }.

{ id: string; label: string; machine?: boolean | undefined; }[]
DiagramSkeletonTipoPor defecto
height number 220
  1. Iniciar sesión con un código
  2. Skeleton
  3. Cuándo usarlo
  4. Para todos
  5. Props

    Busca páginas, secciones y términos