Skip to content

Commit 53f8bd5

Browse files
author
Sander
authored
Merge pull request #94 from sumocoders/bugfix-theme
theme.current → theme()
2 parents 3bc7d3f + 456cf93 commit 53f8bd5

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

docs/frontend/dark-mode.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Dark mode
22

3-
On page load we load the correct theme stylesheet in `templates/head.html.twig` based on the variable `theme.current`.
4-
We also use that variable to show the correct logo in `templates/navigation.html.twig`.
3+
On page load we load the correct theme stylesheet in `templates/head.html.twig` based on the result of the `theme()`
4+
twig function. We also use that variable to show the correct logo in `templates/navigation.html.twig`.
55

66
First time on the application we show the theme based on the users OS preferences.
77
Later when the user uses the theme switcher in the navigation, we set a cookie with the theme chosen in Javascript.
@@ -10,7 +10,7 @@ Later when the user uses the theme switcher in the navigation, we set a cookie w
1010
## Disabled dark mode
1111

1212
- Remove the import of `Theme` from `imports.js`
13-
- Remove all `theme.current` if statements and remove the dark mode code.
13+
- Remove all `theme()` if statements and remove the dark mode code.
1414
- Remove dark mode logo and if statements on the light mode logo in `templates/navigation.html.twig`
1515
- Remove dark mode `encore_entry_link_tags` and if statement around it in `templates/head.html.twig`
1616
- Hide the div with class `.dark-mode-switch` to hide the dark mode toggle.

templates/user.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<div class="d-flex justify-content-end mt-3 me-3">
88
<div class="form-check dark-mode-switch" data-theme-toggler-wrapper>
9-
<input type="checkbox" class="form-check-input" id="dark-mode" data-theme-toggler{% if theme.current == 'theme-dark' %} checked="checked"{% endif %}>
9+
<input type="checkbox" class="form-check-input" id="dark-mode" data-theme-toggler{% if theme() == 'theme-dark' %} checked="checked"{% endif %}>
1010
<label class="form-check-label" for="dark-mode">{{ 'core.themes.dark'|trans|ucfirst }} {{ 'core.themes.themes'|trans }}</label>
1111
</div>
1212
</div>
@@ -17,8 +17,8 @@
1717
<div class="card p-4 mt-5">
1818
<div class="text-center mb-3 py-5 px-sm-4 px-md-5">
1919
{% block logo_image %}
20-
<img class="img-responsive{% if theme.current != 'theme-dark' %} d-none{% endif %}" data-navbar-logo-dark src="{{ asset('build/images/logo-application-dark.svg') }}" alt="{{ fallbacks.get('site_title') }}">
21-
<img class="img-responsive{% if theme.current == 'theme-dark' %} d-none{% endif %}" data-navbar-logo src="{{ asset('build/images/logo-application.svg') }}" alt="{{ fallbacks.get('site_title') }}">
20+
<img class="img-responsive{% if theme() != 'theme-dark' %} d-none{% endif %}" data-navbar-logo-dark src="{{ asset('build/images/logo-application-dark.svg') }}" alt="{{ fallbacks.get('site_title') }}">
21+
<img class="img-responsive{% if theme() == 'theme-dark' %} d-none{% endif %}" data-navbar-logo src="{{ asset('build/images/logo-application.svg') }}" alt="{{ fallbacks.get('site_title') }}">
2222
{% endblock %}
2323
</div>
2424

templates/usermenu.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<li>
1919
<div class="dropdown-item">
2020
<div class="form-check dark-mode-switch" data-theme-toggler-wrapper>
21-
<input type="checkbox" class="form-check-input" id="dark-mode{% if mobile %}-mobile{% endif %}" data-theme-toggler{% if theme.current == 'theme-dark' %} checked="checked"{% endif %}>
21+
<input type="checkbox" class="form-check-input" id="dark-mode{% if mobile %}-mobile{% endif %}" data-theme-toggler{% if theme() == 'theme-dark' %} checked="checked"{% endif %}>
2222
<label class="form-check-label" for="dark-mode{% if mobile %}-mobile{% endif %}">{{ 'core.themes.dark'|trans|ucfirst }} {{ 'core.themes.themes'|trans }}</label>
2323
</div>
2424
</div>

0 commit comments

Comments
 (0)