Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,492 changes: 1,733 additions & 1,759 deletions lib/resources/docs.dart.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions lib/resources/docs.dart.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/resources/styles.css

Large diffs are not rendered by default.

19 changes: 8 additions & 11 deletions lib/src/generator/templates.aot_renderers_for_html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2478,17 +2478,14 @@ String _deduplicated__head(TemplateDataBase context0) {
<form class="search navbar-right" role="search">
<input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
</form>
<div class="toggle" id="theme-button" title="Toggle brightness">
<label for="theme">
<input type="checkbox" id="theme" value="light-theme">
<span id="dark-theme-button" class="material-symbols-outlined">
dark_mode
</span>
<span id="light-theme-button" class="material-symbols-outlined">
light_mode
</span>
</label>
</div>
<button class="toggle" id="theme-button" title="Toggle between light and dark mode" aria-label="Light and dark mode toggle">
<span id="dark-theme-button" class="material-symbols-outlined" aria-hidden="true">
dark_mode
</span>
<span id="light-theme-button" class="material-symbols-outlined" aria-hidden="true">
light_mode
</span>
</button>
</header>
<main>''');

Expand Down
19 changes: 8 additions & 11 deletions lib/templates/_head.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,13 @@
<form class="search navbar-right" role="search">
<input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
</form>
<div class="toggle" id="theme-button" title="Toggle brightness">
<label for="theme">
<input type="checkbox" id="theme" value="light-theme">
<span id="dark-theme-button" class="material-symbols-outlined">
dark_mode
</span>
<span id="light-theme-button" class="material-symbols-outlined">
light_mode
</span>
</label>
</div>
<button class="toggle" id="theme-button" title="Toggle between light and dark mode" aria-label="Light and dark mode toggle">
<span id="dark-theme-button" class="material-symbols-outlined" aria-hidden="true">
dark_mode
</span>
<span id="light-theme-button" class="material-symbols-outlined" aria-hidden="true">
light_mode
</span>
</button>
</header>
<main>
2 changes: 1 addition & 1 deletion web/sig.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6AD77EE4737CB53C3F7994D7BCC1E463
318ACAF85024D323F3F60B8D63B1EC23
70 changes: 30 additions & 40 deletions web/styles/_theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@
--alert-important-fgColor: #7953bf;
--alert-warning-fgColor: #955d00;
--alert-error-fgColor: #c43131;

#light-theme-button {
display: none;
}

// Hide dark-mode only images from GitHub's themable image support.
img[src$="#gh-dark-mode-only"] {
display: none;
}
}

.dark-theme {
Expand Down Expand Up @@ -88,53 +97,34 @@
--alert-important-fgColor: #ad81ff;
--alert-warning-fgColor: #cea11f;
--alert-error-fgColor: #ff6666;
}

#theme {
display: none;
#dark-theme-button {
display: none;
}

// Hide light-mode only images from GitHub's themable image support.
img[src$="#gh-light-mode-only"] {
display: none;
}
}

#theme-button {
// Reset button appearance.
appearance: none;
border: none;
background: none;
cursor: pointer;

position: absolute;
right: 30px;
height: 24px;
}
display: flex;
align-items: center;
justify-content: center;
padding: 4px;

#theme-button .material-symbols-outlined {
color: var(--main-icon-color);
user-select: none;
cursor: pointer;
}

#theme-button .material-symbols-outlined:hover {
color: var(--main-hyperlinks-color);
}

li .material-symbols-outlined, dt .material-symbols-outlined {
font-size: 1em;
vertical-align: text-bottom;
}

dt .material-symbols-outlined {
text-indent: 0;
}

.light-theme #light-theme-button {
display: none;
}

.dark-theme #dark-theme-button {
display: none;
}

/*
Only show images that fit their theme using GitHub's syntax, see:
https://github.blog/changelog/2021-11-24-specify-theme-context-for-images-in-markdown/
*/
.dark-theme img[src$="#gh-light-mode-only"] {
display: none;
}

.light-theme img[src$="#gh-dark-mode-only"] {
display: none;
&:hover {
color: var(--main-hyperlinks-color);
}
}
9 changes: 9 additions & 0 deletions web/styles/dartdoc/_misc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@
display: none !important;
}
}

li .material-symbols-outlined, dt .material-symbols-outlined {
font-size: 1em;
vertical-align: text-bottom;
}

dt .material-symbols-outlined {
text-indent: 0;
}
28 changes: 15 additions & 13 deletions web/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,36 @@ import 'package:web/web.dart';

void init() {
var bodyElement = document.body;

if (bodyElement == null) {
return;
}

var theme = document.getElementById('theme') as HTMLInputElement;
var themeButton =
document.getElementById('theme-button') as HTMLButtonElement;

void switchThemes(bool toDarkMode) {
if (toDarkMode) {
bodyElement.classList.remove('light-theme');
bodyElement.classList.add('dark-theme');

void switchThemes() {
if (theme.checked) {
bodyElement.setAttribute('class', 'dark-theme');
theme.setAttribute('value', 'dark-theme');
window.localStorage.setItem('colorTheme', 'true');
} else {
bodyElement.setAttribute('class', 'light-theme');
theme.setAttribute('value', 'light-theme');
bodyElement.classList.remove('dark-theme');
bodyElement.classList.add('light-theme');

window.localStorage.setItem('colorTheme', 'false');
}
}

theme.addEventListener(
'change',
themeButton.addEventListener(
'click',
(Event _) {
switchThemes();
final currentlyDarkMode = bodyElement.classList.contains('dark-theme');
switchThemes(!currentlyDarkMode);
}.toJS,
);

if (window.localStorage.getItem('colorTheme') case var colorTheme?) {
theme.checked = colorTheme == 'true';
switchThemes();
switchThemes(colorTheme == 'true');
}
}