Update shape

This commit is contained in:
yari-dewalt
2025-01-28 08:10:07 -08:00
parent f00507449b
commit d0768cbc37

View File

@@ -18,7 +18,6 @@ export async function requirementBox<T extends SVGGraphicsElement>(
node.labelStyle = labelStyles; node.labelStyle = labelStyles;
const requirementNode = node as unknown as Requirement; const requirementNode = node as unknown as Requirement;
const elementNode = node as unknown as Element; const elementNode = node as unknown as Element;
const config = getConfig().requirement;
const padding = 20; const padding = 20;
const gap = 20; const gap = 20;
const isRequirementNode = 'verifyMethod' in node; const isRequirementNode = 'verifyMethod' in node;
@@ -47,7 +46,7 @@ export async function requirementBox<T extends SVGGraphicsElement>(
shapeSvg, shapeSvg,
requirementNode.name, requirementNode.name,
accumulativeHeight, accumulativeHeight,
node.labelStyle node.labelStyle + '; font-weight: bold;'
); );
accumulativeHeight += nameHeight + gap; accumulativeHeight += nameHeight + gap;
@@ -98,11 +97,8 @@ export async function requirementBox<T extends SVGGraphicsElement>(
); );
} }
const totalWidth = Math.max( const totalWidth = (shapeSvg.node()?.getBBox().width ?? 200) + padding;
(shapeSvg.node()?.getBBox().width ?? 200) + padding, const totalHeight = (shapeSvg.node()?.getBBox().height ?? 200) + padding;
config?.rect_min_width ?? 200
);
const totalHeight = totalWidth;
const x = -totalWidth / 2; const x = -totalWidth / 2;
const y = -totalHeight / 2; const y = -totalHeight / 2;
@@ -151,16 +147,18 @@ export async function requirementBox<T extends SVGGraphicsElement>(
text.attr('transform', `translate(${newTranslateX}, ${newTranslateY + padding})`); text.attr('transform', `translate(${newTranslateX}, ${newTranslateY + padding})`);
}); });
// Insert divider line // Insert divider line if there is body text
const roughLine = rc.line( if (accumulativeHeight > typeHeight + nameHeight + gap) {
x, const roughLine = rc.line(
y + typeHeight + nameHeight + gap, x,
x + totalWidth, y + typeHeight + nameHeight + gap,
y + typeHeight + nameHeight + gap, x + totalWidth,
options y + typeHeight + nameHeight + gap,
); options
const dividerLine = shapeSvg.insert(() => roughLine); );
dividerLine.attr('style', nodeStyles); const dividerLine = shapeSvg.insert(() => roughLine);
dividerLine.attr('style', nodeStyles);
}
updateNodeBounds(node, rect); updateNodeBounds(node, rect);
@@ -201,6 +199,9 @@ async function addText<T extends SVGGraphicsElement>(
const textChild = text.children[0]; const textChild = text.children[0];
for (const child of textChild.children) { for (const child of textChild.children) {
child.textContent = child.textContent.replaceAll('&gt;', '>').replaceAll('&lt;', '<'); child.textContent = child.textContent.replaceAll('&gt;', '>').replaceAll('&lt;', '<');
if (style) {
child.setAttribute('style', style);
}
} }
// Get the bounding box after the text update // Get the bounding box after the text update
bbox = text.getBBox(); bbox = text.getBBox();