♿️ fix: improve accessibility and i18n (#183)
This commit is contained in:
18
templates/partials/theme_switcher.html
Normal file
18
templates/partials/theme_switcher.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<li class="theme-switcher-wrapper js">
|
||||
{#- Create the localised strings for the title and aria-label attributes -#}
|
||||
{%- set toggle_str = macros_translate::translate(key='toggle_mode', default='Toggle $MODE mode', language_strings=language_strings) -%}
|
||||
{%- set dark_str = macros_translate::translate(key='dark', default='dark', language_strings=language_strings) -%}
|
||||
{%- set light_str = macros_translate::translate(key='light', default='light', language_strings=language_strings) -%}
|
||||
|
||||
{%- set combined_mode_str = dark_str ~ "/" ~ light_str -%}
|
||||
{%- set title_label = toggle_str | replace(from="$MODE", to=combined_mode_str) -%}
|
||||
{%- set aria_label = 'Toggle ' ~ dark_str ~ ' mode' -%}
|
||||
|
||||
<div
|
||||
title="{{ title_label }}"
|
||||
class="theme-switcher"
|
||||
role="button"
|
||||
aria-label="{{ aria_label }}"
|
||||
aria-pressed="false">
|
||||
</div>
|
||||
</li>
|
Reference in New Issue
Block a user