Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions browser-tests/docs-diagrams.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test('the built documentation loads Mermaid and renders diagrams without errors'
page.on('pageerror', error => errors.push(error.message))
await page.goto(`${siteURL}/docs/implementation/`)
const diagrams = page.locator('.mermaid')
await expect(diagrams).toHaveCount(3)
await expect(diagrams.first()).toBeVisible()
for (const diagram of await diagrams.all()) {
await expect(diagram.locator('svg')).toBeVisible()
Expand All @@ -19,3 +20,26 @@ test('the built documentation loads Mermaid and renders diagrams without errors'
}
expect(errors).toEqual([])
})

test('diagram edges and arrowheads follow live light/dark color changes', async ({ page, siteURL }) => {
await page.emulateMedia({ colorScheme: 'light' })
await page.goto(`${siteURL}/docs/implementation/`)
const diagrams = page.locator('.mermaid')
await expect(diagrams).toHaveCount(3)
for (const diagram of await diagrams.all()) {
await expect(diagram.locator('svg')).toBeVisible()
}

const colors = new Set()
for (const colorScheme of ['light', 'dark']) {
await page.emulateMedia({ colorScheme })
const color = await page.locator('body').evaluate(element => getComputedStyle(element).color)
colors.add(color)
for (const diagram of await diagrams.all()) {
await expect(diagram.locator('.flowchart-link').first()).toHaveCSS('stroke', color)
await expect(diagram.locator('.marker path').first()).toHaveCSS('fill', color)
await expect(diagram.locator('.marker path').first()).toHaveCSS('stroke', color)
}
}
expect(colors.size).toBe(2)
})
3 changes: 1 addition & 2 deletions docs/implementation/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ mermaid.initialize({
subGraphTitleMargin: { top: 8, bottom: 16 },
},
themeVariables: {
fontFamily: 'system-ui, sans-serif',
lineColor: 'currentColor'
fontFamily: 'system-ui, sans-serif'
}
})
12 changes: 11 additions & 1 deletion docs/implementation/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
}

/* Mermaid embeds ID-scoped theme rules in each SVG. Override only its
surfaces and labels so diagrams follow the site's live light/dark theme. */
surfaces, labels, and edges so diagrams follow the site's live light/dark
theme without passing CSS color keywords to Mermaid's color parser. */
.mermaid .node :is(rect, polygon, circle, path),
.mermaid .edgeLabel rect {
fill: var(--background) !important;
Expand All @@ -30,6 +31,15 @@
stroke: var(--site-muted) !important;
}

.mermaid .flowchart-link {
stroke: var(--text) !important;
}

.mermaid .marker {
fill: var(--text) !important;
stroke: var(--text) !important;
}

.mermaid text {
fill: var(--text) !important;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"cheerio": "^1.0.0-rc.10",
"installed-check": "^11.0.0",
"jsonfeed-to-atom": "^1.2.5",
"mermaid": "^11.17.2",
"mermaid": "^12.0.0",
"neostandard": "^0.13.0",
"npm-run-all2": "^9.0.2",
"preact": "^10.29.6",
Expand Down