Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit d8fb3f6

Browse files
improve fallback behavior more
1 parent e656bf0 commit d8fb3f6

File tree

8 files changed

+19
-86
lines changed

8 files changed

+19
-86
lines changed

‎.node/tsconfig.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"files": ["../Assets/ts/theme-switching.ts"],
33
"compilerOptions": {
4-
"outFile": "../Resources/all.js"
4+
"outFile": "../Sources/swift-doc/Resources/all.js"
55
}
66
}

‎Assets/css/all.css‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,10 @@ select {
471471
outline: 0;
472472
z-index: 9;
473473
}
474+
475+
& option {
476+
color: #3c3c43;
477+
}
474478
}
475479

476480
input[type="file"] {

‎Assets/ts/theme-switching.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,15 @@ function updateDropdownLabel(systemTheme: "light" | "dark") {
7676
function checkThemingSupport() {
7777
const darkQuery = window.matchMedia('(prefers-color-scheme: dark)');
7878
const lightQuery = window.matchMedia('(prefers-color-scheme: light)');
79-
// If neither query matches, we know that the browser doesn't support theming
79+
// If neither query matches, we know that the browser doesn't support theming.
8080
if (!darkQuery.matches && !lightQuery.matches) {
8181
const themeOptionAuto = window.document.getElementById('theme-option-auto');
8282
// IE doesn't support element.remove()
8383
themeOptionAuto.parentNode.removeChild(themeOptionAuto);
8484
}
85+
// If the browser does not support css properties, we do not allow theme switching.
86+
const customProperty = getComputedStyle(document.body).getPropertyValue("--body");
87+
if (!customProperty) {
88+
(document.querySelector(".theme-select-container") as HTMLDivElement).style.display = 'none';
89+
}
8590
}

‎Resources/all.js‎

Lines changed: 0 additions & 79 deletions
This file was deleted.

‎Resources/all.min.css‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎Sources/swift-doc/Resources/all.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,22 @@ function setPickedTheme(newTheme) {
6262
function updateDropdownLabel(systemTheme) {
6363
window.document.getElementById('theme-option-auto').innerText = "Auto (" + systemTheme + ")";
6464
}
65-
6665
/**
6766
* Checks whether color-scheme is a supported feature of the browser.
6867
* If it is not, removes the auto option from the dropdown.
6968
*/
7069
function checkThemingSupport() {
7170
var darkQuery = window.matchMedia('(prefers-color-scheme: dark)');
7271
var lightQuery = window.matchMedia('(prefers-color-scheme: light)');
73-
// If neither query matches, we know that the browser doesn't support theming
72+
// If neither query matches, we know that the browser doesn't support theming.
7473
if (!darkQuery.matches && !lightQuery.matches) {
7574
var themeOptionAuto = window.document.getElementById('theme-option-auto');
7675
// IE doesn't support element.remove()
7776
themeOptionAuto.parentNode.removeChild(themeOptionAuto);
7877
}
78+
// If the browser does not support css properties, we do not allow theme switching.
79+
var customProperty = getComputedStyle(document.body).getPropertyValue("--body");
80+
if (!customProperty) {
81+
document.querySelector(".theme-select-container").style.display = 'none';
82+
}
7983
}

‎Sources/swift-doc/Resources/all.min.css‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Sources/swift-doc/Subcommands/Generate.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func fetchRemoteJS() throws -> Data {
150150
// When using Swift Package Manager versions that don't support bundled resources, just hide the theme select drop-down.
151151
let fallbackJS = """
152152
var hideThemeSelect = function() {
153-
document.querySelector(".theme-select-container").hidden = true;
153+
document.querySelector(".theme-select-container").style.display = "none";
154154
}
155155
// hiding the element in `requestAnimationFrame` causes the function to be called after the element exists,
156156
// but fast enough that the element does not flash on the screen.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /