Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement optional customWallpaper param via JS (issue #103) #123

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Darthagnon
Copy link
Contributor

(do not merge just yet, I want to try and get adaptive wallpapers working)

@Darthagnon
Copy link
Contributor Author

Darthagnon commented May 26, 2022

I've been trying versions of

	<script type="text/javascript">
	function wallpaper() {
		document.body.style.backgroundImage = "url('{{ if .Site.Params.customWallpaperDark }}{{ .Site.Params.customWallpaperDark | absURL }}{{ else }}{{ .Site.Params.customWallpaper | absURL }}{{ end }}')";
		document.body.style.backgroundAttachment = "fixed";
		document.body.style.backgroundPosition = "center";
		document.body.style.minHeight = "100%";
		document.body.style.backgroundRepeat = "no-repeat";
	}

		wallpaper();
	</script>

but it's late and I'm falling asleep, without any luck.

Is there a reliable way to check whether dark mode is enabled currently? (the above doesn't, and overrides light wallpaper with dark wallpaper if present) I noticed there's a night cookie being set, but either it doesn't update very fast or I wasn't checking it right.

I'm also comparing with the Dark Mode toggle (with 2 wallpapers) from my site theme, which uses Local Storage for a live-updating var to indicate light/dark (but then, I don't know whether changing the cookie method here for that would make any difference, and there are probably dependent functions that I don't know about and would need to update)

@Darthagnon Darthagnon marked this pull request as draft May 26, 2022 02:41
Darthagnon added a commit to DragonsNotIncluded/DragonsNotIncluded.github.io that referenced this pull request May 31, 2022
... until implemented in base theme, we use temporary hack to give website custom wallpapers. See also:
AmazingRise/hugo-theme-diary#103
AmazingRise/hugo-theme-diary#123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant