summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-07-21 14:22:08 +0200
committerLibravatar GitHub <noreply@github.com>2024-07-21 14:22:08 +0200
commit027a93facc73b78e3c3747ab796f4a14b1b4936f (patch)
tree51838cd9fdf607ad46fdfa77a9424fdd8f5cd98d /web
parent[bugfix] update common get target account / status doing refresh async (#3124) (diff)
downloadgotosocial-027a93facc73b78e3c3747ab796f4a14b1b4936f.tar.xz
[feature/frontend] Respect `prefers-reduced-motion` for avatars, headers, and emojis (#3118)
* [feature/frontend] Respect `prefers-reduced-motion` for avatars, headers, and emojis * go fmt * fix tests * use static version of instance thumbnail when appropriate * use prefers-reduced-motion * simplify account conversion a bit * fix c&p error
Diffstat (limited to 'web')
-rw-r--r--web/source/css/base.css26
-rw-r--r--web/source/css/index.css3
-rw-r--r--web/source/css/page.css3
-rw-r--r--web/source/css/status.css8
-rw-r--r--web/template/page.tmpl2
-rw-r--r--web/template/page_header.tmpl19
-rw-r--r--web/template/profile.tmpl47
-rw-r--r--web/template/status_header.tmpl18
8 files changed, 81 insertions, 45 deletions
diff --git a/web/source/css/base.css b/web/source/css/base.css
index 522820f15..630e4a6d2 100644
--- a/web/source/css/base.css
+++ b/web/source/css/base.css
@@ -187,18 +187,20 @@ input, select, textarea, .input {
margin: -0.2em 0.02em 0;
object-fit: contain;
vertical-align: middle;
- transition: 0.1s;
-
- /*
- Enlarge emojis on hover to give
- viewer a good look at them.
- */
- &:hover, &:active {
- transform: scale(2);
- background-color: $bg;
- box-shadow: $boxshadow;
- border: $boxshadow-border;
- border-radius: $br-inner;
+
+ @media (prefers-reduced-motion: no-preference) {
+ /*
+ Enlarge emojis on hover to give
+ viewer a good look at them.
+ */
+ transition: 0.1s;
+ &:hover, &:active {
+ transform: scale(2);
+ background-color: $bg;
+ box-shadow: $boxshadow;
+ border: $boxshadow-border;
+ border-radius: $br-inner;
+ }
}
}
diff --git a/web/source/css/index.css b/web/source/css/index.css
index 59909ec33..382cd68c6 100644
--- a/web/source/css/index.css
+++ b/web/source/css/index.css
@@ -30,7 +30,8 @@
line-height: 2rem;
}
- & > img {
+ img,
+ picture {
align-self: center;
max-height: 6rem;
}
diff --git a/web/source/css/page.css b/web/source/css/page.css
index cc1d4efe3..642586048 100644
--- a/web/source/css/page.css
+++ b/web/source/css/page.css
@@ -48,7 +48,8 @@
gap: 1rem;
justify-content: center;
- img {
+ img,
+ picture {
align-self: center;
/*
diff --git a/web/source/css/status.css b/web/source/css/status.css
index 5c7400654..21dc3416e 100644
--- a/web/source/css/status.css
+++ b/web/source/css/status.css
@@ -193,14 +193,6 @@ main {
font-size: 1rem;
line-height: initial;
}
-
- img {
- max-width: 100%;
- margin: 5px auto;
- }
- img[alt~="!center"] {
- display: block;
- }
}
.poll {
diff --git a/web/template/page.tmpl b/web/template/page.tmpl
index 347caf33e..d2edc5277 100644
--- a/web/template/page.tmpl
+++ b/web/template/page.tmpl
@@ -29,7 +29,7 @@
{{- if .instance.ThumbnailType -}}
{{- .instance.ThumbnailType -}}
{{- else -}}
-image/png
+image/webp
{{- end -}}
{{- end -}}
diff --git a/web/template/page_header.tmpl b/web/template/page_header.tmpl
index e605b349f..388587aaf 100644
--- a/web/template/page_header.tmpl
+++ b/web/template/page_header.tmpl
@@ -57,11 +57,20 @@ Instance Logo
{{- with . }}
<a aria-label="{{- .instance.Title -}}. Go to instance homepage" href="/" class="nounderline">
- <img
- src="{{- .instance.Thumbnail -}}"
- alt="{{- template "thumbnailDescription" . -}}"
- title="{{- template "thumbnailDescription" . -}}"
- />
+ <picture>
+ {{- if .instance.ThumbnailStatic }}
+ <source
+ srcset="{{- .instance.ThumbnailStatic -}}"
+ type="{{- .instance.ThumbnailStaticType -}}"
+ media="(prefers-reduced-motion: reduce)"
+ />
+ {{- end }}
+ <img
+ src="{{- .instance.Thumbnail -}}"
+ alt="{{- template "thumbnailDescription" . -}}"
+ title="{{- template "thumbnailDescription" . -}}"
+ />
+ </picture>
<h1>{{- .instance.Title -}}</h1>
</a>
{{- if .showStrap }}
diff --git a/web/template/profile.tmpl b/web/template/profile.tmpl
index 256bbdccf..a06c842ab 100644
--- a/web/template/profile.tmpl
+++ b/web/template/profile.tmpl
@@ -94,14 +94,26 @@
alt="{{- template "avatarAlt" . -}}"
title="{{- template "avatarAlt" . -}}"
>
- <img
- class="avatar"
- src="{{- .account.Avatar -}}"
- alt="{{- template "avatarAlt" . -}}"
- title="{{- template "avatarAlt" . -}}"
- width="{{- template "avatarWidth" . -}}"
- height="{{- template "avatarHeight" . -}}"
- />
+ <picture
+ aria-hidden="true"
+ >
+ {{- if .account.AvatarAttachment }}
+ <source
+ class="avatar"
+ srcset="{{- .account.AvatarStatic -}}"
+ type="{{- .account.AvatarAttachment.PreviewMIMEType -}}"
+ media="(prefers-reduced-motion: reduce)"
+ />
+ {{- end }}
+ <img
+ class="avatar"
+ src="{{- .account.Avatar -}}"
+ alt="{{- template "avatarAlt" . -}}"
+ title="{{- template "avatarAlt" . -}}"
+ width="{{- template "avatarWidth" . -}}"
+ height="{{- template "avatarHeight" . -}}"
+ />
+ </picture>
</a>
</div>
{{- end }}
@@ -115,11 +127,20 @@
{{- include "profileMovedTo" . | indent 2 }}
{{- end }}
<div class="header-image-wrapper">
- <img
- src="{{- .account.Header -}}"
- alt="{{- template "headerAlt" . -}}"
- title="{{- template "headerAlt" . -}}"
- />
+ <picture>
+ {{- if .account.HeaderAttachment }}
+ <source
+ srcset="{{- .account.HeaderStatic -}}"
+ type="{{- .account.HeaderAttachment.PreviewMIMEType -}}"
+ media="(prefers-reduced-motion: reduce)"
+ />
+ {{- end }}
+ <img
+ src="{{- .account.Header -}}"
+ alt="{{- template "headerAlt" . -}}"
+ title="{{- template "headerAlt" . -}}"
+ />
+ </picture>
</div>
<div class="basic-info">
{{- with . }}
diff --git a/web/template/status_header.tmpl b/web/template/status_header.tmpl
index 8946a1030..01b73aea0 100644
--- a/web/template/status_header.tmpl
+++ b/web/template/status_header.tmpl
@@ -32,13 +32,23 @@
title="Open remote profile (opens in a new window)"
>
{{- end }}
- <img
+ <picture
class="avatar"
aria-hidden="true"
- src="{{- .Avatar -}}"
- alt="Avatar for {{ .Username -}}"
- title="Avatar for {{ .Username -}}"
>
+ {{- if .AvatarAttachment }}
+ <source
+ srcset="{{- .AvatarStatic -}}"
+ type="{{- .AvatarAttachment.PreviewMIMEType -}}"
+ media="(prefers-reduced-motion: reduce)"
+ />
+ {{- end }}
+ <img
+ src="{{- .Avatar -}}"
+ alt="Avatar for {{ .Username -}}"
+ title="Avatar for {{ .Username -}}"
+ >
+ </picture>
<div class="author-strap">
<span class="displayname text-cutoff">
{{- if .DisplayName -}}