Skip to content

Commit 77a24e3

Browse files
authored
Hide theme switcher on homepage layout pages (#6905)
The code looks like a larger change due to whitespace differences, but it just doesn't render the theme switcher on pages with the 'homepage' layout. Which is currently the home page and the 404 page. @mit-mit Suggested this to avoid confusion on the page which (for now) only has a dark mode version. **Staged:** - Landing page: https://dart-dev--pr6905-misc-hide-theme-switcher-u5rlnhl2.web.app/ - 404 page: https://dart-dev--pr6905-misc-hide-theme-switcher-u5rlnhl2.web.app/404 - Another page where it still renders: https://dart-dev--pr6905-misc-hide-theme-switcher-u5rlnhl2.web.app/docs
1 parent 9fb3774 commit 77a24e3

File tree

2 files changed

+63
-65
lines changed

2 files changed

+63
-65
lines changed

site/lib/_sass/components/_theming.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#theme-switcher {
22
position: relative;
33

4-
//.icon-button span {
5-
// font-size: 1.5rem;
6-
//}
7-
84
> .dropdown-content {
95
right: -0.5rem;
106

site/lib/src/components/header.dart

Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class DashHeader extends StatelessComponent {
1616
@override
1717
Component build(BuildContext context) {
1818
final pageUrlPath = context.page.url;
19+
final layout = context.page.data.page['layout'];
1920
final activeEntry = _activeNavEntry(pageUrlPath);
2021

2122
return header(id: 'site-header', classes: 'always-dark-mode', [
@@ -139,69 +140,70 @@ class DashHeader extends StatelessComponent {
139140
MaterialIcon('search'),
140141
],
141142
),
142-
div(id: 'theme-switcher', classes: 'dropdown', [
143-
button(
144-
classes: 'dropdown-button icon-button',
145-
attributes: {
146-
'title': 'Select a theme',
147-
'aria-label': 'Select a theme',
148-
'aria-expanded': 'false',
149-
'aria-controls': 'theme-menu',
150-
},
151-
const [MaterialIcon('routine')],
152-
),
153-
div(classes: 'dropdown-content', id: 'theme-menu', [
154-
div(classes: 'dropdown-menu', [
155-
ul(
156-
attributes: {'role': 'listbox'},
157-
[
158-
li([
159-
button(
160-
attributes: {
161-
'data-theme': 'light',
162-
'title': 'Switch to light mode',
163-
'aria-label': 'Switch to light mode',
164-
'aria-selected': 'false',
165-
},
166-
[
167-
const MaterialIcon('light_mode'),
168-
span([text('Light')]),
169-
],
170-
),
171-
]),
172-
li([
173-
button(
174-
attributes: {
175-
'data-theme': 'dark',
176-
'title': 'Switch to dark mode',
177-
'aria-label': 'Switch to dark mode',
178-
'aria-selected': 'false',
179-
},
180-
[
181-
const MaterialIcon('dark_mode'),
182-
span([text('Dark')]),
183-
],
184-
),
185-
]),
186-
li([
187-
button(
188-
attributes: {
189-
'data-theme': 'auto',
190-
'title': 'Follow the device theme',
191-
'aria-label': 'Follow the device theme',
192-
'aria-selected': 'false',
193-
},
194-
[
195-
const MaterialIcon('night_sight_auto'),
196-
span([text('Automatic')]),
197-
],
198-
),
199-
]),
200-
],
201-
),
143+
if (layout != 'homepage')
144+
div(id: 'theme-switcher', classes: 'dropdown', [
145+
button(
146+
classes: 'dropdown-button icon-button',
147+
attributes: {
148+
'title': 'Select a theme',
149+
'aria-label': 'Select a theme',
150+
'aria-expanded': 'false',
151+
'aria-controls': 'theme-menu',
152+
},
153+
const [MaterialIcon('routine')],
154+
),
155+
div(classes: 'dropdown-content', id: 'theme-menu', [
156+
div(classes: 'dropdown-menu', [
157+
ul(
158+
attributes: {'role': 'listbox'},
159+
[
160+
li([
161+
button(
162+
attributes: {
163+
'data-theme': 'light',
164+
'title': 'Switch to light mode',
165+
'aria-label': 'Switch to light mode',
166+
'aria-selected': 'false',
167+
},
168+
[
169+
const MaterialIcon('light_mode'),
170+
span([text('Light')]),
171+
],
172+
),
173+
]),
174+
li([
175+
button(
176+
attributes: {
177+
'data-theme': 'dark',
178+
'title': 'Switch to dark mode',
179+
'aria-label': 'Switch to dark mode',
180+
'aria-selected': 'false',
181+
},
182+
[
183+
const MaterialIcon('dark_mode'),
184+
span([text('Dark')]),
185+
],
186+
),
187+
]),
188+
li([
189+
button(
190+
attributes: {
191+
'data-theme': 'auto',
192+
'title': 'Follow the device theme',
193+
'aria-label': 'Follow the device theme',
194+
'aria-selected': 'false',
195+
},
196+
[
197+
const MaterialIcon('night_sight_auto'),
198+
span([text('Automatic')]),
199+
],
200+
),
201+
]),
202+
],
203+
),
204+
]),
202205
]),
203206
]),
204-
]),
205207
div(
206208
id: 'site-switcher',
207209
classes: 'dropdown',

0 commit comments

Comments
 (0)