From 4d2ffc46d0dc3f1de87948ffb72af0a2ecc3b3ec Mon Sep 17 00:00:00 2001 From: saurabhg772244 Date: Mon, 23 Sep 2024 16:46:44 +0530 Subject: [PATCH] updated padding for curley brace shape --- .../rendering-elements/shapes/curlyBraceLeft.ts | 8 +++++--- .../rendering-elements/shapes/curlyBraceRight.ts | 8 +++++--- .../rendering-elements/shapes/curlyBraces.ts | 10 ++++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/curlyBraceLeft.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/curlyBraceLeft.ts index 9b98c9aec..f08d99c93 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/curlyBraceLeft.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/curlyBraceLeft.ts @@ -38,8 +38,10 @@ export const curlyBraceLeft = async (parent: SVGAElement, node: Node) => { const { labelStyles, nodeStyles } = styles2String(node); node.labelStyle = labelStyles; const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node)); - const w = bbox.width + (node.padding ?? 0); - const h = bbox.height + (node.padding ?? 0); + const paddingX = node.look === 'neo' ? (node.padding ?? 0) * 2 : (node.padding ?? 0); + const paddingY = node.look === 'neo' ? (node.padding ?? 0) * 1 : (node.padding ?? 0); + const w = Math.max(bbox.width + paddingX, node.width ?? 0); + const h = Math.max(bbox.height + paddingY, node.height ?? 0); const radius = Math.max(5, h * 0.1); const { cssStyles } = node; @@ -96,7 +98,7 @@ export const curlyBraceLeft = async (parent: SVGAElement, node: Node) => { label.attr( 'transform', - `translate(${-w / 2 + radius - (bbox.x - (bbox.left ?? 0))},${-h / 2 + (node.padding ?? 0) / 2 - (bbox.y - (bbox.top ?? 0))})` + `translate(${-w / 2 + radius - (bbox.x - (bbox.left ?? 0))},${-h / 2 + paddingY / 2 - (bbox.y - (bbox.top ?? 0))})` ); updateNodeBounds(node, curlyBraceLeftShape); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/curlyBraceRight.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/curlyBraceRight.ts index 9a051e273..48eadbbd5 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/curlyBraceRight.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/curlyBraceRight.ts @@ -38,8 +38,10 @@ export const curlyBraceRight = async (parent: SVGAElement, node: Node) => { const { labelStyles, nodeStyles } = styles2String(node); node.labelStyle = labelStyles; const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node)); - const w = bbox.width + (node.padding ?? 0); - const h = bbox.height + (node.padding ?? 0); + const paddingX = node.look === 'neo' ? (node.padding ?? 0) * 2 : (node.padding ?? 0); + const paddingY = node.look === 'neo' ? (node.padding ?? 0) * 1 : (node.padding ?? 0); + const w = Math.max(bbox.width + paddingX, node.width ?? 0); + const h = Math.max(bbox.height + paddingY, node.height ?? 0); const radius = Math.max(5, h * 0.1); const { cssStyles } = node; @@ -96,7 +98,7 @@ export const curlyBraceRight = async (parent: SVGAElement, node: Node) => { label.attr( 'transform', - `translate(${-w / 2 + (node.padding ?? 0) / 2 - (bbox.x - (bbox.left ?? 0))},${-h / 2 + (node.padding ?? 0) / 2 - (bbox.y - (bbox.top ?? 0))})` + `translate(${-w / 2 + paddingX / 2 - (bbox.x - (bbox.left ?? 0))},${-h / 2 + paddingY / 2 - (bbox.y - (bbox.top ?? 0))})` ); updateNodeBounds(node, curlyBraceRightShape); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/curlyBraces.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/curlyBraces.ts index 9512c96d2..bf667e3c5 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/curlyBraces.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/curlyBraces.ts @@ -38,8 +38,10 @@ export const curlyBraces = async (parent: SVGAElement, node: Node) => { const { labelStyles, nodeStyles } = styles2String(node); node.labelStyle = labelStyles; const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node)); - const w = bbox.width + (node.padding ?? 0); - const h = bbox.height + (node.padding ?? 0); + const paddingX = node.look === 'neo' ? (node.padding ?? 0) * 2 : (node.padding ?? 0); + const paddingY = node.look === 'neo' ? (node.padding ?? 0) * 1 : (node.padding ?? 0); + const w = Math.max(bbox.width + paddingX, node.width ?? 0); + const h = Math.max(bbox.height + paddingY, node.height ?? 0); const radius = Math.max(5, h * 0.1); const { cssStyles } = node; @@ -83,7 +85,7 @@ export const curlyBraces = async (parent: SVGAElement, node: Node) => { // @ts-ignore - rough is not typed const rc = rough.svg(shapeSvg); - const options = userNodeOverrides(node, { fill: 'none' }); + const options = userNodeOverrides(node, { fill: 'transparent' }); if (node.look !== 'handDrawn') { options.roughness = 0; @@ -115,7 +117,7 @@ export const curlyBraces = async (parent: SVGAElement, node: Node) => { label.attr( 'transform', - `translate(${-w / 2 + (node.padding ?? 0) / 2 - (bbox.x - (bbox.left ?? 0))},${-h / 2 + (node.padding ?? 0) / 2 - (bbox.y - (bbox.top ?? 0))})` + `translate(${-w / 2 + paddingX / 2 - (bbox.x - (bbox.left ?? 0))},${-h / 2 + paddingY / 2 - (bbox.y - (bbox.top ?? 0))})` ); updateNodeBounds(node, curlyBracesShape);