@q2devel/q2-storybook 1.0.133 → 1.0.135

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,16 @@
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;
13
+ baseUrl?: string;
8
14
  }
9
- export default function MediaSlider({ media, interval }: MediaSliderProps): import("react/jsx-runtime").JSX.Element | null;
15
+ export default function MediaSlider({ media, interval, overlayClassName, titleClassName, descriptionClassName, baseUrl, }: MediaSliderProps): import("react/jsx-runtime").JSX.Element | null;
10
16
  export {};
@@ -1,10 +1,28 @@
1
- "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import Image from "next/image";
4
- import { useEffect, useState, useRef } from "react";
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 = '', baseUrl, }) {
6
6
  const [currentSlide, setCurrentSlide] = useState(0);
7
7
  const intervalRef = useRef(null);
8
+ // Helper function to construct media URL
9
+ const getMediaUrl = (url) => {
10
+ // If URL is already absolute (starts with http/https), return as is
11
+ if (url.startsWith('http://') || url.startsWith('https://')) {
12
+ return url;
13
+ }
14
+ // If baseUrl prop is provided, use it
15
+ if (baseUrl) {
16
+ return baseUrl + url;
17
+ }
18
+ // If NEXT_PUBLIC_DRUPAL_URL exists, use it (for Drupal compatibility)
19
+ if (process.env.NEXT_PUBLIC_DRUPAL_URL) {
20
+ return process.env.NEXT_PUBLIC_DRUPAL_URL + url;
21
+ }
22
+ // Otherwise, assume it's a relative URL that should work with Next.js
23
+ // Ensure it starts with /
24
+ return url.startsWith('/') ? url : `/${url}`;
25
+ };
8
26
  useEffect(() => {
9
27
  // Clear any existing interval
10
28
  if (intervalRef.current) {
@@ -26,16 +44,24 @@ export default function MediaSlider({ media, interval = 5000 }) {
26
44
  }
27
45
  const renderMediaItem = (item, index) => {
28
46
  const isActive = index === currentSlide;
47
+ const mediaUrl = getMediaUrl(item.url);
48
+ let mediaElement;
29
49
  switch (item.type) {
30
50
  case 'image':
31
- return (_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));
51
+ mediaElement = (_jsx(Image, { src: mediaUrl, alt: item.title || `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));
52
+ break;
32
53
  case 'video':
33
- return (_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));
54
+ mediaElement = (_jsx("video", { src: mediaUrl, 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));
55
+ break;
34
56
  case 'remote_video':
35
- return (_jsx("iframe", { src: `${item.url.replace('watch?v=', 'embed/').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));
57
+ mediaElement = (_jsx("iframe", { src: `${item.url
58
+ .replace('watch?v=', 'embed/')
59
+ .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));
60
+ break;
36
61
  default:
37
62
  return null;
38
63
  }
64
+ 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
65
  };
40
66
  return (_jsx("div", { className: "relative w-full h-full", children: media.map((item, index) => renderMediaItem(item, index)) }));
41
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@q2devel/q2-storybook",
3
- "version": "1.0.133",
3
+ "version": "1.0.135",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",