aboutsummaryrefslogtreecommitdiffstats
path: root/docs/_static/changelog.js
blob: f72d025cd5199bb15e16a6a014720784dd8746f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/** Update the changelog colors in dark mode */

const changelog = document.getElementById("changelog");

function updateEntryColor(entry) {
    const line = entry.lastChild;
    const lightColorSpan = line.childNodes.item(1);
    const darkColorSpan = lightColorSpan.cloneNode(true);

    line.insertBefore(darkColorSpan, lightColorSpan);

    lightColorSpan.classList.add("light");
    darkColorSpan.classList.add("dark");

    let color;
    switch (darkColorSpan.textContent) {
        case "Feature":
            color = "#5BF38E";
            break;
        case "Support":
            color = "#55A5E7";
            break;
        case "Bug":
            color = "#E14F4F";
            break;
        default:
            color = null;
    }

    darkColorSpan.style["color"] = color;
}

if (changelog !== null) {
    for (let collection of changelog.getElementsByClassName("simple")) {
        Array.from(collection.children).forEach(updateEntryColor);
    }
}