mirror of
https://github.com/foo-dogsquared/hugo-theme-more-contentful.git
synced 2025-02-07 12:19:26 +00:00
Add indication of selected theme
This commit is contained in:
parent
97e08d0557
commit
85f99f2cd4
@ -20,6 +20,11 @@ and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Version
|
|||||||
== Unreleased
|
== Unreleased
|
||||||
|
|
||||||
|
|
||||||
|
=== Added
|
||||||
|
|
||||||
|
* Indicator for the selected theme in the dropdown menu.
|
||||||
|
|
||||||
|
|
||||||
=== Updated
|
=== Updated
|
||||||
|
|
||||||
* Minimum Go runtime version in `go.mod`.
|
* Minimum Go runtime version in `go.mod`.
|
||||||
|
@ -103,6 +103,11 @@ footer[aria-label="Site footer"] {
|
|||||||
color: var(--background);
|
color: var(--background);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&--selected {
|
||||||
|
background: var(--base05);
|
||||||
|
color: var(--background);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination {
|
.pagination {
|
||||||
|
@ -65,7 +65,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script defer>
|
<script>
|
||||||
|
function styleTheme() {
|
||||||
|
const selectedTheme = window.localStorage.getItem("theme");
|
||||||
|
for (const el of document.querySelectorAll(".site__theme-item")) {
|
||||||
|
if (el.dataset.theme == selectedTheme) {
|
||||||
|
el.classList.add("site__theme-item--selected");
|
||||||
|
} else {
|
||||||
|
el.classList.remove("site__theme-item--selected");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const themeDropdown = document.querySelector('.site__theme-btn');
|
const themeDropdown = document.querySelector('.site__theme-btn');
|
||||||
themeDropdown.addEventListener('click', (event) => {
|
themeDropdown.addEventListener('click', (event) => {
|
||||||
const { target } = event;
|
const { target } = event;
|
||||||
@ -79,6 +90,10 @@
|
|||||||
delete document.documentElement.dataset.theme;
|
delete document.documentElement.dataset.theme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
styleTheme();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
styleTheme();
|
||||||
</script>
|
</script>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
Loading…
Reference in New Issue
Block a user