mirror of
https://github.com/jackyzha0/quartz.git
synced 2026-03-24 15:05:42 -05:00
Merge pull request #1 from MarcRez33/fix/graph-colorscheme-text
fix:graph colorscheme text
This commit is contained in:
commit
7bcd5702b1
6
content/index.md
Normal file
6
content/index.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
title: Welcome to Quartz
|
||||
---
|
||||
|
||||
This is a blank Quartz installation.
|
||||
See the [documentation](https://quartz.jzhao.xyz) for how to get started.
|
||||
@ -190,6 +190,15 @@ async function renderGraph(container: string, fullSlug: FullSlug) {
|
||||
{} as Record<(typeof cssVars)[number], string>,
|
||||
)
|
||||
|
||||
function updateTextStyle() {
|
||||
const darkMode = document.documentElement.getAttribute("saved-theme") === "dark"
|
||||
|
||||
for (const n of nodeRenderData) {
|
||||
const nodeColor = color(n.simulationData)
|
||||
n.label.style.fill = darkMode ? "white" : "black"
|
||||
}
|
||||
}
|
||||
|
||||
// calculate color
|
||||
const color = (d: NodeData) => {
|
||||
const isCurrent = d.id === slug
|
||||
@ -379,7 +388,6 @@ async function renderGraph(container: string, fullSlug: FullSlug) {
|
||||
anchor: { x: 0.5, y: 1.2 },
|
||||
style: {
|
||||
fontSize: fontSize * 15,
|
||||
fill: computedStyleMap["--dark"],
|
||||
fontFamily: computedStyleMap["--bodyFont"],
|
||||
},
|
||||
resolution: window.devicePixelRatio * 4,
|
||||
@ -428,6 +436,12 @@ async function renderGraph(container: string, fullSlug: FullSlug) {
|
||||
nodeRenderData.push(nodeRenderDatum)
|
||||
}
|
||||
|
||||
// Call updateTextStyle immediately after creating all labels
|
||||
updateTextStyle()
|
||||
|
||||
document.addEventListener("themechange", updateTextStyle)
|
||||
window.addCleanup(() => document.removeEventListener("themechange", updateTextStyle))
|
||||
|
||||
for (const l of graphData.links) {
|
||||
const gfx = new Graphics({ interactive: false, eventMode: "none" })
|
||||
linkContainer.addChild(gfx)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user