@q2devel/q2-storybook 1.0.8 → 1.0.9

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,3 +1,4 @@
1
+ 'use client';
1
2
  import React from 'react';
2
3
  var Badge = function (_a) {
3
4
  var children = _a.children, onClick = _a.onClick, _b = _a.color, color = _b === void 0 ? 'bg-blue-100 text-blue-800' : _b, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.labelClassName, labelClassName = _d === void 0 ? '' : _d, rightIcon = _a.rightIcon;
@@ -0,0 +1,48 @@
1
+ import React, { ReactNode } from 'react';
2
+ export type BannerItem = {
3
+ id: string;
4
+ imageSrc: string;
5
+ imageAlt?: string;
6
+ title: string;
7
+ subtitle: string;
8
+ buttonText?: string;
9
+ buttonLink?: string;
10
+ customContent?: ReactNode;
11
+ overlayOpacity?: number;
12
+ buttonVariant?: 'primary' | 'secondary' | 'ghost' | 'outline';
13
+ buttonSize?: 'sm' | 'md' | 'lg';
14
+ };
15
+ export type ControlsType = 'arrows' | 'dots' | 'both' | 'none';
16
+ export type BannerProps = {
17
+ items: BannerItem[];
18
+ height?: 'sm' | 'md' | 'lg' | 'xl' | 'full' | 'auto';
19
+ autoplay?: boolean;
20
+ autoplayInterval?: number;
21
+ controls?: ControlsType;
22
+ overlayStyle?: 'dark' | 'light' | 'gradient' | 'none';
23
+ textAlignment?: 'left' | 'center' | 'right';
24
+ textPosition?: 'top' | 'center' | 'bottom';
25
+ className?: string;
26
+ imageClassName?: string;
27
+ titleClassName?: string;
28
+ subtitleClassName?: string;
29
+ buttonClassName?: string;
30
+ indicatorsClassName?: string;
31
+ controlsClassName?: string;
32
+ contentClassName?: string;
33
+ rounded?: 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
34
+ buttonRounded?: 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
35
+ animation?: 'slide' | 'fade' | 'zoom' | 'none';
36
+ animationDuration?: number;
37
+ pauseOnHover?: boolean;
38
+ infiniteLoop?: boolean;
39
+ objectFit?: 'cover' | 'contain' | 'fill' | 'none';
40
+ objectPosition?: 'center' | 'top' | 'bottom' | 'left' | 'right';
41
+ renderItem?: (item: BannerItem, index: number) => ReactNode;
42
+ renderControls?: (goToNext: () => void, goToPrev: () => void) => ReactNode;
43
+ renderIndicators?: (current: number, total: number, goToSlide: (index: number) => void) => ReactNode;
44
+ onSlideChange?: (currentIndex: number, previousIndex: number) => void;
45
+ withOverlay?: boolean;
46
+ overlayOpacity?: number;
47
+ };
48
+ export declare const Banner: ({ items, height, autoplay, autoplayInterval, controls, overlayStyle, textAlignment, textPosition, className, imageClassName, titleClassName, subtitleClassName, buttonClassName, indicatorsClassName, controlsClassName, contentClassName, rounded, buttonRounded, animation, animationDuration, pauseOnHover, infiniteLoop, objectFit, objectPosition, renderItem, renderControls, renderIndicators, onSlideChange, withOverlay, overlayOpacity, }: BannerProps) => React.JSX.Element | null;
@@ -0,0 +1,142 @@
1
+ 'use client';
2
+ import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/outline';
3
+ import Image from 'next/image';
4
+ import React, { useEffect, useState } from 'react';
5
+ import buildClassesByJoining from '../../utils/StyleHelper';
6
+ export var Banner = function (_a) {
7
+ var items = _a.items, _b = _a.height, height = _b === void 0 ? 'md' : _b, _c = _a.autoplay, autoplay = _c === void 0 ? false : _c, _d = _a.autoplayInterval, autoplayInterval = _d === void 0 ? 5000 : _d, _e = _a.controls, controls = _e === void 0 ? 'both' : _e, _f = _a.overlayStyle, overlayStyle = _f === void 0 ? 'gradient' : _f, _g = _a.textAlignment, textAlignment = _g === void 0 ? 'center' : _g, _h = _a.textPosition, textPosition = _h === void 0 ? 'center' : _h, _j = _a.className, className = _j === void 0 ? '' : _j, _k = _a.imageClassName, imageClassName = _k === void 0 ? '' : _k, _l = _a.titleClassName, titleClassName = _l === void 0 ? '' : _l, _m = _a.subtitleClassName, subtitleClassName = _m === void 0 ? '' : _m, _o = _a.buttonClassName, buttonClassName = _o === void 0 ? '' : _o, _p = _a.indicatorsClassName, indicatorsClassName = _p === void 0 ? '' : _p, _q = _a.controlsClassName, controlsClassName = _q === void 0 ? '' : _q, _r = _a.contentClassName, contentClassName = _r === void 0 ? '' : _r, _s = _a.rounded, rounded = _s === void 0 ? 'none' : _s, _t = _a.buttonRounded, buttonRounded = _t === void 0 ? 'md' : _t, _u = _a.animation, animation = _u === void 0 ? 'slide' : _u, _v = _a.animationDuration, animationDuration = _v === void 0 ? 500 : _v, _w = _a.pauseOnHover, pauseOnHover = _w === void 0 ? true : _w, _x = _a.infiniteLoop, infiniteLoop = _x === void 0 ? true : _x, _y = _a.objectFit, objectFit = _y === void 0 ? 'cover' : _y, _z = _a.objectPosition, objectPosition = _z === void 0 ? 'center' : _z, renderItem = _a.renderItem, renderControls = _a.renderControls, renderIndicators = _a.renderIndicators, onSlideChange = _a.onSlideChange, _0 = _a.withOverlay, withOverlay = _0 === void 0 ? true : _0, _1 = _a.overlayOpacity, overlayOpacity = _1 === void 0 ? 0.5 : _1;
8
+ var _2 = useState(0), currentIndex = _2[0], setCurrentIndex = _2[1];
9
+ var _3 = useState(0), prevIndex = _3[0], setPrevIndex = _3[1];
10
+ var _4 = useState(false), isHovered = _4[0], setIsHovered = _4[1];
11
+ var showArrows = controls === 'arrows' || controls === 'both';
12
+ var showDots = controls === 'dots' || controls === 'both';
13
+ var heightClasses = {
14
+ sm: 'h-48 sm:h-64',
15
+ md: 'h-64 sm:h-96',
16
+ lg: 'h-80 sm:h-[32rem]',
17
+ xl: 'h-96 sm:h-[40rem]',
18
+ full: 'h-screen',
19
+ auto: 'h-auto',
20
+ };
21
+ var overlayClasses = {
22
+ dark: "bg-black/".concat(Math.round(overlayOpacity * 100)),
23
+ light: "bg-white/".concat(Math.round(overlayOpacity * 100)),
24
+ gradient: 'bg-gradient-to-t from-black/70 via-black/30 to-transparent',
25
+ none: '',
26
+ };
27
+ var textAlignmentClasses = {
28
+ left: 'text-left items-start',
29
+ center: 'text-center items-center',
30
+ right: 'text-right items-end',
31
+ };
32
+ var textPositionClasses = {
33
+ top: 'justify-start pt-10',
34
+ center: 'justify-center',
35
+ bottom: 'justify-end pb-10',
36
+ };
37
+ var roundedClasses = {
38
+ none: 'rounded-none',
39
+ sm: 'rounded-sm',
40
+ md: 'rounded-md',
41
+ lg: 'rounded-lg',
42
+ xl: 'rounded-xl',
43
+ full: 'rounded-full',
44
+ };
45
+ var buttonRoundedClasses = {
46
+ none: 'rounded-none',
47
+ sm: 'rounded-sm',
48
+ md: 'rounded-md',
49
+ lg: 'rounded-lg',
50
+ xl: 'rounded-xl',
51
+ full: 'rounded-full',
52
+ };
53
+ var objectFitClasses = {
54
+ cover: 'object-cover',
55
+ contain: 'object-contain',
56
+ fill: 'object-fill',
57
+ none: 'object-none',
58
+ };
59
+ var objectPositionClasses = {
60
+ center: 'object-center',
61
+ top: 'object-top',
62
+ bottom: 'object-bottom',
63
+ left: 'object-left',
64
+ right: 'object-right',
65
+ };
66
+ var animationClasses = {
67
+ slide: "transition-transform duration-".concat(animationDuration),
68
+ fade: "transition-opacity duration-".concat(animationDuration),
69
+ zoom: "transform transition-transform duration-".concat(animationDuration),
70
+ none: '',
71
+ };
72
+ var goToNext = function () {
73
+ setPrevIndex(currentIndex);
74
+ setCurrentIndex(function (prev) {
75
+ var newIndex = prev === items.length - 1 ? (infiniteLoop ? 0 : prev) : prev + 1;
76
+ onSlideChange && onSlideChange(newIndex, prev);
77
+ return newIndex;
78
+ });
79
+ };
80
+ var goToPrev = function () {
81
+ setPrevIndex(currentIndex);
82
+ setCurrentIndex(function (prev) {
83
+ var newIndex = prev === 0 ? (infiniteLoop ? items.length - 1 : prev) : prev - 1;
84
+ onSlideChange && onSlideChange(newIndex, prev);
85
+ return newIndex;
86
+ });
87
+ };
88
+ var goToSlide = function (index) {
89
+ if (index === currentIndex)
90
+ return;
91
+ setPrevIndex(currentIndex);
92
+ setCurrentIndex(index);
93
+ onSlideChange && onSlideChange(index, currentIndex);
94
+ };
95
+ // Autoplay effet
96
+ useEffect(function () {
97
+ if (!autoplay || (pauseOnHover && isHovered) || items.length <= 1)
98
+ return;
99
+ var interval = setInterval(goToNext, autoplayInterval);
100
+ return function () { return clearInterval(interval); };
101
+ }, [autoplay, autoplayInterval, isHovered, items.length, pauseOnHover]);
102
+ if (!items || items.length === 0) {
103
+ return null;
104
+ }
105
+ // Renderovanie individuálneho slide
106
+ var renderDefaultItem = function (item, index) { return (React.createElement("div", { key: item.id, className: "min-w-full h-full relative ".concat(animation === 'fade'
107
+ ? index === currentIndex
108
+ ? 'opacity-100'
109
+ : 'opacity-0'
110
+ : '') },
111
+ React.createElement("div", { className: "absolute inset-0 w-full h-full" },
112
+ React.createElement(Image, { src: item.imageSrc, alt: item.imageAlt || item.title, fill: true, unoptimized: true, style: { objectFit: objectFit }, priority: index === 0, className: buildClassesByJoining(roundedClasses[rounded], objectFitClasses[objectFit], objectPositionClasses[objectPosition], imageClassName) }),
113
+ withOverlay && (React.createElement("div", { className: buildClassesByJoining('absolute inset-0', overlayClasses[overlayStyle], roundedClasses[rounded]), style: item.overlayOpacity ? { opacity: item.overlayOpacity } : {} }))),
114
+ item.customContent || (React.createElement("div", { className: buildClassesByJoining('relative h-full w-full flex flex-col px-6', textPositionClasses[textPosition], textAlignmentClasses[textAlignment], contentClassName) },
115
+ React.createElement("h2", { className: buildClassesByJoining('text-3xl sm:text-4xl md:text-5xl font-bold text-white mb-2', titleClassName) }, item.title),
116
+ React.createElement("p", { className: buildClassesByJoining('text-xl text-white/80 max-w-2xl', subtitleClassName) }, item.subtitle),
117
+ item.buttonText && item.buttonLink && (React.createElement("a", { href: item.buttonLink, className: buildClassesByJoining('mt-4 px-6 py-2 bg-white text-black font-medium hover:bg-opacity-90 transition-colors inline-block', buttonRoundedClasses[buttonRounded], buttonClassName) }, item.buttonText)))))); };
118
+ // Pre jeden slide použijeme zjednodušený výstup
119
+ if (items.length === 1) {
120
+ var item = items[0];
121
+ return (React.createElement("div", { className: buildClassesByJoining('relative overflow-hidden w-full', heightClasses[height], roundedClasses[rounded], className) }, renderItem ? renderItem(item, 0) : renderDefaultItem(item, 0)));
122
+ }
123
+ // Pre viac slideov vytvoríme karusel
124
+ return (React.createElement("div", { className: buildClassesByJoining('relative overflow-hidden w-full', heightClasses[height], roundedClasses[rounded], className), onMouseEnter: function () { return pauseOnHover && setIsHovered(true); }, onMouseLeave: function () { return pauseOnHover && setIsHovered(false); } },
125
+ React.createElement("div", { className: buildClassesByJoining('flex h-full', animationClasses[animation]), style: animation === 'slide'
126
+ ? { transform: "translateX(-".concat(currentIndex * 100, "%)") }
127
+ : {} }, items.map(function (item, index) {
128
+ return renderItem ? renderItem(item, index) : renderDefaultItem(item, index);
129
+ })),
130
+ showArrows &&
131
+ items.length > 1 &&
132
+ (renderControls ? (renderControls(goToNext, goToPrev)) : (React.createElement(React.Fragment, null,
133
+ React.createElement("button", { onClick: goToPrev, className: buildClassesByJoining('absolute left-4 top-1/2 -translate-y-1/2 w-10 h-10 flex items-center justify-center rounded-full bg-black/30 hover:bg-black/50 text-white transition-colors', controlsClassName), "aria-label": "P\u0159edchoz\u00ED" },
134
+ React.createElement(ChevronLeftIcon, { className: "h-6 w-6" })),
135
+ React.createElement("button", { onClick: goToNext, className: buildClassesByJoining('absolute right-4 top-1/2 -translate-y-1/2 w-10 h-10 flex items-center justify-center rounded-full bg-black/30 hover:bg-black/50 text-white transition-colors', controlsClassName), "aria-label": "Dal\u0161\u00ED" },
136
+ React.createElement(ChevronRightIcon, { className: "h-6 w-6" }))))),
137
+ showDots &&
138
+ items.length > 1 &&
139
+ (renderIndicators ? (renderIndicators(currentIndex, items.length, goToSlide)) : (React.createElement("div", { className: buildClassesByJoining('absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-2', indicatorsClassName) }, items.map(function (_, index) { return (React.createElement("button", { key: index, onClick: function () { return goToSlide(index); }, className: buildClassesByJoining('w-3 h-3 rounded-full transition-colors', index === currentIndex
140
+ ? 'bg-white'
141
+ : 'bg-white/40 hover:bg-white/60'), "aria-label": "P\u0159ej\u00EDt na slide ".concat(index + 1) })); }))))));
142
+ };
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  var __assign = (this && this.__assign) || function () {
2
3
  __assign = Object.assign || function(t) {
3
4
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -0,0 +1 @@
1
+ @import "tailwindcss";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
+ import './global.css';
1
2
  export { default as Badge } from './components/badge/Badge';
3
+ export { Banner } from './components/banner/Banner';
2
4
  export { default as Button } from './components/button/Button';
3
5
  export { NavBar } from './components/nav-bar/NavBar';
4
6
  export { ProductCard } from './components/product-card/ProductCard';
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
- // src/index.ts
1
+ import './global.css';
2
2
  export { default as Badge } from './components/badge/Badge';
3
+ export { Banner } from './components/banner/Banner';
3
4
  export { default as Button } from './components/button/Button';
4
5
  export { NavBar } from './components/nav-bar/NavBar';
5
6
  export { ProductCard } from './components/product-card/ProductCard';
package/package.json CHANGED
@@ -1,61 +1,64 @@
1
1
  {
2
- "name": "@q2devel/q2-storybook",
3
- "version": "1.0.8",
4
- "main": "dist/index.js",
5
- "module": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "import": "./dist/index.js",
10
- "require": "./dist/index.js"
2
+ "name": "@q2devel/q2-storybook",
3
+ "version": "1.0.9",
4
+ "main": "dist/index.js",
5
+ "module": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.js"
11
+ },
12
+ "./styles": "./dist/global.css"
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "test": "echo \"Error: no test specified\" && exit 1",
19
+ "storybook": "storybook dev -p 6006",
20
+ "build-storybook": "storybook build",
21
+ "build": "tsc && npm run copy-assets",
22
+ "copy-assets": "find src -name '*.css' -exec cp --parents {} dist \\; || xcopy /s /y src\\*.css dist\\",
23
+ "prepublishOnly": "npm run build"
24
+ },
25
+ "keywords": [],
26
+ "author": "Q2",
27
+ "license": "ISC",
28
+ "description": "Komponenty nebo konfigurace pro storybook",
29
+ "devDependencies": {
30
+ "@storybook/addon-actions": "^8.6.12",
31
+ "@storybook/addon-essentials": "^8.6.12",
32
+ "@storybook/addon-interactions": "^8.6.12",
33
+ "@storybook/addon-links": "^8.6.12",
34
+ "@storybook/addon-onboarding": "^8.6.12",
35
+ "@storybook/blocks": "^8.6.12",
36
+ "@storybook/react": "^8.6.12",
37
+ "@storybook/react-vite": "^8.6.12",
38
+ "@storybook/test": "^8.6.12",
39
+ "@types/classnames": "^2.3.0",
40
+ "@types/node": "^22.14.1",
41
+ "@types/react": "^19.1.2",
42
+ "@types/react-dom": "^19.1.2",
43
+ "autoprefixer": "^10.4.21",
44
+ "next": "^15.3.2",
45
+ "postcss": "^8.5.3",
46
+ "react": "^19.1.0",
47
+ "react-dom": "^19.1.0",
48
+ "storybook": "^8.6.12",
49
+ "tailwindcss": "^4.1.4",
50
+ "typescript": "^5.8.3"
51
+ },
52
+ "peerDependencies": {
53
+ "react": "^19.0.0",
54
+ "react-dom": "^19.0.0"
55
+ },
56
+ "dependencies": {
57
+ "@heroicons/react": "^2.2.0",
58
+ "@tailwindcss/postcss": "^4.1.4",
59
+ "classnames": "^2.5.1",
60
+ "html-react-parser": "^5.2.3",
61
+ "react-select": "^5.10.1",
62
+ "tailwind-merge": "^3.2.0"
11
63
  }
12
- },
13
- "files": [
14
- "dist"
15
- ],
16
- "scripts": {
17
- "test": "echo \"Error: no test specified\" && exit 1",
18
- "storybook": "storybook dev -p 6006",
19
- "build-storybook": "storybook build",
20
- "build": "tsc",
21
- "prepublishOnly": "npm run build"
22
- },
23
- "keywords": [],
24
- "author": "Q2",
25
- "license": "ISC",
26
- "description": "Komponenty nebo konfigurace pro storybook",
27
- "devDependencies": {
28
- "@storybook/addon-actions": "^8.6.12",
29
- "@storybook/addon-essentials": "^8.6.12",
30
- "@storybook/addon-interactions": "^8.6.12",
31
- "@storybook/addon-links": "^8.6.12",
32
- "@storybook/addon-onboarding": "^8.6.12",
33
- "@storybook/blocks": "^8.6.12",
34
- "@storybook/react": "^8.6.12",
35
- "@storybook/react-vite": "^8.6.12",
36
- "@storybook/test": "^8.6.12",
37
- "@types/classnames": "^2.3.0",
38
- "@types/node": "^22.14.1",
39
- "@types/react": "^19.1.2",
40
- "@types/react-dom": "^19.1.2",
41
- "autoprefixer": "^10.4.21",
42
- "postcss": "^8.5.3",
43
- "react": "^19.1.0",
44
- "react-dom": "^19.1.0",
45
- "storybook": "^8.6.12",
46
- "tailwindcss": "^4.1.4",
47
- "typescript": "^5.8.3"
48
- },
49
- "peerDependencies": {
50
- "react": "^19.0.0",
51
- "react-dom": "^19.0.0"
52
- },
53
- "dependencies": {
54
- "@heroicons/react": "^2.2.0",
55
- "@tailwindcss/postcss": "^4.1.4",
56
- "classnames": "^2.5.1",
57
- "html-react-parser": "^5.2.3",
58
- "react-select": "^5.10.1",
59
- "tailwind-merge": "^3.2.0"
60
- }
61
64
  }