mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 06:49:47 +02:00
chore: resolve PR comments
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
@@ -36,43 +36,39 @@ export async function textHelper<T extends SVGGraphicsElement>(
|
||||
|
||||
annotationGroup = shapeSvg.insert('g').attr('class', 'annotation-group text');
|
||||
if (node.annotations.length > 0) {
|
||||
const annotation = node.annotations[0];
|
||||
await addText(annotationGroup, { text: `«${annotation}»` } as unknown as ClassMember, 0);
|
||||
await addText(annotationGroup, { text: `` } as unknown as ClassMember, 0);
|
||||
|
||||
const annotationGroupBBox = annotationGroup.node()!.getBBox();
|
||||
annotationGroupHeight = annotationGroupBBox.height;
|
||||
}
|
||||
|
||||
labelGroup = shapeSvg.insert('g').attr('class', 'label-group text');
|
||||
await addText(labelGroup, node, 0, ['font-weight: bolder']);
|
||||
|
||||
// Determine styling based on annotations
|
||||
let labelStyles = ['font-weight: bolder']; // Default bold style
|
||||
let labelClass = 'classTitle';
|
||||
|
||||
let labelClass = '';
|
||||
if (node.annotations && node.annotations.length > 0) {
|
||||
const annotation = node.annotations[0].toLowerCase();
|
||||
switch (annotation) {
|
||||
case 'abstract':
|
||||
labelClass = 'classTitle abstract';
|
||||
labelClass = 'abstract';
|
||||
labelStyles = [];
|
||||
break;
|
||||
case 'enumeration':
|
||||
labelClass = 'classTitle enumeration';
|
||||
labelClass = 'enumeration';
|
||||
labelStyles = [];
|
||||
break;
|
||||
case 'interface':
|
||||
labelClass = 'classTitle interface';
|
||||
labelClass = 'interface';
|
||||
labelStyles = [];
|
||||
break;
|
||||
default:
|
||||
labelClass = 'classTitle';
|
||||
labelStyles = ['font-weight: bolder'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply the CSS class to the label group
|
||||
labelGroup.attr('class', `label-group text ${labelClass}`);
|
||||
labelGroup.attr('class', `label-group text classTitle ${labelClass}`);
|
||||
|
||||
await addText(labelGroup, node, 0, labelStyles);
|
||||
const labelGroupBBox = labelGroup.node()!.getBBox();
|
||||
@@ -101,7 +97,7 @@ export async function textHelper<T extends SVGGraphicsElement>(
|
||||
// Center annotation
|
||||
if (annotationGroup !== null) {
|
||||
const annotationGroupBBox = annotationGroup.node()!.getBBox();
|
||||
annotationGroup.attr('transform', `translate(${-annotationGroupBBox.width / 2})`);
|
||||
annotationGroup.attr('transform', `translate(${-annotationGroupBBox.width / 2}, 0)`);
|
||||
}
|
||||
|
||||
// Adjust label
|
||||
|
@@ -149,14 +149,16 @@ g.classGroup line {
|
||||
stroke-width: 1;
|
||||
}
|
||||
|
||||
.classTitle.abstract {
|
||||
.classTitle.abstract {
|
||||
font-style: italic;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.classTitle.enumeration {
|
||||
text-decoration: underline;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.classTitle.interface {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
Reference in New Issue
Block a user