This repository was archived by the owner on Jun 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +19
-86
lines changed Expand file tree Collapse file tree 8 files changed +19
-86
lines changed Original file line number Diff line number Diff line change 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}
Original file line number Diff line number Diff line change @@ -471,6 +471,10 @@ select {
471471 outline : 0 ;
472472 z-index : 9 ;
473473 }
474+
475+ & option {
476+ color : # 3c3c43 ;
477+ }
474478}
475479
476480input [type = "file" ] {
Original file line number Diff line number Diff line change @@ -76,10 +76,15 @@ function updateDropdownLabel(systemTheme: "light" | "dark") {
7676function 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}
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -62,18 +62,22 @@ function setPickedTheme(newTheme) {
6262function 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 */
7069function 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}
Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments