mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
updated icon and image shape for htmlLabels center alignment
This commit is contained in:
parent
90b6df24a1
commit
6d916fb66f
@ -59,7 +59,7 @@ const getStyles = (options: FlowChartStyleOptions) =>
|
||||
stroke: ${options.nodeBorder};
|
||||
stroke-width: 1px;
|
||||
}
|
||||
.rough-node .label text , .node .label text {
|
||||
.rough-node .label text , .node .label text, .image-shape .label, .icon-shape .label {
|
||||
text-anchor: middle;
|
||||
}
|
||||
// .flowchart-label .text-outer-tspan {
|
||||
@ -75,7 +75,7 @@ const getStyles = (options: FlowChartStyleOptions) =>
|
||||
stroke-width: 1px;
|
||||
}
|
||||
|
||||
.rough-node .label,.node .label {
|
||||
.rough-node .label,.node .label, .image-shape .label, .icon-shape .label {
|
||||
text-align: center;
|
||||
}
|
||||
.node.clickable {
|
||||
@ -164,20 +164,7 @@ const getStyles = (options: FlowChartStyleOptions) =>
|
||||
stroke-width: 0;
|
||||
}
|
||||
|
||||
.icon-shape {
|
||||
background-color: ${options.edgeLabelBackground};
|
||||
p {
|
||||
background-color: ${options.edgeLabelBackground};
|
||||
padding: 2px;
|
||||
}
|
||||
rect {
|
||||
opacity: 0.5;
|
||||
background-color: ${options.edgeLabelBackground};
|
||||
fill: ${options.edgeLabelBackground};
|
||||
}
|
||||
text-align: center;
|
||||
}
|
||||
.image-shape {
|
||||
.icon-shape, .image-shape {
|
||||
background-color: ${options.edgeLabelBackground};
|
||||
p {
|
||||
background-color: ${options.edgeLabelBackground};
|
||||
|
@ -141,8 +141,8 @@ function createFormattedText(
|
||||
const bbox = textElement.node().getBBox();
|
||||
const padding = 2;
|
||||
bkg
|
||||
.attr('x', -padding)
|
||||
.attr('y', -padding)
|
||||
.attr('x', bbox.x - padding)
|
||||
.attr('y', bbox.y - padding)
|
||||
.attr('width', bbox.width + 2 * padding)
|
||||
.attr('height', bbox.height + 2 * padding);
|
||||
|
||||
|
@ -75,7 +75,7 @@ export const icon = async (
|
||||
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2},${topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height})`
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height})`
|
||||
);
|
||||
|
||||
iconShape.attr(
|
||||
|
@ -70,7 +70,7 @@ export const iconCircle = async (
|
||||
iconElem.selectAll('path').attr('fill', stylesMap.get('stroke') || nodeBorder);
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2},${topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height})`
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height})`
|
||||
);
|
||||
|
||||
iconShape.attr(
|
||||
|
@ -80,7 +80,7 @@ export const iconRounded = async (
|
||||
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2},${topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height})`
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height})`
|
||||
);
|
||||
|
||||
iconShape.attr(
|
||||
|
@ -79,7 +79,7 @@ export const iconSquare = async (
|
||||
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2},${topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height})`
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${topLabel ? -outerHeight / 2 : outerHeight / 2 - bbox.height})`
|
||||
);
|
||||
|
||||
iconShape.attr(
|
||||
|
@ -92,7 +92,7 @@ export const imageSquare = async (
|
||||
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2},${topLabel ? -imageHeight / 2 - bbox.height / 2 - labelPadding / 2 : imageHeight / 2 - bbox.height / 2 + labelPadding / 2})`
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))},${topLabel ? -imageHeight / 2 - bbox.height / 2 - labelPadding / 2 : imageHeight / 2 - bbox.height / 2 + labelPadding / 2})`
|
||||
);
|
||||
|
||||
iconShape.attr(
|
||||
|
Loading…
x
Reference in New Issue
Block a user