File tree 1 file changed +10
-0
lines changed
src/librustdoc/html/static
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 1
1
// From rust:
2
2
/* global resourcesSuffix */
3
3
4
+ var darkThemes = [ "dark" , "ayu" ] ;
4
5
var currentTheme = document . getElementById ( "themeStyle" ) ;
5
6
var mainTheme = document . getElementById ( "mainThemeStyle" ) ;
7
+ var localStoredTheme = getCurrentValue ( "rustdoc-theme" ) ;
6
8
7
9
var savedHref = [ ] ;
8
10
@@ -179,6 +181,14 @@ var updateSystemTheme = (function() {
179
181
} ) ( ) ;
180
182
181
183
if ( getCurrentValue ( "rustdoc-use-system-theme" ) !== "false" && window . matchMedia ) {
184
+ // update the preferred dark theme if the user is already using a dark theme
185
+ // See https://github.com/rust-lang/rust/pull/77809#issuecomment-707875732
186
+ if ( getCurrentValue ( "rustdoc-use-system-theme" ) === null
187
+ && getCurrentValue ( "rustdoc-preferred-dark-theme" ) === null
188
+ && darkThemes . indexOf ( localStoredTheme ) >= 0 ) {
189
+ updateLocalStorage ( "rustdoc-preferred-dark-theme" , localStoredTheme ) ;
190
+ }
191
+
182
192
// call the function to initialize the theme at least once!
183
193
updateSystemTheme ( ) ;
184
194
} else {
You can’t perform that action at this time.
0 commit comments