web/Skeleton: add elevated skeleton and use it for picker item

- fixed bg not being visible when shimmer is not on the element in dark theme
- fixed stuck gradient when motion is reduced
- fixed big skeleton
- skeleton is no longer focusable
This commit is contained in:
wukko 2024-07-23 09:55:55 +06:00
parent 718dc4cf0a
commit 7ee99ad30f
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2
3 changed files with 36 additions and 11 deletions

View file

@ -44,7 +44,7 @@
alt="{$t(`a11y.dialog.picker.item.${itemType}`)} {number}" alt="{$t(`a11y.dialog.picker.item.${itemType}`)} {number}"
/> />
<Skeleton class="picker-image" hidden={imageLoaded} /> <Skeleton class="picker-image elevated" hidden={imageLoaded} />
</button> </button>
<style> <style>
@ -72,17 +72,17 @@
display: none; display: none;
} }
.picker-item:active .picker-image {
opacity: 0.8;
}
.picker-image.video-thumbnail { .picker-image.video-thumbnail {
pointer-events: none; pointer-events: none;
} }
:global(.picker-item:active .picker-image) {
opacity: 0.7;
}
@media (hover: hover) { @media (hover: hover) {
.picker-item:hover .picker-image { :global(.picker-item:hover .picker-image) {
opacity: 0.8; opacity: 0.7;
} }
} }

View file

@ -36,15 +36,25 @@
line-height: 1; line-height: 1;
font-size: 1em; font-size: 1em;
text-align: center; text-align: center;
pointer-events: none;
} }
:global([data-theme=light]) .skeleton { :global([data-theme=light]) .skeleton {
background-color: var(--button-hover); background-color: var(--button-hover);
} }
.skeleton.elevated {
background-image: var(--skeleton-gradient-elevated);
background-color: var(--button-elevated);
}
:global([data-reduce-motion="true"]) .skeleton {
background-image: none;
}
.skeleton.big { .skeleton.big {
border-radius: var(--border-radius); border-radius: var(--border-radius);
background-size: 700px 100%; background-size: 400px 100%;
animation: skeleton-big 1.2s ease-in-out infinite; animation: skeleton-big 1.2s ease-in-out infinite;
} }
@ -59,10 +69,10 @@
@keyframes skeleton-big { @keyframes skeleton-big {
0% { 0% {
background-position: -700px 0; background-position: -400px 0;
} }
100% { 100% {
background-position: calc(700px + 100%) 0; background-position: calc(400px + 100%) 0;
} }
} }
</style> </style>

View file

@ -76,6 +76,7 @@
--button-elevated: #e3e3e3; --button-elevated: #e3e3e3;
--button-elevated-hover: #dadada; --button-elevated-hover: #dadada;
--button-elevated-shimmer: #ededed;
--popup-bg: #f1f1f1; --popup-bg: #f1f1f1;
--popup-stroke: rgba(0, 0, 0, 0.08); --popup-stroke: rgba(0, 0, 0, 0.08);
@ -123,6 +124,13 @@
var(--button), var(--button),
var(--button-hover) var(--button-hover)
); );
--skeleton-gradient-elevated: linear-gradient(
90deg,
var(--button-elevated),
var(--button-elevated-shimmer),
var(--button-elevated)
);
} }
:global([data-theme="dark"]) { :global([data-theme="dark"]) {
@ -143,7 +151,7 @@
--button-box-shadow: 0 0 0 1.5px var(--button-stroke) inset; --button-box-shadow: 0 0 0 1.5px var(--button-stroke) inset;
--button-elevated: #282828; --button-elevated: #282828;
--button-elevated-hover: #2f2f2f; --button-elevated-hover: #323232;
--popup-bg: #191919; --popup-bg: #191919;
--popup-stroke: rgba(255, 255, 255, 0.08); --popup-stroke: rgba(255, 255, 255, 0.08);
@ -173,6 +181,13 @@
var(--button-hover), var(--button-hover),
var(--button) var(--button)
); );
--skeleton-gradient-elevated: linear-gradient(
90deg,
var(--button-elevated),
var(--button-elevated-hover),
var(--button-elevated)
);
} }
:global([data-theme="light"] [data-reduce-transparency="true"]) { :global([data-theme="light"] [data-reduce-transparency="true"]) {