From 38eed7c9880c6d4081155608942d6c9dfab6b783 Mon Sep 17 00:00:00 2001 From: Steph <35910788+huynhicode@users.noreply.github.com> Date: Fri, 18 Oct 2024 09:54:46 -0700 Subject: [PATCH 01/30] product hunt promo material updates --- docs/ecosystem/mermaid-chart.md | 2 +- .../.vitepress/components/ProductHuntBadge.vue | 14 -------------- .../mermaid/src/docs/.vitepress/theme/index.ts | 3 --- .../mermaid/src/docs/ecosystem/mermaid-chart.md | 2 +- 4 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 packages/mermaid/src/docs/.vitepress/components/ProductHuntBadge.vue diff --git a/docs/ecosystem/mermaid-chart.md b/docs/ecosystem/mermaid-chart.md index 32bf3376fc..1348219c10 100644 --- a/docs/ecosystem/mermaid-chart.md +++ b/docs/ecosystem/mermaid-chart.md @@ -12,7 +12,7 @@ Try the Ultimate AI, Mermaid, and Visual Diagramming Suite by creating an accoun
-Mermaid Whiteboard - Drag & Drop your Nodes with Mermaid's new Whiteboard! | Product Hunt +Mermaid Chart - A smarter way to create diagrams | Product Hunt ## About diff --git a/packages/mermaid/src/docs/.vitepress/components/ProductHuntBadge.vue b/packages/mermaid/src/docs/.vitepress/components/ProductHuntBadge.vue deleted file mode 100644 index 0f246db715..0000000000 --- a/packages/mermaid/src/docs/.vitepress/components/ProductHuntBadge.vue +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/packages/mermaid/src/docs/.vitepress/theme/index.ts b/packages/mermaid/src/docs/.vitepress/theme/index.ts index 05f15ea6ad..3ec200937f 100644 --- a/packages/mermaid/src/docs/.vitepress/theme/index.ts +++ b/packages/mermaid/src/docs/.vitepress/theme/index.ts @@ -9,8 +9,6 @@ import Contributors from '../components/Contributors.vue'; import HomePage from '../components/HomePage.vue'; // @ts-ignore Type not available import TopBar from '../components/TopBar.vue'; -// @ts-ignore Type not available -import ProductHuntBadge from '../components/ProductHuntBadge.vue'; import { getRedirect } from './redirect.js'; // @ts-ignore Type not available import 'uno.css'; @@ -25,7 +23,6 @@ export default { return h(Theme.Layout, null, { // Keeping this as comment as it took a lot of time to figure out how to add a component to the top bar. 'home-hero-before': () => h(TopBar), - 'home-hero-info-before': () => h(ProductHuntBadge), 'home-features-after': () => h(HomePage), 'doc-before': () => h(TopBar), }); diff --git a/packages/mermaid/src/docs/ecosystem/mermaid-chart.md b/packages/mermaid/src/docs/ecosystem/mermaid-chart.md index 83695dab75..77a7020b77 100644 --- a/packages/mermaid/src/docs/ecosystem/mermaid-chart.md +++ b/packages/mermaid/src/docs/ecosystem/mermaid-chart.md @@ -6,7 +6,7 @@ Try the Ultimate AI, Mermaid, and Visual Diagramming Suite by creating an accoun
-Mermaid Whiteboard - Drag & Drop your Nodes with Mermaid's new Whiteboard! | Product Hunt +Mermaid Chart - A smarter way to create diagrams | Product Hunt ## About From 6df1fa1a0324190f987281f370f1a53aea3eabe7 Mon Sep 17 00:00:00 2001 From: Steph <35910788+huynhicode@users.noreply.github.com> Date: Mon, 21 Oct 2024 23:26:17 -0700 Subject: [PATCH 02/30] update taglines --- .../src/docs/.vitepress/components/TopBar.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/mermaid/src/docs/.vitepress/components/TopBar.vue b/packages/mermaid/src/docs/.vitepress/components/TopBar.vue index 5aa5155757..b36fdd2d00 100644 --- a/packages/mermaid/src/docs/.vitepress/components/TopBar.vue +++ b/packages/mermaid/src/docs/.vitepress/components/TopBar.vue @@ -7,6 +7,10 @@ interface Taglines { } const taglines: Taglines[] = [ + { + label: 'Explore the Mermaid Whiteboard from the creators of Mermaid', + url: 'https://docs.mermaidchart.com/guides/whiteboard?utm_source=mermaid_live_editor&utm_medium=banner_ad&utm_campaign=whiteboard', + }, { label: 'Use the Visual Editor in Mermaid Chart to design and build diagrams', url: 'https://www.mermaidchart.com/play?utm_source=mermaid_live_editor&utm_medium=banner_ad&utm_campaign=visual_editor', @@ -16,8 +20,8 @@ const taglines: Taglines[] = [ url: 'https://www.mermaidchart.com/play?utm_source=mermaid_live_editor&utm_medium=banner_ad&utm_campaign=teams', }, { - label: 'Skip the rough draft with Mermaid AI in Mermaid Chart', - url: 'https://www.mermaidchart.com/play?utm_source=mermaid_live_editor&utm_medium=banner_ad&utm_campaign=mermaid_ai', + label: 'Replace ChatGPT Pro, Mermaid.live, and LucidChart with Mermaid Pro', + url: 'https://www.mermaidchart.com/play?utm_source=mermaid_live_editor&utm_medium=banner_ad&utm_campaign=AIbundle', }, ]; @@ -25,7 +29,7 @@ let index = ref(Math.floor(Math.random() * taglines.length)); onMounted(() => { setInterval(() => { index.value = (index.value + 1) % taglines.length; - }, 60_000); + }, 40_000); }); @@ -41,7 +45,7 @@ onMounted(() => { > {{ taglines[index].label }} From 054f9291502c3b0e966dcf4ace0b5358150ecd6c Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Tue, 29 Oct 2024 21:12:11 +0900 Subject: [PATCH 03/30] refactor: remove unused param from `labelHelper()` Fixes: 7401cb8f6aec0c7dccae820824eb2bb3e6a3e12d --- .../rendering-elements/shapes/util.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.ts index 6a9db8c222..e69e36e382 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.ts @@ -10,8 +10,7 @@ import type { D3Selection, Point } from '../../../types.js'; export const labelHelper = async ( parent: D3Selection, node: Node, - _classes?: string, - _shapeSvg?: D3Selection + _classes?: string ) => { let cssClasses; const useHtmlLabels = node.useHtmlLabels || evaluate(getConfig()?.flowchart?.htmlLabels); @@ -22,12 +21,10 @@ export const labelHelper = async ( } // Add outer g element - const shapeSvg = _shapeSvg - ? _shapeSvg - : parent - .insert('g') - .attr('class', cssClasses) - .attr('id', node.domId || node.id); + const shapeSvg = parent + .insert('g') + .attr('class', cssClasses) + .attr('id', node.domId || node.id); // Create the label and insert it after the rect const labelEl = shapeSvg From f33ebfaf7a135834affbc5e114014028c82c99ef Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Tue, 29 Oct 2024 21:13:10 +0900 Subject: [PATCH 04/30] refactor: fix broken generic on `insertLabel()` Fixes: 7401cb8f6aec0c7dccae820824eb2bb3e6a3e12d --- .../src/rendering-util/rendering-elements/shapes/util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.ts index e69e36e382..d18394f688 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.ts @@ -116,7 +116,7 @@ export const labelHelper = async ( labelEl.insert('rect', ':first-child'); return { shapeSvg, bbox, halfPadding, label: labelEl }; }; -export const insertLabel = async ( +export const insertLabel = async ( parent: D3Selection, label: string, options: { From 9168d5d1f4e3947e0c91ed20453f460c07d41f93 Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Tue, 29 Oct 2024 21:13:57 +0900 Subject: [PATCH 05/30] refactor(types): fix some type errors in kanbanItem Fixes: 7401cb8f6aec0c7dccae820824eb2bb3e6a3e12d --- .../rendering-elements/shapes/kanbanItem.ts | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts index 61dc3f85da..4dc6324a72 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts @@ -1,10 +1,10 @@ import { labelHelper, insertLabel, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { SVG } from '../../../diagram-api/types.js'; import type { Node, KanbanNode, ShapeRenderOptions } from '../../types.js'; import { createRoundedRectPathD } from './roundedRectPath.js'; import { userNodeOverrides, styles2String } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; +import type { D3Selection } from '../../../types.js'; const colorFromPriority = (priority: KanbanNode['priority']) => { switch (priority) { @@ -18,7 +18,11 @@ const colorFromPriority = (priority: KanbanNode['priority']) => { return 'lightblue'; } }; -export const kanbanItem = async (parent: SVG, node: Node, { config }: ShapeRenderOptions) => { +export const kanbanItem = async ( + parent: D3Selection, + node: Node, + { config }: ShapeRenderOptions +) => { const unknownNode = node as unknown; const kanbanNode = unknownNode as KanbanNode; const { labelStyles, nodeStyles } = styles2String(kanbanNode); @@ -41,7 +45,7 @@ export const kanbanItem = async (parent: SVG, node: Node, { config }: ShapeRende if (kanbanNode.ticket && config?.kanban?.ticketBaseUrl) { ticketUrl = config?.kanban?.ticketBaseUrl.replace('#TICKET#', kanbanNode.ticket); link = shapeSvg - .insert('svg:a', ':first-child') + .insert('svg:a', ':first-child') .attr('class', 'kanban-ticket-link') .attr('xlink:href', ticketUrl) .attr('target', '_blank'); @@ -56,11 +60,16 @@ export const kanbanItem = async (parent: SVG, node: Node, { config }: ShapeRende padding: kanbanNode.padding, centerLabel: false, }; - const { label: labelEl, bbox: bbox2 } = await insertLabel( - link ? link : shapeSvg, - kanbanNode.ticket || '', - options - ); + let labelEl, bbox2; + if (link) { + ({ label: labelEl, bbox: bbox2 } = await insertLabel(link, kanbanNode.ticket || '', options)); + } else { + ({ label: labelEl, bbox: bbox2 } = await insertLabel( + shapeSvg, + kanbanNode.ticket || '', + options + )); + } const { label: labelElAssigned, bbox: bboxAssigned } = await insertLabel( shapeSvg, kanbanNode.assigned || '', From dffaf9fa8ff523fa4d30b9c73c54175cfe36d423 Mon Sep 17 00:00:00 2001 From: Ashish Jain Date: Tue, 29 Oct 2024 13:41:20 +0100 Subject: [PATCH 06/30] fix for kanban section shape --- packages/mermaid/src/diagrams/kanban/kanbanDb.ts | 3 ++- .../mermaid/src/rendering-util/rendering-elements/clusters.js | 2 +- .../mermaid/src/rendering-util/rendering-elements/shapes.ts | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/src/diagrams/kanban/kanbanDb.ts b/packages/mermaid/src/diagrams/kanban/kanbanDb.ts index e6f57ef79a..f27799f1e8 100644 --- a/packages/mermaid/src/diagrams/kanban/kanbanDb.ts +++ b/packages/mermaid/src/diagrams/kanban/kanbanDb.ts @@ -129,7 +129,8 @@ const addNode = (level: number, id: string, descr: string, type: number, shapeDa throw new Error(`No such shape: ${doc.shape}. Shape names should be lowercase.`); } - if (doc?.shape) { + // if shape is defined in the yaml data, use it if it is a valid shape kanbanItem or kanbanSection + if (doc?.shape && (doc.shape === 'kanbanItem' || doc.shape === 'kanbanSection')) { node.shape = doc?.shape; } if (doc?.label) { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/clusters.js b/packages/mermaid/src/rendering-util/rendering-elements/clusters.js index 3bd9c9dc77..12ba15f39c 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/clusters.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/clusters.js @@ -280,7 +280,7 @@ const roundedWithTitle = async (parent, node) => { return { cluster: shapeSvg, labelBBox: bbox }; }; -const kanbanSection = async (parent, node) => { +export const kanbanSection = async (parent, node) => { log.info('Creating subgraph rect for ', node.id, node); const siteConfig = getConfig(); const { themeVariables, handDrawnSeed } = siteConfig; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes.ts index 4f6459d852..0dd22b1134 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes.ts @@ -59,6 +59,7 @@ import { waveRectangle } from './shapes/waveRectangle.js'; import { windowPane } from './shapes/windowPane.js'; import { classBox } from './shapes/classBox.js'; import { kanbanItem } from './shapes/kanbanItem.js'; +import { kanbanSection } from './clusters.js'; type ShapeHandler = ( parent: D3Selection, @@ -478,6 +479,7 @@ const generateShapeMap = () => { iconRounded, imageSquare, kanbanItem, + kanbanSection, anchor, } as const; From ef30283fe90481b1c9d45a5bcec18362ee2377f6 Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Tue, 29 Oct 2024 21:39:34 +0900 Subject: [PATCH 07/30] refactor: fix more type errors in kanbanItem Fixes: 7401cb8f6aec0c7dccae820824eb2bb3e6a3e12d --- .../rendering-elements/shapes/kanbanItem.ts | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts index 4dc6324a72..d19ada7c45 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts @@ -6,12 +6,14 @@ import { userNodeOverrides, styles2String } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import type { D3Selection } from '../../../types.js'; -const colorFromPriority = (priority: KanbanNode['priority']) => { +const colorFromPriority = (priority: NonNullable) => { switch (priority) { case 'Very High': return 'red'; case 'High': return 'orange'; + case 'Medium': + return null; // no stroke case 'Low': return 'blue'; case 'Very Low': @@ -20,11 +22,9 @@ const colorFromPriority = (priority: KanbanNode['priority']) => { }; export const kanbanItem = async ( parent: D3Selection, - node: Node, + kanbanNode: Node | Omit, { config }: ShapeRenderOptions ) => { - const unknownNode = node as unknown; - const kanbanNode = unknownNode as KanbanNode; const { labelStyles, nodeStyles } = styles2String(kanbanNode); kanbanNode.labelStyle = labelStyles; @@ -42,7 +42,7 @@ export const kanbanItem = async ( let ticketUrl = ''; let link; - if (kanbanNode.ticket && config?.kanban?.ticketBaseUrl) { + if ('ticket' in kanbanNode && kanbanNode.ticket && config?.kanban?.ticketBaseUrl) { ticketUrl = config?.kanban?.ticketBaseUrl.replace('#TICKET#', kanbanNode.ticket); link = shapeSvg .insert('svg:a', ':first-child') @@ -62,17 +62,21 @@ export const kanbanItem = async ( }; let labelEl, bbox2; if (link) { - ({ label: labelEl, bbox: bbox2 } = await insertLabel(link, kanbanNode.ticket || '', options)); + ({ label: labelEl, bbox: bbox2 } = await insertLabel( + link, + ('ticket' in kanbanNode && kanbanNode.ticket) || '', + options + )); } else { ({ label: labelEl, bbox: bbox2 } = await insertLabel( shapeSvg, - kanbanNode.ticket || '', + ('ticket' in kanbanNode && kanbanNode.ticket) || '', options )); } const { label: labelElAssigned, bbox: bboxAssigned } = await insertLabel( shapeSvg, - kanbanNode.assigned || '', + ('assigned' in kanbanNode && kanbanNode.assigned) || '', options ); kanbanNode.width = orgWidth; @@ -129,7 +133,9 @@ export const kanbanItem = async ( .attr('y', y) .attr('width', totalWidth) .attr('height', totalHeight); - if (kanbanNode.priority) { + + const priority = 'priority' in kanbanNode && kanbanNode.priority; + if (priority) { const line = shapeSvg.append('line', ':first-child'); const lineX = x + 2; @@ -142,7 +148,7 @@ export const kanbanItem = async ( .attr('y2', y2) .attr('stroke-width', '4') - .attr('stroke', colorFromPriority(kanbanNode.priority)); + .attr('stroke', colorFromPriority(priority)); } } From 0197c089169cfe28a476f73c2b216dc537bbf818 Mon Sep 17 00:00:00 2001 From: Ashish Jain Date: Tue, 29 Oct 2024 14:04:57 +0100 Subject: [PATCH 08/30] revert adding kanban section to shape --- packages/mermaid/src/diagrams/kanban/kanbanDb.ts | 4 ++-- .../mermaid/src/rendering-util/rendering-elements/clusters.js | 2 +- .../mermaid/src/rendering-util/rendering-elements/shapes.ts | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/mermaid/src/diagrams/kanban/kanbanDb.ts b/packages/mermaid/src/diagrams/kanban/kanbanDb.ts index f27799f1e8..5d6fc68f90 100644 --- a/packages/mermaid/src/diagrams/kanban/kanbanDb.ts +++ b/packages/mermaid/src/diagrams/kanban/kanbanDb.ts @@ -129,8 +129,8 @@ const addNode = (level: number, id: string, descr: string, type: number, shapeDa throw new Error(`No such shape: ${doc.shape}. Shape names should be lowercase.`); } - // if shape is defined in the yaml data, use it if it is a valid shape kanbanItem or kanbanSection - if (doc?.shape && (doc.shape === 'kanbanItem' || doc.shape === 'kanbanSection')) { + // if shape is defined in the yaml data, use it if it is a valid shape kanbanItem + if (doc?.shape && doc.shape === 'kanbanItem') { node.shape = doc?.shape; } if (doc?.label) { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/clusters.js b/packages/mermaid/src/rendering-util/rendering-elements/clusters.js index 12ba15f39c..3bd9c9dc77 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/clusters.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/clusters.js @@ -280,7 +280,7 @@ const roundedWithTitle = async (parent, node) => { return { cluster: shapeSvg, labelBBox: bbox }; }; -export const kanbanSection = async (parent, node) => { +const kanbanSection = async (parent, node) => { log.info('Creating subgraph rect for ', node.id, node); const siteConfig = getConfig(); const { themeVariables, handDrawnSeed } = siteConfig; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes.ts index 0dd22b1134..4f6459d852 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes.ts @@ -59,7 +59,6 @@ import { waveRectangle } from './shapes/waveRectangle.js'; import { windowPane } from './shapes/windowPane.js'; import { classBox } from './shapes/classBox.js'; import { kanbanItem } from './shapes/kanbanItem.js'; -import { kanbanSection } from './clusters.js'; type ShapeHandler = ( parent: D3Selection, @@ -479,7 +478,6 @@ const generateShapeMap = () => { iconRounded, imageSquare, kanbanItem, - kanbanSection, anchor, } as const; From 34e8946c585ac039e0c2b02947d110df1d295c25 Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Tue, 29 Oct 2024 22:17:24 +0900 Subject: [PATCH 09/30] refactor(types): fix kanbanItem circular types Exclude the `node.shape` type from `kanbanItem()`, as otherwise it causes a circular dependency in the types. --- .../rendering-elements/shapes/kanbanItem.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts index d19ada7c45..34ba7873d5 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts @@ -20,11 +20,12 @@ const colorFromPriority = (priority: NonNullable) => { return 'lightblue'; } }; -export const kanbanItem = async ( +export async function kanbanItem( parent: D3Selection, - kanbanNode: Node | Omit, + // Omit the 'shape' prop since otherwise, it causes a TypeScript circular dependency error + kanbanNode: Omit | Omit, { config }: ShapeRenderOptions -) => { +) { const { labelStyles, nodeStyles } = styles2String(kanbanNode); kanbanNode.labelStyle = labelStyles; @@ -160,4 +161,4 @@ export const kanbanItem = async ( }; return shapeSvg; -}; +} From 124d2f72dd20e3441aeaa5cf1cb64947d95a3590 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Tue, 29 Oct 2024 14:51:55 +0100 Subject: [PATCH 10/30] Fix for icon borders --- packages/mermaid/src/diagrams/kanban/kanbanDb.ts | 1 + .../rendering-elements/shapes/iconCircle.ts | 6 ++++-- .../rendering-elements/shapes/iconRounded.ts | 8 +++++--- .../rendering-elements/shapes/iconSquare.ts | 9 ++++++--- packages/mermaid/src/rendering-util/types.ts | 2 ++ 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/mermaid/src/diagrams/kanban/kanbanDb.ts b/packages/mermaid/src/diagrams/kanban/kanbanDb.ts index e6f57ef79a..260b1d32a5 100644 --- a/packages/mermaid/src/diagrams/kanban/kanbanDb.ts +++ b/packages/mermaid/src/diagrams/kanban/kanbanDb.ts @@ -84,6 +84,7 @@ const getData = function () { shape: 'kanbanItem', level: item.level, rx: 5, + ry: 5, cssStyles: ['text-align: left'], } satisfies KanbanNode; _nodes.push(childNode); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/iconCircle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/iconCircle.ts index 313e5c7af1..785a3d219c 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/iconCircle.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/iconCircle.ts @@ -26,16 +26,18 @@ export async function iconCircle( const topLabel = node.pos === 't'; - const { nodeBorder } = themeVariables; + const { nodeBorder, mainBkg } = themeVariables; const { stylesMap } = compileStyles(node); // @ts-expect-error -- Passing a D3.Selection seems to work for some reason const rc = rough.svg(shapeSvg); - const options = userNodeOverrides(node, { stroke: 'transparent' }); + const options = userNodeOverrides(node, {}); if (node.look !== 'handDrawn') { options.roughness = 0; options.fillStyle = 'solid'; } + const stroke = stylesMap.get('stroke'); + options.stroke = stroke ? stylesMap.get('stroke') : mainBkg; const iconElem = shapeSvg.append('g'); if (node.icon) { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/iconRounded.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/iconRounded.ts index ab778de71b..cfb13c35c6 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/iconRounded.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/iconRounded.ts @@ -30,7 +30,7 @@ export async function iconRounded( const height = iconSize + halfPadding * 2; const width = iconSize + halfPadding * 2; - const { nodeBorder } = themeVariables; + const { nodeBorder, mainBkg } = themeVariables; const { stylesMap } = compileStyles(node); const x = -width / 2; @@ -40,12 +40,14 @@ export async function iconRounded( // @ts-expect-error -- Passing a D3.Selection seems to work for some reason const rc = rough.svg(shapeSvg); - const options = userNodeOverrides(node, { stroke: 'transparent' }); + const options = userNodeOverrides(node, {}); if (node.look !== 'handDrawn') { options.roughness = 0; options.fillStyle = 'solid'; } + const stroke = stylesMap.get('stroke'); + options.stroke = stroke ? stylesMap.get('stroke') : mainBkg; const iconNode = rc.path(createRoundedRectPathD(x, y, width, height, 5), options); @@ -58,7 +60,7 @@ export async function iconRounded( stroke: 'none', }); - const iconShape = shapeSvg.insert(() => iconNode, ':first-child'); + const iconShape = shapeSvg.insert(() => iconNode, ':first-child').attr('class', 'icon-shape2'); const outerShape = shapeSvg.insert(() => outerNode); if (node.icon) { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/iconSquare.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/iconSquare.ts index 8cbccb74d2..97d5da1d19 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/iconSquare.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/iconSquare.ts @@ -3,6 +3,7 @@ import { log } from '../../../logger.js'; import { getIconSVG } from '../../icons.js'; import type { Node, ShapeRenderOptions } from '../../types.js'; import intersect from '../intersect/index.js'; +import { createRoundedRectPathD } from './roundedRectPath.js'; import { compileStyles, styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; import { labelHelper, updateNodeBounds } from './util.js'; import type { D3Selection } from '../../../types.js'; @@ -29,7 +30,7 @@ export async function iconSquare( const height = iconSize + halfPadding * 2; const width = iconSize + halfPadding * 2; - const { nodeBorder } = themeVariables; + const { nodeBorder, mainBkg } = themeVariables; const { stylesMap } = compileStyles(node); const x = -width / 2; @@ -39,14 +40,16 @@ export async function iconSquare( // @ts-expect-error -- Passing a D3.Selection seems to work for some reason const rc = rough.svg(shapeSvg); - const options = userNodeOverrides(node, { stroke: 'transparent' }); + const options = userNodeOverrides(node, {}); if (node.look !== 'handDrawn') { options.roughness = 0; options.fillStyle = 'solid'; } + const stroke = stylesMap.get('stroke'); + options.stroke = stroke ? stylesMap.get('stroke') : mainBkg; - const iconNode = rc.rectangle(x, y, width, height, options); + const iconNode = rc.path(createRoundedRectPathD(x, y, width, height, 0.1), options); const outerWidth = Math.max(width, bbox.width); const outerHeight = height + bbox.height + labelPadding; diff --git a/packages/mermaid/src/rendering-util/types.ts b/packages/mermaid/src/rendering-util/types.ts index e49218f711..f8e9c31b53 100644 --- a/packages/mermaid/src/rendering-util/types.ts +++ b/packages/mermaid/src/rendering-util/types.ts @@ -161,4 +161,6 @@ export interface KanbanNode extends Node { assigned?: string; icon?: string; level: number; + rx: number; + ry: number; } From 73bbde8476ec76e3c46eac2320d04cd7e195c278 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Tue, 29 Oct 2024 16:21:56 +0100 Subject: [PATCH 11/30] Update of the background-fix --- cypress/platform/knsv2.html | 101 +++++++++++++++++- .../rendering-elements/shapes/iconCircle.ts | 4 +- .../rendering-elements/shapes/iconRounded.ts | 4 +- .../rendering-elements/shapes/iconSquare.ts | 4 +- 4 files changed, 105 insertions(+), 8 deletions(-) diff --git a/cypress/platform/knsv2.html b/cypress/platform/knsv2.html index 1de0712838..66fc0f2d31 100644 --- a/cypress/platform/knsv2.html +++ b/cypress/platform/knsv2.html @@ -10,6 +10,10 @@ href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css" rel="stylesheet" /> + +
+flowchart LR
+nA[Default] --> A@{ icon: 'fa:bell', form: 'rounded' }
+
+    
+
+flowchart LR
+nA[Style] --> A@{ icon: 'fa:bell', form: 'rounded' }
+style A fill:#f9f,stroke:#333,stroke-width:4px
+    
+
+flowchart LR
+nA[Class] --> A@{ icon: 'fa:bell', form: 'rounded' }
+A:::AClass
+classDef AClass fill:#f9f,stroke:#333,stroke-width:4px
+    
+
+flowchart LR
+  nA[Class] --> A@{ icon: 'logos:aws', form: 'rounded' }
+
+    
+
+flowchart LR
+nA[Default] --> A@{ icon: 'fa:bell', form: 'square' }
+
+    
+
+flowchart LR
+nA[Style] --> A@{ icon: 'fa:bell', form: 'square' }
+style A fill:#f9f,stroke:#333,stroke-width:4px
+    
+
+flowchart LR
+nA[Class] --> A@{ icon: 'fa:bell', form: 'square' }
+A:::AClass
+classDef AClass fill:#f9f,stroke:#333,stroke-width:4px
+    
+
+flowchart LR
+  nA[Class] --> A@{ icon: 'logos:aws', form: 'square' }
+
+    
+
+flowchart LR
+nA[Default] --> A@{ icon: 'fa:bell', form: 'circle' }
+
+    
+
+flowchart LR
+nA[Style] --> A@{ icon: 'fa:bell', form: 'circle' }
+style A fill:#f9f,stroke:#333,stroke-width:4px
+    
+
+flowchart LR
+nA[Class] --> A@{ icon: 'fa:bell', form: 'circle' }
+A:::AClass
+classDef AClass fill:#f9f,stroke:#333,stroke-width:4px
+    
+
+flowchart LR
+  nA[Class] --> A@{ icon: 'logos:aws', form: 'circle' }
+  A:::AClass
+  classDef AClass fill:#f9f,stroke:#333,stroke-width:4px
+    
+
+flowchart LR
+  nA[Style] --> A@{ icon: 'logos:aws', form: 'circle' }
+  style A fill:#f9f,stroke:#333,stroke-width:4px
+    
 kanban
   id2[In progress]
     docs[Create Blog about the new diagram]@{ priority: 'Very Low', ticket: MC-2037, assigned: 'knsv' }
     
-
+    
 ---
 config:
   kanban:
@@ -118,6 +191,30 @@