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

Chg: make usable without js #80

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/css/_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ section.gallery {
border-radius: 1rem;
}

& > img, & figure > img {
& > img, & figure > img, & noscript > img, & noscript > figure > img {
transition-duration: 150ms;
transition-property: all;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
Expand Down
10 changes: 10 additions & 0 deletions assets/css/no_script.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

img.lazyload {
display: none;
}

#gallery {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 20px;
}
3 changes: 3 additions & 0 deletions layouts/partials/album-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
{{ with $gallery }}
<a class="card" href="{{ .page.RelPermalink }}" title="{{ .page.Title }}">
<figure style="background-color: {{ .color }}">
<noscript>
<img loading="lazy" width="{{ .thumbnail.Width }}" height="{{ .thumbnail.Height }}" src="{{ .thumbnail.RelPermalink }}" alt="{{ .page.Title }}" />
</noscript>
<img class="lazyload" width="{{ .thumbnail.Width }}" height="{{ .thumbnail.Height }}" data-src="{{ .thumbnail.RelPermalink }}" alt="{{ .page.Title }}" />
</figure>
<div>
Expand Down
9 changes: 8 additions & 1 deletion layouts/partials/gallery.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<section class="gallery">
<div id="gallery" style="visibility: hidden; height: 1px; overflow: hidden">
<div id="gallery" style="overflow: hidden">
{{ $images := slice }}
{{ range $image := .Resources.ByType "image" }}
{{ $title := "" }}
Expand Down Expand Up @@ -27,6 +27,9 @@
{{ $color := index $thumbnail.Colors 0 | default "transparent" }}
<a class="gallery-item" href="{{ $image.RelPermalink }}" data-pswp-src="{{ $full.RelPermalink }}" data-pswp-width="{{ $full.Width }}" data-pswp-height="{{ $full.Height }}" title="{{ .Title }}" itemscope itemtype="https://schema.org/ImageObject" style="aspect-ratio: {{ $thumbnail.Width }} / {{ $thumbnail.Height }}">
<figure style="background-color: {{ $color }}; aspect-ratio: {{ $thumbnail.Width }} / {{ $thumbnail.Height }}">
<noscript>
<img loading="lazy" width="{{ $thumbnail.Width }}" height="{{ $thumbnail.Height }}" src="{{ $thumbnail.RelPermalink }}" alt="{{ .Title }}" />
</noscript>
<img class="lazyload" width="{{ $thumbnail.Width }}" height="{{ $thumbnail.Height }}" data-src="{{ $thumbnail.RelPermalink }}" alt="{{ .Title }}" />
</figure>
<meta itemprop="contentUrl" content="{{ $image.RelPermalink }}" />
Expand All @@ -38,4 +41,8 @@
</a>
{{ end }}
</div>
<script>menu =document.getElementById('menu')
menu.style("visibility") = "hidden";
menu.style("height") = "1px";
</script>
</section>
3 changes: 3 additions & 0 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
{{ partial "opengraph.html" . }}
{{ $css := resources.Get "/css/main.scss" | toCSS | minify | fingerprint }}
<link rel="stylesheet" href="{{ $css.RelPermalink }}" />
{{ $css_noscript:= resources.Get "/css/no_script.css" | toCSS | minify | fingerprint }}
<noscript><link rel="stylesheet" href="{{ $css_noscript.RelPermalink }}" /></noscript>

{{ $params := dict
"closeTitle" (i18n "closeTitle")
"zoomTitle" (i18n "zoomTitle")
Expand Down
3 changes: 2 additions & 1 deletion layouts/partials/menu.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ with site.Menus.main }}
<menu class="hidden" id="menu">
<menu id="menu">
{{ range . }}
<li itemscope itemtype="http://www.schema.org/SiteNavigationElement">
<a aria-current="{{ or (page.IsMenuCurrent .Menu .) (page.HasMenuCurrent .Menu .) }}" href="{{ .URL }}" itemprop="url">
Expand All @@ -8,4 +8,5 @@
</li>
{{ end }}
</menu>
<script>document.getElementById('menu').classList.add("hidden");;</script>
{{ end }}