Skip to content

Commit 7f113a8

Browse files
committed
docs(sidebar[projects]): prevent active link flash with visibility gate
why: all links render with class="current" then JS replaces the hostname-matching link with a bold span, causing a visible reflow when IBM Plex fonts load with different metrics than the fallback. what: - Remove misleading class="current" from all project links - Hide #sidebar-projects until JS resolves active state (.ready class) - Use textContent instead of innerHTML for safer DOM manipulation
1 parent dadbe02 commit 7f113a8

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

docs/_static/css/custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
margin-right: calc(var(--sidebar-item-spacing-horizontal) / 2.5);
1717
}
1818

19+
#sidebar-projects:not(.ready) {
20+
visibility: hidden;
21+
}
22+
1923
.sidebar-tree .active {
2024
font-weight: bold;
2125
}

docs/_templates/sidebar/projects.html

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,64 @@
77

88
<p class="indented-block">
99
<span class="project-name">vcs-python</span>
10-
<a class="internal" href="https://vcspull.git-pull.com" class="current">vcspull</a>
10+
<a class="internal" href="https://vcspull.git-pull.com">vcspull</a>
1111
(<a class="internal" href="https://libvcs.git-pull.com">libvcs</a>),
1212
<a class="internal" href="https://g.git-pull.com">g</a>
1313
</p>
1414
<p class="indented-block">
1515
<span class="project-name">tmux-python</span>
16-
<a class="internal" href="https://tmuxp.git-pull.com" class="current">tmuxp</a>
16+
<a class="internal" href="https://tmuxp.git-pull.com">tmuxp</a>
1717
(<a class="internal" href="https://libtmux.git-pull.com">libtmux</a>)
1818
</p>
1919

2020
<p class="indented-block">
2121
<span class="project-name">cihai</span>
2222
<span class="indent">
23-
<a class="internal" href="https://unihan-etl.git-pull.com" class="current">unihan-etl</a>
23+
<a class="internal" href="https://unihan-etl.git-pull.com">unihan-etl</a>
2424
(<a class="internal" href="https://unihan-db.git-pull.com">db</a>)
2525
</span>
2626
<span class="indent">
27-
<a class="internal" href="https://cihai.git-pull.com" class="current">cihai</a>
27+
<a class="internal" href="https://cihai.git-pull.com">cihai</a>
2828
(<a class="internal" href="https://cihai-cli.git-pull.com">cli</a>)
2929
</span>
3030
</p>
3131

3232
<p class="indented-block">
3333
<span class="project-name">django</span>
3434
<span class="indent">
35-
<a class="internal" href="https://django-slugify-processor.git-pull.com" class="current">django-slugify-processor</a>
35+
<a class="internal" href="https://django-slugify-processor.git-pull.com">django-slugify-processor</a>
3636
</span>
3737
<span class="indent">
38-
<a class="internal" href="https://django-docutils.git-pull.com" class="current">django-docutils</a>
38+
<a class="internal" href="https://django-docutils.git-pull.com">django-docutils</a>
3939
</span>
4040
</p>
4141

4242
<p class="indented-block">
4343
<span class="project-name">docs + tests</span>
4444
<span class="indent">
45-
<a class="internal" href="https://gp-libs.git-pull.com" class="current">gp-libs</a>
45+
<a class="internal" href="https://gp-libs.git-pull.com">gp-libs</a>
4646
</span>
4747
</p>
4848

4949
<p class="indented-block">
5050
<span class="project-name">web</span>
5151
<span class="indent">
52-
<a class="internal" href="https://social-embed.org" class="current">social-embed</a>
52+
<a class="internal" href="https://social-embed.org">social-embed</a>
5353
</span>
5454
</p>
5555
</div>
5656
<script type="text/javascript">
5757
(() => {
58-
const sidebar = document.getElementById("sidebar-projects")
58+
const sidebar = document.getElementById("sidebar-projects");
5959
sidebar.querySelectorAll(`a[href*="${window.location.hostname}"]`)
6060
.forEach((link) => {
6161
if (!link.classList.contains("active")) {
6262
const d = document.createElement('span');
63-
d.innerHTML = link.innerHTML;
63+
d.textContent = link.textContent;
6464
d.classList.add("active");
6565
link.parentNode.replaceChild(d, link);
6666
}
6767
});
68+
sidebar.classList.add('ready');
6869
})()
6970
</script>

0 commit comments

Comments
 (0)