mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-17 19:24:10 +01: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');
|
annotationGroup = shapeSvg.insert('g').attr('class', 'annotation-group text');
|
||||||
if (node.annotations.length > 0) {
|
if (node.annotations.length > 0) {
|
||||||
const annotation = node.annotations[0];
|
await addText(annotationGroup, { text: `` } as unknown as ClassMember, 0);
|
||||||
await addText(annotationGroup, { text: `«${annotation}»` } as unknown as ClassMember, 0);
|
|
||||||
|
|
||||||
const annotationGroupBBox = annotationGroup.node()!.getBBox();
|
const annotationGroupBBox = annotationGroup.node()!.getBBox();
|
||||||
annotationGroupHeight = annotationGroupBBox.height;
|
annotationGroupHeight = annotationGroupBBox.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
labelGroup = shapeSvg.insert('g').attr('class', 'label-group text');
|
labelGroup = shapeSvg.insert('g').attr('class', 'label-group text');
|
||||||
await addText(labelGroup, node, 0, ['font-weight: bolder']);
|
|
||||||
// Determine styling based on annotations
|
// Determine styling based on annotations
|
||||||
let labelStyles = ['font-weight: bolder']; // Default bold style
|
let labelStyles = ['font-weight: bolder']; // Default bold style
|
||||||
let labelClass = 'classTitle';
|
let labelClass = '';
|
||||||
|
|
||||||
if (node.annotations && node.annotations.length > 0) {
|
if (node.annotations && node.annotations.length > 0) {
|
||||||
const annotation = node.annotations[0].toLowerCase();
|
const annotation = node.annotations[0].toLowerCase();
|
||||||
switch (annotation) {
|
switch (annotation) {
|
||||||
case 'abstract':
|
case 'abstract':
|
||||||
labelClass = 'classTitle abstract';
|
labelClass = 'abstract';
|
||||||
labelStyles = [];
|
labelStyles = [];
|
||||||
break;
|
break;
|
||||||
case 'enumeration':
|
case 'enumeration':
|
||||||
labelClass = 'classTitle enumeration';
|
labelClass = 'enumeration';
|
||||||
labelStyles = [];
|
labelStyles = [];
|
||||||
break;
|
break;
|
||||||
case 'interface':
|
case 'interface':
|
||||||
labelClass = 'classTitle interface';
|
labelClass = 'interface';
|
||||||
labelStyles = [];
|
labelStyles = [];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
labelClass = 'classTitle';
|
|
||||||
labelStyles = ['font-weight: bolder'];
|
labelStyles = ['font-weight: bolder'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the CSS class to the label group
|
// 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);
|
await addText(labelGroup, node, 0, labelStyles);
|
||||||
const labelGroupBBox = labelGroup.node()!.getBBox();
|
const labelGroupBBox = labelGroup.node()!.getBBox();
|
||||||
@@ -101,7 +97,7 @@ export async function textHelper<T extends SVGGraphicsElement>(
|
|||||||
// Center annotation
|
// Center annotation
|
||||||
if (annotationGroup !== null) {
|
if (annotationGroup !== null) {
|
||||||
const annotationGroupBBox = annotationGroup.node()!.getBBox();
|
const annotationGroupBBox = annotationGroup.node()!.getBBox();
|
||||||
annotationGroup.attr('transform', `translate(${-annotationGroupBBox.width / 2})`);
|
annotationGroup.attr('transform', `translate(${-annotationGroupBBox.width / 2}, 0)`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust label
|
// Adjust label
|
||||||
|
|||||||
@@ -149,14 +149,16 @@ g.classGroup line {
|
|||||||
stroke-width: 1;
|
stroke-width: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.classTitle.abstract {
|
.classTitle.abstract {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.classTitle.enumeration {
|
.classTitle.enumeration {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.classTitle.interface {
|
.classTitle.interface {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user