mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-12-05 12:04:45 +01:00
MC-1730 Selector for gradients
This commit is contained in:
@@ -1608,7 +1608,7 @@ direction LR
|
|||||||
mermaid.initialize({
|
mermaid.initialize({
|
||||||
handdrawn: false,
|
handdrawn: false,
|
||||||
mergeEdges: true,
|
mergeEdges: true,
|
||||||
layout: 'dagre',
|
layout: 'elk',
|
||||||
flowchart: { titleTopMargin: 10 },
|
flowchart: { titleTopMargin: 10 },
|
||||||
// fontFamily: 'Caveat',
|
// fontFamily: 'Caveat',
|
||||||
fontFamily: 'Kalam',
|
fontFamily: 'Kalam',
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ export const createUserStyles = (
|
|||||||
svgId: string
|
svgId: string
|
||||||
): string => {
|
): string => {
|
||||||
const userCSSstyles = createCssStyles(config, classDefs);
|
const userCSSstyles = createCssStyles(config, classDefs);
|
||||||
const allStyles = getStyles(graphType, userCSSstyles, config.themeVariables);
|
const allStyles = getStyles(graphType, userCSSstyles, config.themeVariables, svgId);
|
||||||
|
|
||||||
// Now turn all of the styles into a (compiled) string that starts with the id
|
// Now turn all of the styles into a (compiled) string that starts with the id
|
||||||
// use the stylis library to compile the css, turn the results into a valid CSS string (serialize(...., stringify))
|
// use the stylis library to compile the css, turn the results into a valid CSS string (serialize(...., stringify))
|
||||||
@@ -534,7 +534,7 @@ function initialize(options: MermaidConfig = {}) {
|
|||||||
|
|
||||||
const config =
|
const config =
|
||||||
typeof options === 'object' ? configApi.setSiteConfig(options) : configApi.getSiteConfig();
|
typeof options === 'object' ? configApi.setSiteConfig(options) : configApi.getSiteConfig();
|
||||||
|
console.log('IPI config', config.themeVariables.useGradient);
|
||||||
setLogLevel(config.logLevel);
|
setLogLevel(config.logLevel);
|
||||||
addDiagrams();
|
addDiagrams();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,11 +47,13 @@ export const render = async (data4Layout: any, svg: any, element: any, positions
|
|||||||
|
|
||||||
const { useGradient, gradientStart, gradientStop } = data4Layout.config.themeVariables;
|
const { useGradient, gradientStart, gradientStop } = data4Layout.config.themeVariables;
|
||||||
|
|
||||||
|
// console.log('IPI data4Layout', svg.attr('id'));
|
||||||
|
|
||||||
if (useGradient) {
|
if (useGradient) {
|
||||||
const gradient = svg.append('linearGradient');
|
const gradient = svg.append('linearGradient');
|
||||||
|
|
||||||
gradient
|
gradient
|
||||||
.attr('id', 'gradient')
|
.attr('id', svg.attr('id') + '-gradient')
|
||||||
.attr('gradientUnits', 'userSpaceOnUse')
|
.attr('gradientUnits', 'userSpaceOnUse')
|
||||||
.attr('spreadMethod', 'pad');
|
.attr('spreadMethod', 'pad');
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ describe('styles', () => {
|
|||||||
|
|
||||||
addStylesForDiagram(diagramType, myTypeGetStylesFunc);
|
addStylesForDiagram(diagramType, myTypeGetStylesFunc);
|
||||||
|
|
||||||
const styles = getStyles(diagramType, '', getConfig().themeVariables);
|
const styles = getStyles(diagramType, '', getConfig().themeVariables, '');
|
||||||
|
|
||||||
await checkValidStylisCSSStyleSheet(styles);
|
await checkValidStylisCSSStyleSheet(styles);
|
||||||
});
|
});
|
||||||
@@ -107,7 +107,8 @@ describe('styles', () => {
|
|||||||
diagramId,
|
diagramId,
|
||||||
'',
|
'',
|
||||||
// @ts-expect-error This will probably be broken until we create a proper Themes type.
|
// @ts-expect-error This will probably be broken until we create a proper Themes type.
|
||||||
themes[themeId].getThemeVariables()
|
themes[themeId].getThemeVariables(),
|
||||||
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
await checkValidStylisCSSStyleSheet(styles);
|
await checkValidStylisCSSStyleSheet(styles);
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ const getStyles = (
|
|||||||
errorTextColor: string;
|
errorTextColor: string;
|
||||||
lineColor: string;
|
lineColor: string;
|
||||||
useGradient: boolean;
|
useGradient: boolean;
|
||||||
} & FlowChartStyleOptions
|
} & FlowChartStyleOptions,
|
||||||
|
svgId: string
|
||||||
) => {
|
) => {
|
||||||
let diagramStyles = '';
|
let diagramStyles = '';
|
||||||
if (type in themes && themes[type as keyof typeof themes]) {
|
if (type in themes && themes[type as keyof typeof themes]) {
|
||||||
@@ -75,18 +76,18 @@ const getStyles = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
[data-look="neo"].node rect, [data-look="neo"].cluster rect, [data-look="neo"].node polygon {
|
[data-look="neo"].node rect, [data-look="neo"].cluster rect, [data-look="neo"].node polygon {
|
||||||
stroke: ${options.useGradient ? 'url(#gradient)' : options.nodeBorder};
|
stroke: ${options.useGradient ? 'url(' + svgId + '-gradient)' : options.nodeBorder};
|
||||||
filter: ${options.dropShadow};
|
filter: ${options.dropShadow};
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-look="neo"].node rect, [data-look="neo"].node circle, [data-look="neo"].node polygon {
|
[data-look="neo"].node rect, [data-look="neo"].node circle, [data-look="neo"].node polygon {
|
||||||
stroke: ${options.useGradient ? 'url(#gradient)' : options.nodeBorder};
|
stroke: ${options.useGradient ? 'url(' + svgId + '-gradient)' : options.nodeBorder};
|
||||||
filter: ${options.dropShadow};
|
filter: ${options.dropShadow};
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-look="neo"].node circle{
|
[data-look="neo"].node circle{
|
||||||
stroke: $(options.nodeBorder);
|
stroke: $(options.nodeBorder);
|
||||||
stroke: ${options.useGradient ? 'url(#gradient)' : options.nodeBorder};
|
stroke: ${options.useGradient ? 'url(' + svgId + '-gradient)' : options.nodeBorder};
|
||||||
|
|
||||||
filter: ${options.dropShadow};
|
filter: ${options.dropShadow};
|
||||||
}
|
}
|
||||||
@@ -98,7 +99,7 @@ const getStyles = (
|
|||||||
|
|
||||||
[data-look="neo"].statediagram-cluster rect {
|
[data-look="neo"].statediagram-cluster rect {
|
||||||
fill: ${options.compositeTitleBackground};
|
fill: ${options.compositeTitleBackground};
|
||||||
stroke: ${options.useGradient ? 'url(#gradient)' : options.nodeBorder};
|
stroke: ${options.useGradient ? 'url(' + svgId + '-gradient)' : options.nodeBorder};
|
||||||
//stroke: none;
|
//stroke: none;
|
||||||
stroke-width: 1px;
|
stroke-width: 1px;
|
||||||
rx: 3;
|
rx: 3;
|
||||||
|
|||||||
Reference in New Issue
Block a user