From c3838305b360ecafc56aeedf2ab0dffeaf6bf901 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 27 Sep 2024 13:44:44 +0200 Subject: [PATCH] Lean-left --- .../rendering-elements/shapes/leanLeft.ts | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts index c1e897336..a15269e61 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts @@ -8,12 +8,27 @@ import { insertPolygonShape } from './insertPolygonShape.js'; export const lean_left = async (parent: SVGAElement, node: Node): Promise => { const { labelStyles, nodeStyles } = styles2String(node); node.labelStyle = labelStyles; - const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node)); const nodePadding = node.padding ?? 0; - const labelPaddingX = node.look === 'neo' ? nodePadding * 3 : nodePadding; const labelPaddingY = node.look === 'neo' ? nodePadding * 1.5 : nodePadding; - const w = Math.max(bbox.width + (labelPaddingY ?? 0), node?.width ?? 0); - const h = Math.max(bbox.height + (labelPaddingX ?? 0), node?.height ?? 0); + + if (node.width || node.height) { + node.width = node?.width ?? 0; + if (node.width < 50) { + node.width = 50; + } + + node.height = node?.height ?? 0; + if (node.height < 50) { + node.height = 50; + } + const _dx = (3 * node.height) / 6; + node.height = node.height - labelPaddingY; + node.width = node.width - 2 * _dx; + } + + const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node)); + const h = Math.max(bbox.height, node?.height ?? 0) + labelPaddingY; + const w = Math.max(bbox.width, node?.width ?? 0); const points = [ { x: 0, y: 0 }, { x: w + (3 * h) / 6, y: 0 },