hugo-theme-re-terminal/demoSite/layouts/posts/css-vars-showcase.html

51 lines
1.8 KiB
HTML
Raw Normal View History

2024-07-31 10:19:01 +00:00
{{ define "head" }}
<style>
2024-07-31 12:24:36 +00:00
.color-container {
background-color: var(--accent);
padding: 10px;
color: var(--accent-contrast-color)
}
2024-07-31 10:19:01 +00:00
</style>
{{ end }}{{ define "main" }}
<div class="post">
<!-- Common header, cover, etc. -->
{{ partial "single_basic.html" . }}
2024-07-31 12:24:36 +00:00
<form oninput="accentColor.value=accentColorPicker.value">
<output class="color-container" name="accentColor" for="accentColorPicker">#------</output>
<label>
Pick accent color
<input id="accentColorPicker" name="accentColorPicker" type="color" />
</label>
</form>
<form oninput="accentContrastColor.value=accentContrastColorPicker.value;">
<output class="color-container" name="accentContrastColor" for="accentContrastColorPicker">#------</output>
2024-07-31 10:19:01 +00:00
<label>
2024-07-31 12:24:36 +00:00
Pick accent contrast color
<input id="accentContrastColorPicker" name="accentContrastColorPicker" type="color" />
2024-07-31 10:19:01 +00:00
</label>
</form>
2024-07-31 12:24:36 +00:00
2024-07-31 10:19:01 +00:00
<script defer>
const root = document.querySelector(':root');
2024-07-31 12:24:36 +00:00
const accentPicker = document.getElementById("accentColorPicker");
const accentListener = accentPicker.addEventListener("input", () => {
if (accentPicker.value) {
root.style.setProperty('--accent', accentPicker.value);
2024-07-31 10:19:01 +00:00
}
})
2024-07-31 12:24:36 +00:00
const accentContrastPicker = document.getElementById("accentContrastColorPicker");
const accentContrastListener = accentContrastPicker.addEventListener("input", () => {
if (accentContrastPicker.value) {
root.style.setProperty('--accent-contrast-color', accentContrastPicker.value);
}
})
2024-07-31 10:19:01 +00:00
</script>
{{ if eq .Type $.Site.Params.contentTypeName }} {{ partial
"posts_pagination.html" . }} {{ end }} {{ if not (.Params.hideComments |
default false) }} {{ partial "comments.html" . }} {{ end }}
</div>
2024-07-31 12:24:36 +00:00
{{ end }}