|
2 | 2 | import BaseLayout from '../../layouts/BaseLayout.astro' |
3 | 3 | import DocsNav from '../../components/DocsNav.astro' |
4 | 4 | import BpmnDiagram from '../../components/BpmnDiagram.astro' |
| 5 | +import BpmnShape from '../../components/BpmnShape.astro' |
5 | 6 | import { procesosBpmn, leyendaBpmn } from '../../data/bpmn' |
6 | | -import { GEO } from '../../lib/bpmn-layout' |
| 7 | +import { sizeOf, type PlacedNode } from '../../lib/bpmn-layout' |
7 | 8 |
|
8 | | -// La leyenda reusa el mismo renderer: cada símbolo es un proceso de un solo |
9 | | -// nodo, así que si cambia el dibujo de una figura, la leyenda cambia con ella. |
10 | | -const muestras = leyendaBpmn.map((item) => ({ |
11 | | - ...item, |
12 | | - proceso: { |
| 9 | +// La leyenda monta la misma figura que el diagrama (BpmnShape) en un lienzo |
| 10 | +// ajustado a su tamaño: si cambia el dibujo de un símbolo, cambia en los dos |
| 11 | +// sitios. Alto de muestra fijo para que la fila quede pareja. |
| 12 | +const ALTO_MUESTRA = 30 |
| 13 | +const muestras = leyendaBpmn.map((item) => { |
| 14 | + const { w, h } = sizeOf(item.type) |
| 15 | + const pad = 3 |
| 16 | + const node: PlacedNode = { |
13 | 17 | id: `leyenda-${item.type}`, |
14 | | - titulo: item.label, |
15 | | - desc: '', |
16 | | - origen: '', |
17 | | - lanes: [{ id: 'l', label: '' }], |
18 | | - nodes: [{ id: 'n', type: item.type, label: '', lane: 'l', col: 0 }], |
19 | | - flows: [], |
20 | | - }, |
21 | | -})) |
| 18 | + type: item.type, |
| 19 | + label: '', |
| 20 | + lane: 'l', |
| 21 | + col: 0, |
| 22 | + row: 0, |
| 23 | + cx: w / 2 + pad, |
| 24 | + cy: h / 2 + pad, |
| 25 | + w, |
| 26 | + h, |
| 27 | + lines: [], |
| 28 | + outside: false, |
| 29 | + } |
| 30 | + const vbW = w + pad * 2 |
| 31 | + const vbH = h + pad * 2 |
| 32 | + return { ...item, node, vbW, vbH, ancho: Math.round((vbW * ALTO_MUESTRA) / vbH) } |
| 33 | +}) |
22 | 34 | --- |
23 | 35 |
|
24 | 36 | <BaseLayout title="Diagramas BPMN"> |
|
0 commit comments