@q2devel/q2-storybook 1.0.133 → 1.0.134
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.
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
interface MediaItem {
|
|
2
2
|
url: string;
|
|
3
3
|
type: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
description?: string;
|
|
4
6
|
}
|
|
5
7
|
interface MediaSliderProps {
|
|
6
8
|
media: MediaItem[];
|
|
7
9
|
interval?: number;
|
|
10
|
+
overlayClassName?: string;
|
|
11
|
+
titleClassName?: string;
|
|
12
|
+
descriptionClassName?: string;
|
|
8
13
|
}
|
|
9
|
-
export default function MediaSlider({ media, interval }: MediaSliderProps): import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
+
export default function MediaSlider({ media, interval, overlayClassName, titleClassName, descriptionClassName, }: MediaSliderProps): import("react/jsx-runtime").JSX.Element | null;
|
|
10
15
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import Image from
|
|
4
|
-
import { useEffect,
|
|
5
|
-
export default function MediaSlider({ media, interval = 5000 }) {
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import Image from 'next/image';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
export default function MediaSlider({ media, interval = 5000, overlayClassName = '', titleClassName = '', descriptionClassName = '', }) {
|
|
6
6
|
const [currentSlide, setCurrentSlide] = useState(0);
|
|
7
7
|
const intervalRef = useRef(null);
|
|
8
8
|
useEffect(() => {
|
|
@@ -26,16 +26,23 @@ export default function MediaSlider({ media, interval = 5000 }) {
|
|
|
26
26
|
}
|
|
27
27
|
const renderMediaItem = (item, index) => {
|
|
28
28
|
const isActive = index === currentSlide;
|
|
29
|
+
let mediaElement;
|
|
29
30
|
switch (item.type) {
|
|
30
31
|
case 'image':
|
|
31
|
-
|
|
32
|
+
mediaElement = (_jsx(Image, { src: process.env.NEXT_PUBLIC_DRUPAL_URL + item.url, alt: `Banner ${index + 1}`, width: 1200, height: 800, className: `absolute top-0 left-0 w-full h-full object-cover transition-opacity duration-1000 ${isActive ? 'opacity-100' : 'opacity-0'}`, priority: index === 0 }, index));
|
|
33
|
+
break;
|
|
32
34
|
case 'video':
|
|
33
|
-
|
|
35
|
+
mediaElement = (_jsx("video", { src: process.env.NEXT_PUBLIC_DRUPAL_URL + item.url, autoPlay: true, loop: true, muted: true, playsInline: true, className: `absolute top-0 left-0 w-full h-full object-cover transition-opacity duration-1000 ${isActive ? 'opacity-100' : 'opacity-0'}` }, index));
|
|
36
|
+
break;
|
|
34
37
|
case 'remote_video':
|
|
35
|
-
|
|
38
|
+
mediaElement = (_jsx("iframe", { src: `${item.url
|
|
39
|
+
.replace('watch?v=', 'embed/')
|
|
40
|
+
.replace('youtu.be', 'youtube.com/embed/')}?autoplay=1&mute=1&controls=0`, allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture", allowFullScreen: true, className: `absolute top-0 left-0 w-full h-full transition-opacity duration-1000 ${isActive ? 'opacity-100' : 'opacity-0'}` }, index));
|
|
41
|
+
break;
|
|
36
42
|
default:
|
|
37
43
|
return null;
|
|
38
44
|
}
|
|
45
|
+
return (_jsxs("div", { children: [mediaElement, (item.title || item.description) && (_jsx("div", { className: `absolute inset-0 bg-black/30 flex items-center justify-center transition-opacity duration-1000 ${isActive ? 'opacity-100' : 'opacity-0'} ${overlayClassName}`, children: _jsxs("div", { className: "text-center text-white p-4", children: [item.title && (_jsx("h2", { className: `text-4xl font-bold mb-4 ${titleClassName}`, children: item.title })), item.description && (_jsx("p", { className: `text-lg ${descriptionClassName}`, children: item.description }))] }) }))] }, `slide-${index}`));
|
|
39
46
|
};
|
|
40
47
|
return (_jsx("div", { className: "relative w-full h-full", children: media.map((item, index) => renderMediaItem(item, index)) }));
|
|
41
48
|
}
|