Skip to content

Commit

Permalink
Merge pull request #29 from Mermaid-Chart/redux-theme
Browse files Browse the repository at this point in the history
Updated html-label alignment for shapes
  • Loading branch information
ashishjain0512 authored Jan 24, 2025
2 parents 4911b63 + d52e3d1 commit bf39ae7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,10 @@ export async function curlyBraceLeft<T extends SVGGraphicsElement>(

curlyBraceLeftShape.attr('transform', `translate(${radius}, 0)`);

label.attr('transform', `translate(${-bbox.width / 2}, ${-bbox.height / 2})`);
// label.attr(
// 'transform',
// `translate(${-w / 2 + radius - (bbox.x - (bbox.left ?? 0))},${-paddingY / 2 - (bbox.y - (bbox.top ?? 0))})`
// );
label.attr(
'transform',
`translate(${-w / 2 + (paddingX ?? 0) - (bbox.x - (bbox.left ?? 0))}, ${-bbox.height / 2})`
);

updateNodeBounds(node, curlyBraceLeftShape);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,10 @@ export async function curlyBraceRight<T extends SVGGraphicsElement>(

curlyBraceRightShape.attr('transform', `translate(${-radius}, 0)`);

label.attr('transform', `translate(${-bbox.width / 2}, ${-bbox.height / 2})`);

// label.attr(
// 'transform',
// `translate(${-w / 2 + labelPaddingX / 2 - (bbox.x - (bbox.left ?? 0))},${-(labelPaddingY / 2) - (bbox.y - (bbox.top ?? 0))})`
// );
label.attr(
'transform',
`translate(${-w / 2 + (labelPaddingX ?? 0) - (bbox.x - (bbox.left ?? 0))}, ${-bbox.height / 2})`
);

updateNodeBounds(node, curlyBraceRightShape);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ export async function curlyBraces<T extends SVGGraphicsElement>(

curlyBracesShape.attr('transform', `translate(${radius - radius / 4}, 0)`);

label.attr('transform', `translate(${-bbox.width / 2}, ${-bbox.height / 2})`);
label.attr(
'transform',
`translate(${-w / 2 + (labelPaddingX ?? 0) - (bbox.x - (bbox.left ?? 0))}, ${-bbox.height / 2})`
);
updateNodeBounds(node, curlyBracesShape);

node.intersect = function (point) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export async function dividedRectangle<T extends SVGGraphicsElement>(
// place the label in the center of the lower half of the divided rectangle
label.attr(
'transform',
`translate(${-bbox.width / 2}, ${-bbox.height / 2 - rectOffset / 2 + rectOffset})`
`translate(${-w / 2 + (paddingX ?? 0) - (bbox.x - (bbox.left ?? 0))}, ${-bbox.height / 2 - rectOffset / 2 + rectOffset})`
);

updateNodeBounds(node, polygon);
Expand Down

0 comments on commit bf39ae7

Please sign in to comment.