nuxt-hero 0.1.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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +212 -0
  3. package/dist/module.d.mts +19 -0
  4. package/dist/module.json +12 -0
  5. package/dist/module.mjs +322 -0
  6. package/dist/runtime/assets/hero.css +1 -0
  7. package/dist/runtime/components/navigation/HeroNavigation.d.vue.ts +18 -0
  8. package/dist/runtime/components/navigation/HeroNavigation.vue +68 -0
  9. package/dist/runtime/components/navigation/HeroNavigation.vue.d.ts +18 -0
  10. package/dist/runtime/components/navigation/HeroPagination.d.vue.ts +22 -0
  11. package/dist/runtime/components/navigation/HeroPagination.vue +50 -0
  12. package/dist/runtime/components/navigation/HeroPagination.vue.d.ts +22 -0
  13. package/dist/runtime/components/slider/HeroSlide.d.vue.ts +66 -0
  14. package/dist/runtime/components/slider/HeroSlide.vue +124 -0
  15. package/dist/runtime/components/slider/HeroSlide.vue.d.ts +66 -0
  16. package/dist/runtime/components/slider/index.d.vue.ts +69 -0
  17. package/dist/runtime/components/slider/index.vue +200 -0
  18. package/dist/runtime/components/slider/index.vue.d.ts +69 -0
  19. package/dist/runtime/components/video/HeroSlideVideo.d.vue.ts +39 -0
  20. package/dist/runtime/components/video/HeroSlideVideo.vue +116 -0
  21. package/dist/runtime/components/video/HeroSlideVideo.vue.d.ts +39 -0
  22. package/dist/runtime/components/video/HeroVideoControls.d.vue.ts +12 -0
  23. package/dist/runtime/components/video/HeroVideoControls.vue +87 -0
  24. package/dist/runtime/components/video/HeroVideoControls.vue.d.ts +12 -0
  25. package/dist/runtime/components/video/HeroVideoScrubber.d.vue.ts +64 -0
  26. package/dist/runtime/components/video/HeroVideoScrubber.vue +50 -0
  27. package/dist/runtime/components/video/HeroVideoScrubber.vue.d.ts +64 -0
  28. package/dist/runtime/composables/_autoplay.d.ts +25 -0
  29. package/dist/runtime/composables/_autoplay.js +72 -0
  30. package/dist/runtime/composables/_gsap.d.ts +60 -0
  31. package/dist/runtime/composables/_gsap.js +135 -0
  32. package/dist/runtime/composables/_hls.d.ts +35 -0
  33. package/dist/runtime/composables/_hls.js +88 -0
  34. package/dist/runtime/composables/_slides.d.ts +26 -0
  35. package/dist/runtime/composables/_slides.js +40 -0
  36. package/dist/runtime/composables/_swiper.d.ts +23 -0
  37. package/dist/runtime/composables/_swiper.js +52 -0
  38. package/dist/runtime/composables/_video.d.ts +30 -0
  39. package/dist/runtime/composables/_video.js +89 -0
  40. package/dist/runtime/composables/useHeroSlider.d.ts +24 -0
  41. package/dist/runtime/composables/useHeroSlider.js +131 -0
  42. package/dist/runtime/hero-swiper-modules.d.ts +4 -0
  43. package/dist/runtime/types.d.ts +221 -0
  44. package/dist/runtime/types.js +0 -0
  45. package/dist/runtime/utils.d.ts +22 -0
  46. package/dist/runtime/utils.js +50 -0
  47. package/dist/types.d.mts +9 -0
  48. package/package.json +94 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-present weskhaled
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,212 @@
1
+ # nuxt-hero
2
+
3
+ A full-featured hero slider Nuxt module with parallax, video backgrounds, overlay patterns, and customizable animations.
4
+
5
+ ## Features
6
+
7
+ - Swiper-based slider with autoplay progress tracking
8
+ - GSAP-powered parallax (background + content)
9
+ - Video backgrounds (MP4, WebM, HLS via hls.js)
10
+ - Overlay patterns (lines, dots, gradient, custom)
11
+ - Dark mode support via `@nuxtjs/color-mode`
12
+ - Built-in + animate.css animations
13
+ - Thumbnail navigation previews
14
+ - Vertical and horizontal layouts
15
+ - `@nuxt/icon` for all icons (Lucide set)
16
+ - Tailwind CSS v4 + DaisyUI v5
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ pnpm add nuxt-hero
22
+ ```
23
+
24
+ Add the module to your `nuxt.config.ts`:
25
+
26
+ ```ts
27
+ export default defineNuxtConfig({
28
+ modules: ['nuxt-hero'],
29
+ })
30
+ ```
31
+
32
+ ### Peer dependencies
33
+
34
+ Required:
35
+
36
+ ```bash
37
+ pnpm add tailwindcss @tailwindcss/vite swiper @vueuse/nuxt
38
+ ```
39
+
40
+ Optional:
41
+
42
+ ```bash
43
+ pnpm add @nuxt/image daisyui hls.js animate.css
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ ```vue
49
+ <script setup>
50
+ const slides = [
51
+ {
52
+ bgSrc: 'https://example.com/photo.jpg',
53
+ bgDarkSrc: 'https://example.com/photo-dark.jpg',
54
+ thumbSrc: 'https://example.com/thumb.jpg',
55
+ title: 'First Slide',
56
+ animation: {
57
+ enter: 'hero-animated hero-slideInUp',
58
+ leave: 'hero-animated hero-slideOutDown',
59
+ },
60
+ },
61
+ {
62
+ bgSrc: 'https://example.com/video.mp4',
63
+ title: 'Video Slide',
64
+ },
65
+ ]
66
+ </script>
67
+
68
+ <template>
69
+ <HeroSlider
70
+ :slides="slides"
71
+ :swiper-options="{ autoplay: { delay: 5000 }, speed: 600 }"
72
+ :parallax="{ bg: true, content: true, speed: 0.5 }"
73
+ :overlay-patterns="[{ type: 'lines', opacity: 0.1 }]"
74
+ class="h-screen"
75
+ >
76
+ <template #slide="{ slide, isActive }">
77
+ <div class="flex size-full items-center justify-center">
78
+ <h1 class="text-5xl font-bold text-white">{{ slide.title }}</h1>
79
+ </div>
80
+ </template>
81
+ </HeroSlider>
82
+ </template>
83
+ ```
84
+
85
+ ## Props
86
+
87
+ ### `HeroSlider`
88
+
89
+ | Prop | Type | Default | Description |
90
+ |------|------|---------|-------------|
91
+ | `slides` | `HeroSlide[]` | required | Array of slide objects |
92
+ | `swiperOptions` | `SwiperOptions` | `{}` | Swiper config pass-through |
93
+ | `enterAnimation` | `string` | `''` | Default enter animation class |
94
+ | `leaveAnimation` | `string` | `''` | Default leave animation class |
95
+ | `overlayPatterns` | `OverlayPattern[]` | `[{ type: 'lines', opacity: 0.1 }]` | Stacked overlay patterns |
96
+ | `parallax` | `boolean \| ParallaxConfig` | `true` | Parallax configuration |
97
+ | `imagePreset` | `string` | `''` | `@nuxt/image` preset name |
98
+ | `as` | `string` | `'div'` | Wrapper element tag |
99
+
100
+ ### `HeroSlide` object
101
+
102
+ | Field | Type | Required | Description |
103
+ |-------|------|----------|-------------|
104
+ | `bgSrc` | `string` | yes | Background image or video URL |
105
+ | `bgDarkSrc` | `string` | no | Dark mode background URL |
106
+ | `thumbSrc` | `string` | no | Thumbnail for navigation preview |
107
+ | `title` | `string` | no | Slide title |
108
+ | `poster` | `string` | no | Poster frame for video backgrounds |
109
+ | `animation` | `{ enter?, leave? }` | no | Per-slide animation override |
110
+
111
+ ### `ParallaxConfig`
112
+
113
+ | Field | Type | Default | Description |
114
+ |-------|------|---------|-------------|
115
+ | `bg` | `boolean` | `true` | Enable background parallax |
116
+ | `content` | `boolean` | `true` | Enable content parallax |
117
+ | `speed` | `number` | `0.125` | Parallax speed multiplier |
118
+ | `minOpacity` | `number` | `0.7` | Minimum content opacity on scroll |
119
+
120
+ ### `OverlayPattern`
121
+
122
+ | Field | Type | Default | Description |
123
+ |-------|------|---------|-------------|
124
+ | `type` | `'lines' \| 'dots' \| 'gradient' \| 'custom'` | required | Pattern type |
125
+ | `opacity` | `number` | `0.15` | Pattern opacity |
126
+ | `color` | `string` | `'black'` | Pattern color |
127
+ | `css` | `string` | — | Custom CSS `background-image` (for `type: 'custom'`) |
128
+
129
+ ## Slots
130
+
131
+ | Slot | Props | Description |
132
+ |------|-------|-------------|
133
+ | `slide` | `{ slide, index, isActive, animationClass }` | Slide content |
134
+ | `pagination` | `{ activeIndex, total, progress, slideTo, vertical }` | Custom pagination |
135
+ | `navigation` | `{ prev, next, activeIndex, slides, vertical }` | Custom navigation |
136
+ | `video-controls` | `{ playing, currentTime, duration, volume, muted, waiting, hls }` | Custom video controls |
137
+
138
+ ## Built-in Animations
139
+
140
+ Use with the `hero-animated` base class:
141
+
142
+ - `hero-fadeIn` / `hero-fadeOut`
143
+ - `hero-slideInUp` / `hero-slideOutDown`
144
+ - `hero-slideInRight` / `hero-slideInLeft`
145
+ - `hero-zoomIn` / `hero-zoomOut`
146
+
147
+ Or use [animate.css](https://animate.style/) classes (install `animate.css` peer dependency).
148
+
149
+ ## Module Options
150
+
151
+ ```ts
152
+ export default defineNuxtConfig({
153
+ hero: {
154
+ prefix: 'Hero', // Component name prefix
155
+ colorMode: true, // Enable @nuxtjs/color-mode
156
+ icon: true, // Enable @nuxt/icon
157
+ defaultVolume: 0, // Default volume for video backgrounds (0-1)
158
+ },
159
+ })
160
+ ```
161
+
162
+ ## Project Structure
163
+
164
+ The module's runtime components are organized by feature domain:
165
+
166
+ ```
167
+ src/runtime/
168
+ components/
169
+ slider/ # Core slider
170
+ index.vue # HeroSlider — main component
171
+ HeroSlide.vue # Individual slide with bg image/video
172
+ video/ # Video playback controls
173
+ HeroVideoControls.vue
174
+ HeroVideoScrubber.vue
175
+ navigation/ # Slide navigation UI
176
+ HeroNavigation.vue
177
+ HeroPagination.vue
178
+ composables/
179
+ useHeroSlider.ts # Core slider state, autoplay, video registration
180
+ useGSAP.ts # Scoped GSAP animations with cleanup
181
+ useHls.ts # HLS video playback
182
+ utils.ts # Shared utilities (video detection, patterns, formatting)
183
+ types.ts # TypeScript interfaces
184
+ ```
185
+
186
+ ## Composables
187
+
188
+ ### `useHeroSlider(containerRef, slides, options?)`
189
+
190
+ Core slider composable — manages Swiper, autoplay progress, hover-pause, and animations.
191
+
192
+ ### `useGSAP(callback?, options?)`
193
+
194
+ Vue composable wrapping `gsap.context()` for safe, scoped GSAP animations with automatic cleanup.
195
+
196
+ ### `useHls(videoEl, src, options?)`
197
+
198
+ HLS video playback composable — dynamically loads hls.js, with Safari native fallback.
199
+
200
+ ## Development
201
+
202
+ ```bash
203
+ pnpm install
204
+ pnpm dev # Start playground
205
+ pnpm test # Run tests
206
+ pnpm build # Build module
207
+ pnpm lint # Lint with oxlint
208
+ ```
209
+
210
+ ## License
211
+
212
+ MIT
@@ -0,0 +1,19 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ import { HeroFeatures } from '../dist/runtime/types.js';
3
+
4
+ interface HeroModuleOptions {
5
+ /** Component name prefix. Default: 'Hero' */
6
+ prefix?: string;
7
+ /** Enable @nuxtjs/color-mode. Default: true */
8
+ colorMode?: boolean;
9
+ /** Enable @nuxt/icon. Default: true */
10
+ icon?: boolean;
11
+ /** Default volume for video backgrounds (0-1). Default: 0 */
12
+ defaultVolume?: number;
13
+ /** Opt-in feature flags. Default: {} (nothing enabled) */
14
+ features?: HeroFeatures;
15
+ }
16
+ declare const _default: _nuxt_schema.NuxtModule<HeroModuleOptions, HeroModuleOptions, false>;
17
+
18
+ export { _default as default };
19
+ export type { HeroModuleOptions };
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "nuxt-hero",
3
+ "configKey": "hero",
4
+ "compatibility": {
5
+ "nuxt": ">=3.0.0"
6
+ },
7
+ "version": "0.1.0",
8
+ "builder": {
9
+ "@nuxt/module-builder": "1.0.2",
10
+ "unbuild": "3.6.1"
11
+ }
12
+ }
@@ -0,0 +1,322 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { defineNuxtModule, createResolver, hasNuxtModule, addComponent, addImports, addTemplate } from '@nuxt/kit';
3
+
4
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
5
+ function normalizeWindowsPath(input = "") {
6
+ if (!input) {
7
+ return input;
8
+ }
9
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
10
+ }
11
+
12
+ const _UNC_REGEX = /^[/\\]{2}/;
13
+ const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
14
+ const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
15
+ const normalize = function(path) {
16
+ if (path.length === 0) {
17
+ return ".";
18
+ }
19
+ path = normalizeWindowsPath(path);
20
+ const isUNCPath = path.match(_UNC_REGEX);
21
+ const isPathAbsolute = isAbsolute(path);
22
+ const trailingSeparator = path[path.length - 1] === "/";
23
+ path = normalizeString(path, !isPathAbsolute);
24
+ if (path.length === 0) {
25
+ if (isPathAbsolute) {
26
+ return "/";
27
+ }
28
+ return trailingSeparator ? "./" : ".";
29
+ }
30
+ if (trailingSeparator) {
31
+ path += "/";
32
+ }
33
+ if (_DRIVE_LETTER_RE.test(path)) {
34
+ path += "/";
35
+ }
36
+ if (isUNCPath) {
37
+ if (!isPathAbsolute) {
38
+ return `//./${path}`;
39
+ }
40
+ return `//${path}`;
41
+ }
42
+ return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
43
+ };
44
+ const join = function(...segments) {
45
+ let path = "";
46
+ for (const seg of segments) {
47
+ if (!seg) {
48
+ continue;
49
+ }
50
+ if (path.length > 0) {
51
+ const pathTrailing = path[path.length - 1] === "/";
52
+ const segLeading = seg[0] === "/";
53
+ const both = pathTrailing && segLeading;
54
+ if (both) {
55
+ path += seg.slice(1);
56
+ } else {
57
+ path += pathTrailing || segLeading ? seg : `/${seg}`;
58
+ }
59
+ } else {
60
+ path += seg;
61
+ }
62
+ }
63
+ return normalize(path);
64
+ };
65
+ function normalizeString(path, allowAboveRoot) {
66
+ let res = "";
67
+ let lastSegmentLength = 0;
68
+ let lastSlash = -1;
69
+ let dots = 0;
70
+ let char = null;
71
+ for (let index = 0; index <= path.length; ++index) {
72
+ if (index < path.length) {
73
+ char = path[index];
74
+ } else if (char === "/") {
75
+ break;
76
+ } else {
77
+ char = "/";
78
+ }
79
+ if (char === "/") {
80
+ if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
81
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
82
+ if (res.length > 2) {
83
+ const lastSlashIndex = res.lastIndexOf("/");
84
+ if (lastSlashIndex === -1) {
85
+ res = "";
86
+ lastSegmentLength = 0;
87
+ } else {
88
+ res = res.slice(0, lastSlashIndex);
89
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
90
+ }
91
+ lastSlash = index;
92
+ dots = 0;
93
+ continue;
94
+ } else if (res.length > 0) {
95
+ res = "";
96
+ lastSegmentLength = 0;
97
+ lastSlash = index;
98
+ dots = 0;
99
+ continue;
100
+ }
101
+ }
102
+ if (allowAboveRoot) {
103
+ res += res.length > 0 ? "/.." : "..";
104
+ lastSegmentLength = 2;
105
+ }
106
+ } else {
107
+ if (res.length > 0) {
108
+ res += `/${path.slice(lastSlash + 1, index)}`;
109
+ } else {
110
+ res = path.slice(lastSlash + 1, index);
111
+ }
112
+ lastSegmentLength = index - lastSlash - 1;
113
+ }
114
+ lastSlash = index;
115
+ dots = 0;
116
+ } else if (char === "." && dots !== -1) {
117
+ ++dots;
118
+ } else {
119
+ dots = -1;
120
+ }
121
+ }
122
+ return res;
123
+ }
124
+ const isAbsolute = function(p) {
125
+ return _IS_ABSOLUTE_RE.test(p);
126
+ };
127
+
128
+ const SWIPER_MODULE_MAP = {
129
+ navigation: { module: "Navigation", css: "swiper/css/navigation" },
130
+ pagination: { module: "Pagination", css: "swiper/css/pagination" },
131
+ mousewheel: { module: "Mousewheel" },
132
+ keyboard: { module: "Keyboard" },
133
+ a11y: { module: "A11y" },
134
+ freeMode: { module: "FreeMode", css: "swiper/css/free-mode" },
135
+ thumbs: { module: "Thumbs", css: "swiper/css/thumbs" },
136
+ grid: { module: "Grid", css: "swiper/css/grid" },
137
+ zoom: { module: "Zoom", css: "swiper/css/zoom" },
138
+ scrollbar: { module: "Scrollbar", css: "swiper/css/scrollbar" },
139
+ controller: { module: "Controller" },
140
+ virtual: { module: "Virtual", css: "swiper/css/virtual" },
141
+ hashNavigation: { module: "HashNavigation" },
142
+ history: { module: "History" },
143
+ swiperParallax: { module: "Parallax" }
144
+ };
145
+ const EFFECT_MAP = {
146
+ fade: { module: "EffectFade", css: "swiper/css/effect-fade" },
147
+ cube: { module: "EffectCube", css: "swiper/css/effect-cube" },
148
+ coverflow: { module: "EffectCoverflow", css: "swiper/css/effect-coverflow" },
149
+ creative: { module: "EffectCreative", css: "swiper/css/effect-creative" },
150
+ cards: { module: "EffectCards", css: "swiper/css/effect-cards" },
151
+ flip: { module: "EffectFlip", css: "swiper/css/effect-flip" }
152
+ };
153
+ const VALID_EFFECTS = ["fade", "cube", "coverflow", "creative", "cards", "flip"];
154
+ const module$1 = defineNuxtModule({
155
+ meta: {
156
+ name: "nuxt-hero",
157
+ configKey: "hero",
158
+ compatibility: { nuxt: ">=3.0.0" }
159
+ },
160
+ defaults: {
161
+ prefix: "Hero",
162
+ colorMode: true,
163
+ icon: true,
164
+ defaultVolume: 0,
165
+ features: {}
166
+ },
167
+ moduleDependencies: (_nuxt) => ({
168
+ "@nuxtjs/color-mode": {
169
+ defaults: {
170
+ classSuffix: "",
171
+ dataValue: "theme"
172
+ }
173
+ },
174
+ "@nuxt/icon": {
175
+ defaults: {
176
+ cssLayer: "base"
177
+ }
178
+ }
179
+ }),
180
+ setup(options, nuxt) {
181
+ const { resolve } = createResolver(import.meta.url);
182
+ const runtimeDir = resolve("./runtime");
183
+ const prefix = options.prefix ?? "Hero";
184
+ const features = { ...options.features };
185
+ if (features.hls && !features.video) {
186
+ console.warn("[nuxt-hero] `hls: true` requires `video: true` \u2014 auto-enabling video.");
187
+ features.video = true;
188
+ }
189
+ if (features.effects) {
190
+ features.effects = features.effects.filter((e) => {
191
+ if (!VALID_EFFECTS.includes(e)) {
192
+ console.warn(`[nuxt-hero] Unknown effect "${e}" \u2014 ignoring. Valid: ${VALID_EFFECTS.join(", ")}`);
193
+ return false;
194
+ }
195
+ return true;
196
+ });
197
+ }
198
+ setupTailwind(nuxt, runtimeDir);
199
+ nuxt.options.css.push("swiper/css");
200
+ nuxt.options.css.push(resolve("./runtime/assets/hero.css"));
201
+ for (const [key, mapping] of Object.entries(SWIPER_MODULE_MAP)) {
202
+ if (features[key] && mapping.css) {
203
+ nuxt.options.css.push(mapping.css);
204
+ }
205
+ }
206
+ if (features.effects) {
207
+ for (const effect of features.effects) {
208
+ nuxt.options.css.push(EFFECT_MAP[effect].css);
209
+ }
210
+ }
211
+ nuxt.options.runtimeConfig.public.hero = {
212
+ hasNuxtImage: hasNuxtModule("@nuxt/image"),
213
+ defaultVolume: options.defaultVolume ?? 0,
214
+ features
215
+ };
216
+ addComponent({ name: `${prefix}Slider`, filePath: resolve("./runtime/components/slider/index.vue") });
217
+ addComponent({ name: `${prefix}Slide`, filePath: resolve("./runtime/components/slider/HeroSlide.vue") });
218
+ if (features.pagination) {
219
+ addComponent({ name: `${prefix}Pagination`, filePath: resolve("./runtime/components/navigation/HeroPagination.vue") });
220
+ }
221
+ if (features.navigation) {
222
+ addComponent({ name: `${prefix}Navigation`, filePath: resolve("./runtime/components/navigation/HeroNavigation.vue") });
223
+ }
224
+ if (features.video) {
225
+ addComponent({ name: `${prefix}VideoControls`, filePath: resolve("./runtime/components/video/HeroVideoControls.vue") });
226
+ addComponent({ name: `${prefix}VideoScrubber`, filePath: resolve("./runtime/components/video/HeroVideoScrubber.vue") });
227
+ addComponent({ name: `${prefix}SlideVideo`, filePath: resolve("./runtime/components/video/HeroSlideVideo.vue") });
228
+ }
229
+ addImports({ name: "useHeroSlider", from: resolve("./runtime/composables/useHeroSlider") });
230
+ nuxt.options.alias["#hero"] = runtimeDir;
231
+ setupVirtualSwiperModules(nuxt, features);
232
+ setupVite(nuxt, runtimeDir, features);
233
+ }
234
+ });
235
+ function setupTailwind(nuxt, runtimeDir) {
236
+ const hostHasTailwind = hasNuxtModule("@nuxt/ui", nuxt);
237
+ if (!hostHasTailwind) {
238
+ const lines = [
239
+ `@import 'tailwindcss';`,
240
+ ``,
241
+ `@custom-variant dark (&:where([data-theme=dark], [data-theme=dark] *));`,
242
+ ``,
243
+ `@source "${runtimeDir}/components";`,
244
+ `@source "${runtimeDir}/assets";`
245
+ ];
246
+ const { dst } = addTemplate({
247
+ filename: "nuxt-hero/tailwind.css",
248
+ write: true,
249
+ getContents: () => lines.join("\n")
250
+ });
251
+ nuxt.options.css.unshift(dst);
252
+ nuxt.hook("vite:extend", async ({ config }) => {
253
+ const plugin = await import('@tailwindcss/vite').then((r) => r.default);
254
+ config.plugins ||= [];
255
+ config.plugins.push(plugin());
256
+ });
257
+ if (nuxt.options.builder !== "@nuxt/vite-builder") {
258
+ nuxt.options.postcss.plugins["@tailwindcss/postcss"] = {};
259
+ }
260
+ } else {
261
+ const { dst } = addTemplate({
262
+ filename: "nuxt-hero/tailwind.css",
263
+ write: true,
264
+ getContents: () => [
265
+ `@source "${runtimeDir}/components";`,
266
+ `@source "${runtimeDir}/assets";`
267
+ ].join("\n")
268
+ });
269
+ nuxt.options.css.push(dst);
270
+ }
271
+ }
272
+ function setupVirtualSwiperModules(nuxt, features) {
273
+ const modules = [];
274
+ for (const [key, mapping] of Object.entries(SWIPER_MODULE_MAP)) {
275
+ if (features[key]) {
276
+ modules.push(mapping.module);
277
+ }
278
+ }
279
+ if (features.effects) {
280
+ for (const effect of features.effects) {
281
+ modules.push(EFFECT_MAP[effect].module);
282
+ }
283
+ }
284
+ const imports = modules.length > 0 ? `import { ${modules.join(", ")} } from 'swiper/modules'` : "";
285
+ const exported = modules.length > 0 ? `export const swiperModules = [${modules.join(", ")}]` : "export const swiperModules = []";
286
+ addTemplate({
287
+ filename: "nuxt-hero/swiper-modules.mjs",
288
+ write: true,
289
+ getContents: () => [imports, exported, ""].join("\n")
290
+ });
291
+ nuxt.options.alias["#hero/swiper-modules"] = nuxt.options.buildDir + "/nuxt-hero/swiper-modules.mjs";
292
+ }
293
+ function setupVite(nuxt, runtimeDir, features) {
294
+ const hostNodeModules = join(nuxt.options.rootDir, "node_modules");
295
+ const sharedDeps = ["@vueuse/core"];
296
+ if (features.parallax) sharedDeps.push("gsap");
297
+ for (const dep of sharedDeps) {
298
+ const hostPath = join(hostNodeModules, dep);
299
+ if (existsSync(hostPath)) {
300
+ nuxt.options.alias[dep] = hostPath;
301
+ }
302
+ }
303
+ nuxt.options.vite.server ??= {};
304
+ nuxt.options.vite.server.watch ??= {};
305
+ nuxt.options.vite.server.watch.ignored ??= [];
306
+ if (Array.isArray(nuxt.options.vite.server.watch.ignored)) {
307
+ nuxt.options.vite.server.watch.ignored.push(`!${runtimeDir}/**`);
308
+ }
309
+ nuxt.options.vite.optimizeDeps ??= {};
310
+ nuxt.options.vite.optimizeDeps.include ??= [];
311
+ nuxt.options.vite.optimizeDeps.include.push("swiper/vue", "@vueuse/core");
312
+ if (features.parallax) {
313
+ nuxt.options.vite.optimizeDeps.include.push("gsap", "gsap/ScrollTrigger");
314
+ }
315
+ const hasAnyModule = Object.keys(SWIPER_MODULE_MAP).some((k) => features[k]) || features.effects && features.effects.length > 0;
316
+ if (hasAnyModule) {
317
+ nuxt.options.vite.optimizeDeps.include.push("swiper/modules");
318
+ }
319
+ nuxt.options.build.transpile.push("swiper");
320
+ }
321
+
322
+ export { module$1 as default };
@@ -0,0 +1 @@
1
+ @reference "tailwindcss";:root{--hero-primary:#fff;--hero-bg:hsla(0,0%,100%,.55);--hero-border:hsla(0,0%,100%,.2);--hero-progress-bg:hsla(0,0%,100%,.65);--hero-nav-bg:rgba(0,0,0,.3);--hero-nav-text:#fff}.hero-slider .hero-nav{@apply min-h-0}.hero-slider .nav-slit-btn{@apply pointer-events-auto absolute z-10 block cursor-pointer outline-none}.hero-slider .nav-slit-btn>span{@apply relative block bg-white/40 ring ring-white backdrop-blur-sm text-black transition-transform duration-300;@apply dark:bg-black/40 dark:ring-black dark:text-white;@apply group-hover:opacity-100}.hero-slider .nav-slit-preview{@apply absolute ring ring-white transition-transform duration-300 delay-300;@apply bg-white dark:bg-black dark:ring-black}.hero-slider .nav-slit-preview h3{@apply absolute m-0 truncate px-2 py-0.5 text-sm font-light capitalize leading-5 backface-hidden transition-transform duration-300;@apply bg-white/70 ring ring-white backdrop-blur-sm text-black;@apply dark:bg-black/70 dark:ring-black dark:text-white}.hero-slider .nav-slit-prev .nav-slit-preview{@apply left-0 -translate-x-full}.hero-slider .nav-slit-prev:hover .nav-slit-preview{@apply left-0 translate-x-0}.hero-slider .nav-slit-next .nav-slit-preview{@apply right-0 translate-x-full text-right}.hero-slider .nav-slit-next:hover .nav-slit-preview{@apply right-0 translate-x-0}.hero-video-btn{@apply shadow-none border-none transition-all duration-200 relative;@apply bg-white/35 backdrop-blur-sm opacity-0 hover:scale-110;@apply dark:bg-black/35;@apply group-hover/slider:opacity-100}.media-controls{@apply pointer-events-auto absolute z-999 bottom-5 left-4 flex items-center gap-1}.swiper-pagination>button>.tooltip-content{@apply pointer-events-none absolute bottom-full mb-1 left-1/2 z-90 w-30 -ml-[60px] cursor-default opacity-0 transition-opacity duration-300 delay-300}.swiper-pagination>button>.tooltip-content:after{@apply pointer-events-none absolute -bottom-2.5 left-1/2 -ml-1.25 size-0 border-5 border-transparent border-t-inherit!;content:""}.swiper-pagination>button>.tooltip-content .tooltip-text{@apply overflow-hidden border-b-2 origin-left scale-x-0 scale-y-100 transition-transform duration-300 delay-300}.swiper-pagination>button>.tooltip-content .tooltip-text .tooltip-inner{@apply max-w-[inherit] rounded-none p-0 translate-y-full transition-transform duration-300}.swiper-pagination>button>.tooltip-content .tooltip-text .tooltip-inner img{@apply opacity-65}.swiper-pagination>button:hover>.tooltip-content{@apply z-99 opacity-100 delay-0}.swiper-pagination>button:hover>.tooltip-content .tooltip-text{@apply scale-x-100 delay-0}.swiper-pagination>button:hover>.tooltip-content .tooltip-text .tooltip-inner{@apply translate-y-0 delay-300}.swiper-pagination .progress-circle-svg{@apply -rotate-90}.swiper-pagination .progress-circle-bar{stroke:var(--hero-primary)}.swiper-pagination .progress-circle-bg{stroke:var(--hero-progress-bg)}.hero-radial-progress{--hero-progress-value:0;--hero-progress-size:1.25rem;--hero-progress-thickness:2px;background:conic-gradient(currentColor calc(var(--hero-progress-value)*1%),transparent 0);border-radius:9999px;display:inline-grid;height:var(--hero-progress-size);-webkit-mask:radial-gradient(farthest-side,transparent calc(100% - var(--hero-progress-thickness)),#000 calc(100% - var(--hero-progress-thickness)));mask:radial-gradient(farthest-side,transparent calc(100% - var(--hero-progress-thickness)),#000 calc(100% - var(--hero-progress-thickness)));place-content:center;width:var(--hero-progress-size)}@keyframes heroSpin{to{transform:rotate(1turn)}}.hero-spinner{animation:heroSpin .6s linear infinite;border-color:currentcolor transparent transparent currentcolor;border-radius:9999px;border-style:solid;border-width:2px;display:inline-block}.hero-spinner-sm{height:1rem;width:1rem}.hero-spinner-md{height:1.25rem;width:1.25rem}.hero-range::-webkit-slider-thumb{@apply appearance-none size-3 rounded-full bg-white cursor-pointer}.hero-range::-moz-range-thumb{@apply size-3 rounded-full bg-white cursor-pointer border-none}.hero-animated{animation-duration:.6s;animation-fill-mode:both}@keyframes heroFadeIn{0%{opacity:0}to{opacity:1}}@keyframes heroFadeOut{0%{opacity:1}to{opacity:0}}@keyframes heroSlideInUp{0%{opacity:0;transform:translateY(30px)}to{opacity:1;transform:translateY(0)}}@keyframes heroSlideOutDown{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(30px)}}@keyframes heroSlideInRight{0%{opacity:0;transform:translateX(30px)}to{opacity:1;transform:translateX(0)}}@keyframes heroSlideInLeft{0%{opacity:0;transform:translateX(-30px)}to{opacity:1;transform:translateX(0)}}@keyframes heroZoomIn{0%{opacity:0;transform:scale(.9)}to{opacity:1;transform:scale(1)}}@keyframes heroZoomOut{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(1.1)}}.hero-fadeIn{animation-name:heroFadeIn}.hero-fadeOut{animation-name:heroFadeOut}.hero-slideInUp{animation-name:heroSlideInUp}.hero-slideOutDown{animation-name:heroSlideOutDown}.hero-slideInRight{animation-name:heroSlideInRight}.hero-slideInLeft{animation-name:heroSlideInLeft}.hero-zoomIn{animation-name:heroZoomIn}.hero-zoomOut{animation-name:heroZoomOut}
@@ -0,0 +1,18 @@
1
+ import type { HeroSlide } from '#hero/types';
2
+ interface NavigationProps {
3
+ slides: HeroSlide[];
4
+ activeIndex: number;
5
+ /** When true, prev is on top and next is on bottom */
6
+ vertical?: boolean;
7
+ }
8
+ declare const __VLS_export: import("vue").DefineComponent<NavigationProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ next: () => any;
10
+ prev: () => any;
11
+ }, string, import("vue").PublicProps, Readonly<NavigationProps> & Readonly<{
12
+ onNext?: (() => any) | undefined;
13
+ onPrev?: (() => any) | undefined;
14
+ }>, {
15
+ vertical: boolean;
16
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: typeof __VLS_export;
18
+ export default _default;
@@ -0,0 +1,68 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ const props = defineProps({
4
+ slides: { type: Array, required: true },
5
+ activeIndex: { type: Number, required: true },
6
+ vertical: { type: Boolean, required: false, default: false }
7
+ });
8
+ const emit = defineEmits(["prev", "next"]);
9
+ const prevSlide = computed(() => {
10
+ const idx = props.activeIndex < 1 ? props.slides.length - 1 : props.activeIndex - 1;
11
+ return props.slides[idx];
12
+ });
13
+ const nextSlide = computed(() => {
14
+ const idx = props.activeIndex + 1 >= props.slides.length ? 0 : props.activeIndex + 1;
15
+ return props.slides[idx];
16
+ });
17
+ const prevHoverClass = computed(
18
+ () => props.vertical ? "px-10 py-1 group-hover:-translate-y-full" : `py-10 px-1 ${prevSlide.value?.thumbSrc ? "group-hover:-translate-x-full" : "group-hover:-translate-x-1/10"}`
19
+ );
20
+ const nextHoverClass = computed(
21
+ () => props.vertical ? "px-10 py-1 group-hover:translate-y-full" : `py-10 px-1 ${nextSlide.value?.thumbSrc ? "group-hover:translate-x-full" : "group-hover:translate-x-1/10"}`
22
+ );
23
+ </script>
24
+
25
+ <template>
26
+ <nav class="hero-nav nav-slit" :class="{ 'nav-slit--vertical': vertical }">
27
+ <!--
28
+ Horizontal: prev=left, next=right
29
+ Vertical: prev=top, next=bottom
30
+ -->
31
+
32
+ <!-- Prev -->
33
+ <button type="button" aria-label="Previous slide" class="nav-slit-btn nav-slit-prev group"
34
+ :class="vertical ? 'top-0 left-1/2 -translate-x-1/2' : 'left-0 top-1/2 -translate-y-1/2'" @click="emit('prev')">
35
+ <span :class="prevHoverClass">
36
+ <Icon :name="vertical ? 'lucide:chevron-up' : 'lucide:chevron-left'" class="block text-base" />
37
+ </span>
38
+ <div v-if="prevSlide?.thumbSrc" class="nav-slit-preview"
39
+ :class="vertical ? 'top-0 left-0 w-full h-24 -translate-y-full' : 'left-0 top-0 h-full w-36 -translate-x-full'">
40
+ <h3 :class="vertical ? 'bottom-0 left-0 w-full origin-bottom scale-y-0' : 'top-full w-full origin-top -rotate-x-90'">
41
+ {{ prevSlide?.title }}
42
+ </h3>
43
+ <img :src="prevSlide.thumbSrc" :alt="prevSlide?.title ?? 'Previous'"
44
+ class="absolute inset-0 size-full object-cover" loading="lazy" />
45
+ </div>
46
+ </button>
47
+
48
+ <!-- Next -->
49
+ <button type="button" aria-label="Next slide" class="nav-slit-btn nav-slit-next group"
50
+ :class="vertical ? 'bottom-0 left-1/2 -translate-x-1/2' : 'right-0 top-1/2 -translate-y-1/2 text-right'" @click="emit('next')">
51
+ <span :class="nextHoverClass">
52
+ <Icon :name="vertical ? 'lucide:chevron-down' : 'lucide:chevron-right'" class="block text-base" />
53
+ </span>
54
+ <div v-if="nextSlide?.thumbSrc" class="nav-slit-preview"
55
+ :class="vertical ? 'bottom-0 left-0 w-full h-24 translate-y-full' : 'right-0 top-0 h-full w-36 translate-x-full'">
56
+ <h3 :class="vertical ? 'top-0 left-0 w-full origin-top scale-y-0' : 'top-full text-left w-full origin-top -rotate-x-90'">
57
+ {{ nextSlide?.title }}
58
+ </h3>
59
+ <img :src="nextSlide.thumbSrc" :alt="nextSlide?.title ?? 'Next'" class="absolute inset-0 size-full object-cover"
60
+ loading="lazy" />
61
+ </div>
62
+ </button>
63
+ </nav>
64
+ </template>
65
+
66
+ <style scoped>
67
+ .nav-slit-btn:hover .nav-slit-preview{transform:translate(0)}.nav-slit-btn:hover h3{transform:rotateX(0deg) scaleY(1);transition-delay:.6s}.nav-slit--vertical .nav-slit-prev:hover .hero-icon{transform:translateY(-150%);transition-delay:0s}.nav-slit--vertical .nav-slit-next:hover .hero-icon{transform:translateY(150%);transition-delay:0s}
68
+ </style>