Skip to content

Commit 62fc950

Browse files
authored
doc: make theme consistent across api and other docs
Since website based on 2 different repos, there was an inconsistency in theme selection, so we had 2 independant theme props. Now only one stored in local storage is a single source of truth PR-URL: #50877 Reviewed-By: Claudio Wunder <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent 4466dee commit 62fc950

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

BUILDING.md

+6
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,12 @@ make docopen
462462
This will open a file URL to a one-page version of all the browsable HTML
463463
documents using the default browser.
464464

465+
```bash
466+
make docclean
467+
```
468+
469+
This will clean previously built doc.
470+
465471
To test if Node.js was built correctly:
466472

467473
```bash

doc/api_assets/api.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
{
44
function setupTheme() {
5-
const kCustomPreference = 'customDarkTheme';
6-
const userSettings = sessionStorage.getItem(kCustomPreference);
5+
const storedTheme = localStorage.getItem('theme');
76
const themeToggleButton = document.getElementById('theme-toggle-btn');
87

9-
if (userSettings === null && window.matchMedia) {
8+
// Follow operating system theme preference
9+
if (storedTheme === null && window.matchMedia) {
1010
const mq = window.matchMedia('(prefers-color-scheme: dark)');
1111

1212
if ('onchange' in mq) {
@@ -28,16 +28,16 @@
2828
if (mq.matches) {
2929
document.documentElement.classList.add('dark-mode');
3030
}
31-
} else if (userSettings === 'true') {
31+
} else if (storedTheme === 'dark') {
3232
document.documentElement.classList.add('dark-mode');
3333
}
3434

3535
if (themeToggleButton) {
3636
themeToggleButton.hidden = false;
3737
themeToggleButton.addEventListener('click', function() {
38-
sessionStorage.setItem(
39-
kCustomPreference,
40-
document.documentElement.classList.toggle('dark-mode'),
38+
localStorage.setItem(
39+
'theme',
40+
document.documentElement.classList.toggle('dark-mode') ? 'dark' : 'light',
4141
);
4242
});
4343
}

doc/contributing/collaborator-guide.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,10 @@ The TSC serves as the final arbiter where required.
532532
[build](https://github.com/nodejs/build/issues) repositories, open new
533533
issues. Run a new CI any time someone pushes new code to the pull request.
534534
4. Check that the commit message adheres to [commit message guidelines][].
535-
5. Add all necessary [metadata](#metadata) to commit messages before landing. If
536-
you are unsure exactly how to format the commit messages, use the commit log
537-
as a reference. See [this commit][commit-example] as an example.
535+
5. Add all necessary [metadata][git-node-metadata] to commit messages before
536+
landing. If you are unsure exactly how to format the commit messages, use
537+
the commit log as a reference. See [this commit][commit-example] as an
538+
example.
538539

539540
For pull requests from first-time contributors, be
540541
[welcoming](#welcoming-first-time-contributors). Also, verify that their git

0 commit comments

Comments
 (0)