mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 14:18:04 +08:00
Add the auto-generated node catalog to the website's user manual (#3662)
* Generate the MVP node catalog in the manual (with some placeholders) * Implement nearly the rest of everything * Move to the tools directory and make it generate nicer default values * Add category descriptions * Organize file structure and improve type naming * Improve book table of contents code * Add collapsing chapter navigation to the book template * Add to build workflow * Clean up site structure
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
window.addEventListener("DOMContentLoaded", initializeFundraisingBar);
|
||||
|
||||
function initializeFundraisingBar() {
|
||||
const VISIBILITY_COVERAGE_FRACTION = 0.5;
|
||||
|
||||
let loaded = false;
|
||||
|
||||
const fundraising = document.querySelector("[data-fundraising]");
|
||||
if (!fundraising) return;
|
||||
const bar = fundraising.querySelector("[data-fundraising-bar]");
|
||||
const dynamicPercent = fundraising.querySelector("[data-fundraising-percent] [data-dynamic]");
|
||||
const dynamicGoal = fundraising.querySelector("[data-fundraising-goal] [data-dynamic]");
|
||||
if (!(fundraising instanceof HTMLElement && bar instanceof HTMLElement && dynamicPercent instanceof HTMLElement && dynamicGoal instanceof HTMLElement)) return;
|
||||
|
||||
const setFundraisingGoal = async () => {
|
||||
const request = await fetch("https://graphite.art/fundraising-goal");
|
||||
/** @type {{ percentComplete: number, targetValue: number }} */
|
||||
const data = await request.json();
|
||||
|
||||
fundraising.classList.remove("loading");
|
||||
bar.style.setProperty("--fundraising-percent", `${data.percentComplete}%`);
|
||||
dynamicPercent.textContent = `${data.percentComplete}`;
|
||||
dynamicGoal.textContent = `${data.targetValue}`;
|
||||
|
||||
loaded = true;
|
||||
};
|
||||
new IntersectionObserver(
|
||||
(entries) => {
|
||||
entries.forEach((entry) => {
|
||||
if (!loaded && entry.intersectionRatio > VISIBILITY_COVERAGE_FRACTION) setFundraisingGoal();
|
||||
});
|
||||
},
|
||||
{ threshold: VISIBILITY_COVERAGE_FRACTION },
|
||||
).observe(fundraising);
|
||||
}
|
||||
Reference in New Issue
Block a user