fix: track card hover
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
{{/* Track Card Component */}}
|
{{/* Track Card Component */}}
|
||||||
<article class="track-card rounded-lg overflow-hidden group grayscale hover:grayscale-0">
|
{{- $hasVideo := .Resources.GetMatch "preview.*" -}}
|
||||||
|
<article
|
||||||
|
class="track-card rounded-lg overflow-hidden group transition-all duration-300"
|
||||||
|
:class="hovering ? '' : 'grayscale'"
|
||||||
|
x-data="{ hovering: false }"
|
||||||
|
@mouseenter="hovering = true; $refs.video?.play().catch(() => {})"
|
||||||
|
@mouseleave="hovering = false; if ($refs.video) { $refs.video.pause(); $refs.video.currentTime = 0; }"
|
||||||
|
>
|
||||||
{{/* Cover Image/Video */}}
|
{{/* Cover Image/Video */}}
|
||||||
<a href="{{ .Permalink }}" class="block relative aspect-square overflow-hidden">
|
<a href="{{ .Permalink }}" class="block relative aspect-square overflow-hidden">
|
||||||
{{- with .Resources.GetMatch "cover.*" }}
|
{{- with .Resources.GetMatch "cover.*" }}
|
||||||
@@ -7,7 +14,8 @@
|
|||||||
<img
|
<img
|
||||||
src="{{ $img.RelPermalink }}"
|
src="{{ $img.RelPermalink }}"
|
||||||
alt="{{ $.Title }}"
|
alt="{{ $.Title }}"
|
||||||
class="track-card__cover w-full h-full"
|
class="track-card__cover w-full h-full object-cover"
|
||||||
|
:class="{ 'opacity-0': hovering && $refs.video }"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
decoding="async"
|
decoding="async"
|
||||||
>
|
>
|
||||||
@@ -22,18 +30,19 @@
|
|||||||
{{/* Video preview on hover */}}
|
{{/* Video preview on hover */}}
|
||||||
{{- with .Resources.GetMatch "preview.*" }}
|
{{- with .Resources.GetMatch "preview.*" }}
|
||||||
<video
|
<video
|
||||||
|
x-ref="video"
|
||||||
src="{{ .RelPermalink }}"
|
src="{{ .RelPermalink }}"
|
||||||
class="absolute inset-0 w-full h-full object-cover opacity-0 group-hover:opacity-100 transition-opacity duration-300"
|
class="absolute inset-0 w-full h-full object-cover transition-opacity duration-300"
|
||||||
|
:class="hovering ? 'opacity-100' : 'opacity-0'"
|
||||||
muted
|
muted
|
||||||
loop
|
loop
|
||||||
playsinline
|
playsinline
|
||||||
onmouseenter="this.play()"
|
preload="metadata"
|
||||||
onmouseleave="this.pause(); this.currentTime=0;"
|
|
||||||
></video>
|
></video>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{/* Play overlay - hide if video exists */}}
|
{{/* Play overlay - only show if NO video exists */}}
|
||||||
{{- if not (.Resources.GetMatch "preview.*") }}
|
{{- if not $hasVideo }}
|
||||||
<div class="absolute inset-0 bg-surface-0/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center">
|
<div class="absolute inset-0 bg-surface-0/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center">
|
||||||
<div class="w-14 h-14 rounded-full bg-accent flex items-center justify-center transform scale-90 group-hover:scale-100 transition-transform">
|
<div class="w-14 h-14 rounded-full bg-accent flex items-center justify-center transform scale-90 group-hover:scale-100 transition-transform">
|
||||||
<svg class="w-6 h-6 text-surface-0 ml-1" fill="currentColor" viewBox="0 0 24 24">
|
<svg class="w-6 h-6 text-surface-0 ml-1" fill="currentColor" viewBox="0 0 24 24">
|
||||||
|
|||||||
Reference in New Issue
Block a user