manim/docs/source/_static/responsiveSvg.js
Anton Ballmaier 2d2604bca9
Add inheritance diagrams to reference page (#1441)
* test

* revert test changes

* add inheritance map

* Configure Graph to fit dark theme

* Add inheritance graphs to each section in reference

* Responsive color scheme

* remove unnecessary comment

* remove more stuff from testing

* and more still

* Update docs/source/_static/responsiveSvg.js

Co-authored-by: Naveen M K <naveen@syrusdark.website>

* Add graphviz explanation to docs

* add background color fix for chrome

* Add subheadings

* Chnaged Headings to singular and bold

Apply suggestions from code review

Co-authored-by: Jan-Hendrik Müller <44469195+kolibril13@users.noreply.github.com>

Co-authored-by: Naveen M K <naveen@syrusdark.website>
Co-authored-by: Jan-Hendrik Müller <44469195+kolibril13@users.noreply.github.com>
2021-05-06 12:31:02 +02:00

67 lines
1.9 KiB
JavaScript

window.addEventListener("load", function () {
const styleElements = []
const colorSchemeQuery = window.matchMedia('(prefers-color-scheme: dark)');
const diagrams = document.querySelectorAll("object.inheritance.graphviz");
for (let diagram of diagrams) {
style = document.createElement('style');
styleElements.push(style);
console.log(diagram);
diagram.contentDocument.firstElementChild.appendChild(style);
}
function setColorScheme(e) {
let colors, additions = "";
if (e.matches) {
// Dark
colors = {
text: "#e07a5f",
box: "#383838",
edge: "#d0d0d0",
background: "#131416"
};
} else {
// Light
colors = {
text: "#e07a5f",
box: "#fff",
edge: "#413c3c",
background: "#f1ece9"
};
additions = `
.node polygon {
filter: drop-shadow(0 1px 3px #0002);
}
`
}
for (let style of styleElements) {
style.innerHTML = `
svg {
background-color: ${colors.background};
}
.node text {
fill: ${colors.text};
}
.node polygon {
fill: ${colors.box};
}
.edge polygon {
fill: ${colors.edge};
stroke: ${colors.edge};
}
.edge path {
stroke: ${colors.edge};
}
${additions}
`;
}
}
setColorScheme(colorSchemeQuery);
colorSchemeQuery.addEventListener("change", setColorScheme);
});