forked from reuixiy/hugo-theme-meme
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Use SVG icon for theme switcher (reuixiy#155)
Fixes reuixiy#144 * Use SVG icon for theme switcher * Replace innerHTML with CSS selectors * Add some magic to moon icon * Update sun icon * Simplify * Do not add icons if theme switcher is hidden * Fix a careless bug
- Loading branch information
Showing
7 changed files
with
68 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...leSite/resources/_gen/assets/scss/scss/main.scss_a899b346ffc3a4bc65b84e40528dea51.content
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
exampleSite/resources/_gen/assets/scss/scss/main.scss_a899b346ffc3a4bc65b84e40528dea51.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"Target":"css/meme.min.123893da0ad2f3e34bfbdc37ba47a437fad955d0ad5d4642cd640578cd8569a8.css","MediaType":"text/css","Data":{"Integrity":"sha256-EjiT2grS8+NL+9w3ukekN/rZVdCtXUZCzWQFeM2Faag="}} | ||
{"Target":"css/meme.min.d2614cbfce1c21c345cf7ee62ee4d75ce06f77d2d7dedc087b2a8a526fc69d5d.css","MediaType":"text/css","Data":{"Integrity":"sha256-0mFMv84cIcNFz37mLuTXXOBvd9LX3twIeyqKUm/GnV0="}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
{{ if .Site.Params.enableDarkMode }} | ||
{{ with .Site.Params.defaultTheme | default "light" }} | ||
{{ if eq . "light" }} | ||
{{ $.Scratch.Set "text" "🌞" }} | ||
{{ else }} | ||
{{ $.Scratch.Set "text" "🌙" }} | ||
{{ end }} | ||
{{ $text := $.Scratch.Get "text" }} | ||
{{- $.Scratch.Delete "hide" -}} | ||
{{- if or (and $.IsHome $.Site.Params.hideThemeToggleInHome) (and (not $.IsHome) $.Site.Params.hideThemeToggle) -}} | ||
{{- $.Scratch.Set "hide" true -}} | ||
{{- end -}} | ||
{{- $hide := $.Scratch.Get "hide" -}} | ||
<div id="theme-switcher"{{ if $hide }} data-hide="true"{{ end }}>{{ $text }}</div> | ||
{{- $hide := or (and $.IsHome $.Site.Params.hideThemeToggleInHome) (and (not $.IsHome) $.Site.Params.hideThemeToggle) -}} | ||
<input | ||
type="checkbox" | ||
id="theme-switcher" | ||
{{ if eq . "dark" }}checked{{ end }} | ||
{{ if $hide }}aria-hidden="true"{{ end }} | ||
/> | ||
<label | ||
for="theme-switcher" | ||
class="switcher-label" | ||
> | ||
{{- if not $hide -}} | ||
{{- partial "utils/icon.html" (dict "Deliver" $ "name" "sun" "class" "icon theme-icon-light") -}} | ||
{{- partial "utils/icon.html" (dict "Deliver" $ "name" "moon" "class" "icon theme-icon-dark") -}} | ||
{{- end -}} | ||
</label> | ||
{{ end }} | ||
{{ end }} |