{% themer %}
Concept
{% themer %}
is an overrideable theme switcher, i.e. a <button>
surrounding two icons.
- Requires file-based requirements of two icons to be present.
- Thin wrapper over
{% toggle_icons %}
but one containing the generic defaults. - The
<button>
implementstoggleTheme()
. - When set in the template without arguments, it will use defaults.
Execution
A wrapper over toggle_icons()
but specific to a toggle for the common sun and moon
pattern.
Each icon uses the same signature as {% icon %}. To apply a value to the first icon,
use the prefix icon_1
. To apply a value to the second icon, use the prefix icon_2
. If
none are supplied, icon_1 will contain defaults for 'sun', icon_2 will contain defaults
for 'moon'.
So with tog(icon_1_name='sun', icon_2_Name='moon')
, would implement the equivalent of
2 {% icon %} template tags surrounded by a button, e.g.:
This implies that the svgs for sun
and moon
are present in the designated template folder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
btn_kls |
str | None
|
Will populate the button's |
'theme-toggler'
|
aria_label |
str | None
|
Will populate the button's |
'Toggle dark mode'
|
icon1_name |
str | None
|
Will be used to create first {% icon %}. Defaults to "sun". |
'sun'
|
icon1_css |
str | None
|
Will be used to create first {% icon %}. Defaults to "sun_css". |
'sun_css'
|
icon1_parent_class |
str | None
|
Will be used to create first {% icon %}. Defaults to "icon1_svg". |
'icon1_svg'
|
icon1_pre_text |
str | None
|
Will be used to create first {% icon %}. Defaults to "Light mode". |
'Light mode'
|
icon1_pre_class |
str | None
|
Will be used to create first {% icon %}. Defaults to "sr-only". |
'sr-only'
|
icon2_name |
str | None
|
Will be used to create second {% icon %}. Defaults to "moon". |
'moon'
|
icon2_css |
str | None
|
Will be used to create second {% icon %}. Defaults to "moon_css". |
'moon_css'
|
icon2_parent_class |
str | None
|
Will be used to create second {% icon %}. Defaults to "icon2_svg". |
'icon2_svg'
|
icon2_pre_text |
str | None
|
Will be used to create second {% icon %}. Defaults to "Dark mode". |
'Dark mode'
|
icon2_pre_class |
str | None
|
Will be used to create second {% icon %}. Defaults to "sr-only". |
'sr-only'
|
Returns:
Name | Type | Description |
---|---|---|
SafeText |
SafeText
|
HTML fragment button |