Skip to content

Commit f0d506c

Browse files
committed
Fixed theme breaking when no palette is defined
1 parent 0028518 commit f0d506c

File tree

2 files changed

+49
-45
lines changed

2 files changed

+49
-45
lines changed

material/partials/header.html

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,22 @@
3333
</div>
3434
</div>
3535
</div>
36-
{% if not config.theme.palette is mapping %}
37-
<form class="md-header__option" data-md-component="palette">
38-
{% for option in config.theme.palette %}
39-
{% set scheme = option.scheme | d("default", true) %}
40-
{% set primary = option.primary | d("indigo", true) %}
41-
{% set accent = option.accent | d("indigo", true) %}
42-
<input class="md-option" data-md-color-media="{{ option.media }}" data-md-color-scheme="{{ scheme | replace(' ', '-') }}" data-md-color-primary="{{ primary | replace(' ', '-') }}" data-md-color-accent="{{ accent | replace(' ', '-') }}" {% if option.toggle %} aria-label="{{ option.toggle.name }}" {% else %} aria-hidden="true" {% endif %} type="radio" name="__palette" id="__palette_{{ loop.index }}">
43-
{% if option.toggle %}
44-
<label class="md-header__button md-icon" title="{{ option.toggle.name }}" for="__palette_{{ loop.index0 or loop.length }}" hidden>
45-
{% include ".icons/" ~ option.toggle.icon ~ ".svg" %}
46-
</label>
47-
{% endif %}
48-
{% endfor %}
49-
</form>
36+
{% if config.theme.palette %}
37+
{% if not config.theme.palette is mapping %}
38+
<form class="md-header__option" data-md-component="palette">
39+
{% for option in config.theme.palette %}
40+
{% set scheme = option.scheme | d("default", true) %}
41+
{% set primary = option.primary | d("indigo", true) %}
42+
{% set accent = option.accent | d("indigo", true) %}
43+
<input class="md-option" data-md-color-media="{{ option.media }}" data-md-color-scheme="{{ scheme | replace(' ', '-') }}" data-md-color-primary="{{ primary | replace(' ', '-') }}" data-md-color-accent="{{ accent | replace(' ', '-') }}" {% if option.toggle %} aria-label="{{ option.toggle.name }}" {% else %} aria-hidden="true" {% endif %} type="radio" name="__palette" id="__palette_{{ loop.index }}">
44+
{% if option.toggle %}
45+
<label class="md-header__button md-icon" title="{{ option.toggle.name }}" for="__palette_{{ loop.index0 or loop.length }}" hidden>
46+
{% include ".icons/" ~ option.toggle.icon ~ ".svg" %}
47+
</label>
48+
{% endif %}
49+
{% endfor %}
50+
</form>
51+
{% endif %}
5052
{% endif %}
5153
{% if config.extra.alternate %}
5254
<div class="md-header__option">

src/partials/header.html

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -72,39 +72,41 @@
7272
</div>
7373

7474
<!-- Color palette -->
75-
{% if not config.theme.palette is mapping %}
76-
<form class="md-header__option" data-md-component="palette">
77-
{% for option in config.theme.palette %}
78-
{% set scheme = option.scheme | d("default", true) %}
79-
{% set primary = option.primary | d("indigo", true) %}
80-
{% set accent = option.accent | d("indigo", true) %}
81-
<input
82-
class="md-option"
83-
data-md-color-media="{{ option.media }}"
84-
data-md-color-scheme="{{ scheme | replace(' ', '-') }}"
85-
data-md-color-primary="{{ primary | replace(' ', '-') }}"
86-
data-md-color-accent="{{ accent | replace(' ', '-') }}"
75+
{% if config.theme.palette %}
76+
{% if not config.theme.palette is mapping %}
77+
<form class="md-header__option" data-md-component="palette">
78+
{% for option in config.theme.palette %}
79+
{% set scheme = option.scheme | d("default", true) %}
80+
{% set primary = option.primary | d("indigo", true) %}
81+
{% set accent = option.accent | d("indigo", true) %}
82+
<input
83+
class="md-option"
84+
data-md-color-media="{{ option.media }}"
85+
data-md-color-scheme="{{ scheme | replace(' ', '-') }}"
86+
data-md-color-primary="{{ primary | replace(' ', '-') }}"
87+
data-md-color-accent="{{ accent | replace(' ', '-') }}"
88+
{% if option.toggle %}
89+
aria-label="{{ option.toggle.name }}"
90+
{% else %}
91+
aria-hidden="true"
92+
{% endif %}
93+
type="radio"
94+
name="__palette"
95+
id="__palette_{{ loop.index }}"
96+
/>
8797
{% if option.toggle %}
88-
aria-label="{{ option.toggle.name }}"
89-
{% else %}
90-
aria-hidden="true"
98+
<label
99+
class="md-header__button md-icon"
100+
title="{{ option.toggle.name }}"
101+
for="__palette_{{ loop.index0 or loop.length }}"
102+
hidden
103+
>
104+
{% include ".icons/" ~ option.toggle.icon ~ ".svg" %}
105+
</label>
91106
{% endif %}
92-
type="radio"
93-
name="__palette"
94-
id="__palette_{{ loop.index }}"
95-
/>
96-
{% if option.toggle %}
97-
<label
98-
class="md-header__button md-icon"
99-
title="{{ option.toggle.name }}"
100-
for="__palette_{{ loop.index0 or loop.length }}"
101-
hidden
102-
>
103-
{% include ".icons/" ~ option.toggle.icon ~ ".svg" %}
104-
</label>
105-
{% endif %}
106-
{% endfor %}
107-
</form>
107+
{% endfor %}
108+
</form>
109+
{% endif %}
108110
{% endif %}
109111

110112
<!-- Site language selector -->

0 commit comments

Comments
 (0)