@netlify/spark-ui 1.22.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/spark-ui",
3
3
  "description": "Assets, design tokens, components, and utilities",
4
- "version": "1.22.0",
4
+ "version": "1.23.0",
5
5
  "type": "module",
6
6
  "main": "dist/components/preact/index.js",
7
7
  "types": "dist/components/preact/index.d.ts",
@@ -7,16 +7,42 @@ interface Props {
7
7
  poster?: string;
8
8
  params?: string;
9
9
  class?: string;
10
+ previewVideo?: string;
11
+ previewVideoWebm?: string;
10
12
  }
11
13
 
12
- const { id, title, poster, params, class: className, ...rest } = Astro.props;
14
+ const {
15
+ id,
16
+ title,
17
+ poster,
18
+ params,
19
+ class: className,
20
+ previewVideo,
21
+ previewVideoWebm,
22
+ ...rest
23
+ } = Astro.props;
24
+
25
+ const hasPreviewVideo = previewVideo || previewVideoWebm;
13
26
  ---
14
27
 
15
28
  <div class:list={['n-youtube-video', className]} {...rest}>
16
29
  <YouTube {id} {title} {poster} {params} />
30
+ {
31
+ hasPreviewVideo && (
32
+ <div class="n-youtube-video__bg-video">
33
+ <video autoplay muted loop playsinline>
34
+ {previewVideoWebm && <source src={previewVideoWebm} type="video/webm" />}
35
+ {previewVideo && <source src={previewVideo} type="video/mp4" />}
36
+ </video>
37
+ </div>
38
+ )
39
+ }
40
+ <div class="n-youtube-video__play-icon" aria-hidden="true" />
17
41
  </div>
18
42
 
19
43
  <style>
44
+ /* ── Container ──────────────────────────────────────────────────────── */
45
+
20
46
  .n-youtube-video {
21
47
  position: relative;
22
48
  border-radius: var(--ntl-radius-xl);
@@ -29,36 +55,45 @@ const { id, title, poster, params, class: className, ...rest } = Astro.props;
29
55
  max-width: 100%;
30
56
  }
31
57
 
32
- /* Suppress the default YouTube SVG icon */
58
+ /* Suppress the default lite-youtube play button — we render our own */
33
59
  .n-youtube-video :global(.lyt-playbtn) {
34
- background-image: none;
60
+ display: none;
35
61
  }
36
62
 
37
- /* Circle background */
38
- .n-youtube-video :global(.lyt-playbtn)::after {
39
- content: '';
63
+ /* ── Play button ────────────────────────────────────────────────────── */
64
+
65
+ .n-youtube-video__play-icon {
40
66
  position: absolute;
41
67
  top: 50%;
42
68
  left: 50%;
43
69
  transform: translate(-50%, -50%);
44
- z-index: 1;
70
+ z-index: 2;
45
71
  width: 4rem;
46
72
  height: 4rem;
73
+ pointer-events: none;
74
+ }
75
+
76
+ .n-youtube-video__play-icon::after {
77
+ content: '';
78
+ position: absolute;
79
+ inset: 0;
47
80
  border-radius: 50%;
48
81
  background-color: var(--n-youtube-video-btn-bg, var(--ntl-neutral-800));
49
82
  opacity: 0.5;
50
83
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
51
- pointer-events: none;
84
+ transition:
85
+ background-color 300ms ease,
86
+ box-shadow 300ms ease,
87
+ opacity 300ms ease;
52
88
  }
53
89
 
54
- /* Play icon — mask-image lets background-color be CSS-variable-driven */
55
- .n-youtube-video :global(.lyt-playbtn)::before {
90
+ .n-youtube-video__play-icon::before {
56
91
  content: '';
57
92
  position: absolute;
58
93
  top: 50%;
59
94
  left: 50%;
60
95
  transform: translate(-50%, calc(-50% + 1px));
61
- z-index: 2;
96
+ z-index: 1;
62
97
  width: 2rem;
63
98
  height: 2rem;
64
99
  background-color: var(--n-youtube-video-icon-color, var(--ntl-neutral-000));
@@ -66,6 +101,41 @@ const { id, title, poster, params, class: className, ...rest } = Astro.props;
66
101
  mask-repeat: no-repeat;
67
102
  mask-position: center;
68
103
  mask-size: contain;
104
+ }
105
+
106
+ .n-youtube-video:has(lite-youtube:hover) .n-youtube-video__play-icon::after {
107
+ background-color: var(--n-youtube-video-btn-bg-hover, var(--ntl-teal-400, #00c2b0));
108
+ opacity: 0.9;
109
+ box-shadow: 0 0 24px var(--n-youtube-video-btn-bg-hover, var(--ntl-teal-400, #00c2b0));
110
+ }
111
+
112
+ .n-youtube-video:has(lite-youtube.lyt-activated) .n-youtube-video__play-icon {
113
+ display: none;
114
+ }
115
+
116
+ /* ── Preview video overlay ──────────────────────────────────────────── */
117
+
118
+ .n-youtube-video__bg-video {
119
+ position: absolute;
120
+ inset: 0;
121
+ z-index: 1;
69
122
  pointer-events: none;
123
+ transition: opacity 300ms ease-in-out;
124
+ }
125
+
126
+ .n-youtube-video__bg-video video {
127
+ width: 100%;
128
+ height: 100%;
129
+ object-fit: cover;
130
+ }
131
+
132
+ .n-youtube-video:has(lite-youtube.lyt-activated) .n-youtube-video__bg-video {
133
+ opacity: 0;
134
+ }
135
+
136
+ @media (prefers-reduced-motion: reduce) {
137
+ .n-youtube-video__bg-video {
138
+ display: none;
139
+ }
70
140
  }
71
141
  </style>