1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-12-18 05:41:31 +00:00

Refactor theme mode toggle

- Improve mode switching JS execution priority
- Drop deprecated Web API
This commit is contained in:
Cotes Chung
2021-12-01 19:51:25 +08:00
parent 707466b1df
commit 55fce7574c
10 changed files with 77 additions and 80 deletions

View File

@@ -52,7 +52,17 @@
</ul> <!-- ul.nav.flex-column -->
<div class="sidebar-bottom mt-auto d-flex flex-wrap justify-content-center align-items-center">
{% unless site.theme_mode %}
<a id="mode-toggle-wrapper" tabindex="0" onclick="flipMode()">
<i class="mode-toggle fas fa-adjust"></i>
</a>
{% if site.data.contact.size > 0 %}
<span class="icon-border"></span>
{% endif %}
{% endunless %}
{% for entry in site.data.contact %}
{% capture url %}
{%- if entry.type == 'github' -%}
@@ -71,7 +81,6 @@
{% if url %}
<a href="{{ url }}" aria-label="{{ entry.type }}"
{% unless site.theme_mode %}class="order-{{ forloop.index | plus: 2 }}"{% endunless %}
{% unless entry.noblank %}target="_blank" rel="noopener"{% endunless %}>
<i class="{{ entry.icon }}"></i>
</a>
@@ -79,16 +88,6 @@
{% endfor %}
{% unless site.theme_mode %}
{% if site.data.contact.size > 0 %}
<span class="icon-border order-2"></span>
{% endif %}
<span id="mode-toggle-wrapper" class="order-1" tabindex="0">
{% include mode-toggle.html %}
</span>
{% endunless %}
</div> <!-- .sidebar-bottom -->
</div><!-- #sidebar -->