mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
Basic fix for handdrawn subgraph styling
This commit is contained in:
parent
99ee235e75
commit
09afb077f0
@ -19,7 +19,7 @@ const rect = async (parent, node) => {
|
||||
const { themeVariables, handDrawnSeed } = siteConfig;
|
||||
const { clusterBkg, clusterBorder } = themeVariables;
|
||||
|
||||
const { labelStyles, nodeStyles } = styles2String(node);
|
||||
const { labelStyles, nodeStyles, borderStyles, backgroundStyles } = styles2String(node);
|
||||
|
||||
// Add outer g element
|
||||
const shapeSvg = parent
|
||||
@ -79,6 +79,9 @@ const rect = async (parent, node) => {
|
||||
log.debug('Rough node insert CXC', roughNode);
|
||||
return roughNode;
|
||||
}, ':first-child');
|
||||
// Should we affect the options instead of doing this?
|
||||
rect.select('path:nth-child(2)').attr('style', borderStyles.join(';'));
|
||||
rect.select('path').attr('style', backgroundStyles.join(';').replace('fill', 'stroke'));
|
||||
} else {
|
||||
// add the rect
|
||||
rect = shapeSvg.insert('rect', ':first-child');
|
||||
|
@ -37,6 +37,8 @@ export const styles2String = (node: Node) => {
|
||||
const { stylesArray } = compileStyles(node);
|
||||
const labelStyles: string[] = [];
|
||||
const nodeStyles: string[] = [];
|
||||
const borderStyles: string[] = [];
|
||||
const backgroundStyles: string[] = [];
|
||||
|
||||
stylesArray.forEach((style) => {
|
||||
const key = style[0];
|
||||
@ -63,10 +65,22 @@ export const styles2String = (node: Node) => {
|
||||
labelStyles.push(style.join(':') + ' !important');
|
||||
} else {
|
||||
nodeStyles.push(style.join(':') + ' !important');
|
||||
if (key === 'stroke' || key === 'stroke-width') {
|
||||
borderStyles.push(style.join(':') + ' !important');
|
||||
}
|
||||
if (key === 'fill') {
|
||||
backgroundStyles.push(style.join(':') + ' !important');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return { labelStyles: labelStyles.join(';'), nodeStyles: nodeStyles.join(';') };
|
||||
return {
|
||||
labelStyles: labelStyles.join(';'),
|
||||
nodeStyles: nodeStyles.join(';'),
|
||||
stylesArray,
|
||||
borderStyles,
|
||||
backgroundStyles,
|
||||
};
|
||||
};
|
||||
|
||||
// Striped fill like start or fork nodes in state diagrams
|
||||
|
Loading…
x
Reference in New Issue
Block a user