Skip to content

Commit bace5fd

Browse files
committed
feat: refactor legend rendering to use BpmnShape for consistent display
1 parent ed9df00 commit bace5fd

1 file changed

Lines changed: 26 additions & 14 deletions

File tree

src/pages/docs/diagrama-bpmn.astro

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,35 @@
22
import BaseLayout from '../../layouts/BaseLayout.astro'
33
import DocsNav from '../../components/DocsNav.astro'
44
import BpmnDiagram from '../../components/BpmnDiagram.astro'
5+
import BpmnShape from '../../components/BpmnShape.astro'
56
import { procesosBpmn, leyendaBpmn } from '../../data/bpmn'
6-
import { GEO } from '../../lib/bpmn-layout'
7+
import { sizeOf, type PlacedNode } from '../../lib/bpmn-layout'
78
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 = {
1317
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+
})
2234
---
2335

2436
<BaseLayout title="Diagramas BPMN">

0 commit comments

Comments
 (0)