@umituz/web-design-system 2.0.1 → 2.2.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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-design-system",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Web Design System - Atomic Design components (Atoms, Molecules, Organisms, Templates) for React applications",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"react-day-picker": ">=9.0.0",
|
|
78
78
|
"react-dom": ">=19.0.0",
|
|
79
79
|
"react-i18next": ">=13.0.0",
|
|
80
|
+
"react-syntax-highlighter": ">=15.0.0",
|
|
80
81
|
"tailwind-merge": ">=2.0.0"
|
|
81
82
|
},
|
|
82
83
|
"devDependencies": {
|
|
@@ -99,6 +100,7 @@
|
|
|
99
100
|
"@radix-ui/react-tooltip": "^1.2.7",
|
|
100
101
|
"@types/react": "^19.0.0",
|
|
101
102
|
"@types/react-dom": "^19.0.0",
|
|
103
|
+
"@types/react-syntax-highlighter": "^15.5.13",
|
|
102
104
|
"class-variance-authority": "^0.7.1",
|
|
103
105
|
"clsx": "^2.1.1",
|
|
104
106
|
"lucide-react": "^0.577.0",
|
|
@@ -106,6 +108,7 @@
|
|
|
106
108
|
"react-day-picker": "^9.14.0",
|
|
107
109
|
"react-dom": "^19.0.0",
|
|
108
110
|
"react-i18next": "^13.0.0",
|
|
111
|
+
"react-syntax-highlighter": "^16.1.1",
|
|
109
112
|
"tailwind-merge": "^3.5.0",
|
|
110
113
|
"typescript": "~5.9.2"
|
|
111
114
|
},
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImageLightbox Component (Organism)
|
|
3
|
+
* @description Full-screen image gallery with zoom, navigation, and thumbnails
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
7
|
+
import { cn } from '../../infrastructure/utils';
|
|
8
|
+
import type { BaseProps } from '../../domain/types';
|
|
9
|
+
import { Icon } from '../atoms/Icon';
|
|
10
|
+
|
|
11
|
+
export interface ImageLightboxImage {
|
|
12
|
+
src: string;
|
|
13
|
+
alt: string;
|
|
14
|
+
title?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ImageLightboxProps extends BaseProps {
|
|
18
|
+
images: ImageLightboxImage[];
|
|
19
|
+
initialIndex?: number;
|
|
20
|
+
isOpen: boolean;
|
|
21
|
+
onClose: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const ImageLightbox = ({
|
|
25
|
+
images,
|
|
26
|
+
initialIndex = 0,
|
|
27
|
+
isOpen,
|
|
28
|
+
onClose,
|
|
29
|
+
}: ImageLightboxProps) => {
|
|
30
|
+
// Early return if closed
|
|
31
|
+
if (!isOpen) return null;
|
|
32
|
+
|
|
33
|
+
// Early return if no images
|
|
34
|
+
if (!images || images.length === 0) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const [currentIndex, setCurrentIndex] = useState(initialIndex);
|
|
39
|
+
const [isZoomed, setIsZoomed] = useState(false);
|
|
40
|
+
|
|
41
|
+
// Ensure initialIndex is within bounds
|
|
42
|
+
const safeIndex = Math.min(Math.max(initialIndex, 0), images.length - 1);
|
|
43
|
+
const currentImage = images[safeIndex];
|
|
44
|
+
|
|
45
|
+
// Use useCallback to memoize navigation functions
|
|
46
|
+
const goToNext = useCallback(() => {
|
|
47
|
+
setCurrentIndex((prev) => (prev + 1) % images.length);
|
|
48
|
+
}, [images.length]);
|
|
49
|
+
|
|
50
|
+
const goToPrevious = useCallback(() => {
|
|
51
|
+
setCurrentIndex((prev) => (prev - 1 + images.length) % images.length);
|
|
52
|
+
}, [images.length]);
|
|
53
|
+
|
|
54
|
+
const handleImageClick = useCallback(() => {
|
|
55
|
+
setIsZoomed(!isZoomed);
|
|
56
|
+
}, [isZoomed]);
|
|
57
|
+
|
|
58
|
+
// Handle keyboard navigation
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
61
|
+
switch (e.key) {
|
|
62
|
+
case 'Escape':
|
|
63
|
+
onClose();
|
|
64
|
+
break;
|
|
65
|
+
case 'ArrowLeft':
|
|
66
|
+
goToPrevious();
|
|
67
|
+
break;
|
|
68
|
+
case 'ArrowRight':
|
|
69
|
+
goToNext();
|
|
70
|
+
break;
|
|
71
|
+
case '+':
|
|
72
|
+
case '=':
|
|
73
|
+
setIsZoomed(!isZoomed);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
79
|
+
return () => window.removeEventListener('keydown', handleKeyDown);
|
|
80
|
+
}, [onClose, goToPrevious, goToNext, isZoomed]);
|
|
81
|
+
|
|
82
|
+
// Prevent body scroll when lightbox is open
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
const originalOverflow = document.body.style.overflow;
|
|
85
|
+
document.body.style.overflow = 'hidden';
|
|
86
|
+
|
|
87
|
+
return () => {
|
|
88
|
+
document.body.style.overflow = originalOverflow;
|
|
89
|
+
};
|
|
90
|
+
}, []);
|
|
91
|
+
|
|
92
|
+
if (!currentImage) return null;
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div
|
|
96
|
+
className="fixed inset-0 z-50 bg-black/90 flex items-center justify-center p-4"
|
|
97
|
+
onClick={onClose}
|
|
98
|
+
>
|
|
99
|
+
{/* Close button */}
|
|
100
|
+
<button
|
|
101
|
+
onClick={onClose}
|
|
102
|
+
className="absolute top-4 right-4 p-2 bg-black/50 hover:bg-black/70 rounded-full text-white transition-all"
|
|
103
|
+
aria-label="Close lightbox"
|
|
104
|
+
>
|
|
105
|
+
<Icon className="text-white">
|
|
106
|
+
<path
|
|
107
|
+
strokeLinecap="round"
|
|
108
|
+
strokeLinejoin="round"
|
|
109
|
+
strokeWidth={2}
|
|
110
|
+
d="M6 18L18 6M6 6l12 12"
|
|
111
|
+
/>
|
|
112
|
+
</Icon>
|
|
113
|
+
</button>
|
|
114
|
+
|
|
115
|
+
{/* Navigation - Previous */}
|
|
116
|
+
{images.length > 1 && (
|
|
117
|
+
<button
|
|
118
|
+
onClick={(e) => {
|
|
119
|
+
e.stopPropagation();
|
|
120
|
+
goToPrevious();
|
|
121
|
+
}}
|
|
122
|
+
className="absolute left-4 p-2 bg-black/50 hover:bg-black/70 rounded-full text-white transition-all"
|
|
123
|
+
aria-label="Previous image"
|
|
124
|
+
>
|
|
125
|
+
<Icon className="text-white" size="lg">
|
|
126
|
+
<path
|
|
127
|
+
strokeLinecap="round"
|
|
128
|
+
strokeLinejoin="round"
|
|
129
|
+
strokeWidth={2}
|
|
130
|
+
d="M15 19l-7-7 7-7"
|
|
131
|
+
/>
|
|
132
|
+
</Icon>
|
|
133
|
+
</button>
|
|
134
|
+
)}
|
|
135
|
+
|
|
136
|
+
{/* Navigation - Next */}
|
|
137
|
+
{images.length > 1 && (
|
|
138
|
+
<button
|
|
139
|
+
onClick={(e) => {
|
|
140
|
+
e.stopPropagation();
|
|
141
|
+
goToNext();
|
|
142
|
+
}}
|
|
143
|
+
className="absolute right-4 p-2 bg-black/50 hover:bg-black/70 rounded-full text-white transition-all"
|
|
144
|
+
aria-label="Next image"
|
|
145
|
+
>
|
|
146
|
+
<Icon className="text-white" size="lg">
|
|
147
|
+
<path
|
|
148
|
+
strokeLinecap="round"
|
|
149
|
+
strokeLinejoin="round"
|
|
150
|
+
strokeWidth={2}
|
|
151
|
+
d="M9 5l7 7-7 7"
|
|
152
|
+
/>
|
|
153
|
+
</Icon>
|
|
154
|
+
</button>
|
|
155
|
+
)}
|
|
156
|
+
|
|
157
|
+
{/* Main Image */}
|
|
158
|
+
<div
|
|
159
|
+
className="relative max-w-5xl max-h-[90vh] w-full"
|
|
160
|
+
onClick={handleImageClick}
|
|
161
|
+
>
|
|
162
|
+
<img
|
|
163
|
+
src={currentImage.src}
|
|
164
|
+
alt={currentImage.alt}
|
|
165
|
+
className={cn(
|
|
166
|
+
'w-full h-full object-contain',
|
|
167
|
+
isZoomed ? 'cursor-zoom-out' : 'cursor-zoom-in'
|
|
168
|
+
)}
|
|
169
|
+
style={{
|
|
170
|
+
maxHeight: '90vh',
|
|
171
|
+
objectFit: 'contain',
|
|
172
|
+
}}
|
|
173
|
+
/>
|
|
174
|
+
|
|
175
|
+
{/* Zoom indicator */}
|
|
176
|
+
<div className="absolute bottom-4 right-4 flex items-center gap-2 bg-black/50 px-3 py-2 rounded-full">
|
|
177
|
+
<button
|
|
178
|
+
onClick={(e) => {
|
|
179
|
+
e.stopPropagation();
|
|
180
|
+
setIsZoomed(!isZoomed);
|
|
181
|
+
}}
|
|
182
|
+
className="p-1 hover:bg-black/70 rounded-full transition-all text-white"
|
|
183
|
+
aria-label={isZoomed ? 'Zoom out' : 'Zoom in'}
|
|
184
|
+
>
|
|
185
|
+
{isZoomed ? (
|
|
186
|
+
<Icon className="text-white" size="sm">
|
|
187
|
+
<path
|
|
188
|
+
strokeLinecap="round"
|
|
189
|
+
strokeLinejoin="round"
|
|
190
|
+
strokeWidth={2}
|
|
191
|
+
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM13 10H7"
|
|
192
|
+
/>
|
|
193
|
+
</Icon>
|
|
194
|
+
) : (
|
|
195
|
+
<Icon className="text-white" size="sm">
|
|
196
|
+
<path
|
|
197
|
+
strokeLinecap="round"
|
|
198
|
+
strokeLinejoin="round"
|
|
199
|
+
strokeWidth={2}
|
|
200
|
+
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v6m3-3H7"
|
|
201
|
+
/>
|
|
202
|
+
</Icon>
|
|
203
|
+
)}
|
|
204
|
+
</button>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
|
|
208
|
+
{/* Image Counter */}
|
|
209
|
+
{images.length > 1 && (
|
|
210
|
+
<div className="absolute bottom-4 left-4 bg-black/50 px-4 py-2 rounded-full text-white text-sm">
|
|
211
|
+
{currentIndex + 1} / {images.length}
|
|
212
|
+
</div>
|
|
213
|
+
)}
|
|
214
|
+
|
|
215
|
+
{/* Image Title */}
|
|
216
|
+
{currentImage.title && (
|
|
217
|
+
<div className="absolute bottom-4 left-1/2 -translate-x-1/2 bg-black/50 px-4 py-2 rounded-full text-white text-sm max-w-md text-center">
|
|
218
|
+
{currentImage.title}
|
|
219
|
+
</div>
|
|
220
|
+
)}
|
|
221
|
+
|
|
222
|
+
{/* Thumbnails */}
|
|
223
|
+
{images.length > 1 && (
|
|
224
|
+
<div className="absolute bottom-20 left-1/2 -translate-x-1/2 flex gap-2 max-w-xl overflow-x-auto">
|
|
225
|
+
{images.map((image, index) => (
|
|
226
|
+
<button
|
|
227
|
+
key={index}
|
|
228
|
+
onClick={(e) => {
|
|
229
|
+
e.stopPropagation();
|
|
230
|
+
setCurrentIndex(index);
|
|
231
|
+
}}
|
|
232
|
+
className={cn(
|
|
233
|
+
'flex-shrink-0 w-16 h-16 rounded-lg overflow-hidden border-2 transition-all',
|
|
234
|
+
index === currentIndex
|
|
235
|
+
? 'border-white scale-110'
|
|
236
|
+
: 'border-transparent opacity-50 hover:opacity-100'
|
|
237
|
+
)}
|
|
238
|
+
>
|
|
239
|
+
<img
|
|
240
|
+
src={image.src}
|
|
241
|
+
alt={image.alt}
|
|
242
|
+
className="w-full h-full object-cover"
|
|
243
|
+
/>
|
|
244
|
+
</button>
|
|
245
|
+
))}
|
|
246
|
+
</div>
|
|
247
|
+
)}
|
|
248
|
+
</div>
|
|
249
|
+
);
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
ImageLightbox.displayName = 'ImageLightbox';
|
|
@@ -131,3 +131,7 @@ export {
|
|
|
131
131
|
} from './DropdownMenu';
|
|
132
132
|
|
|
133
133
|
export { ToggleGroup, ToggleGroupItem } from './ToggleGroup';
|
|
134
|
+
|
|
135
|
+
// NEW: Media & Content Components
|
|
136
|
+
export { ImageLightbox } from './ImageLightbox';
|
|
137
|
+
export type { ImageLightboxProps, ImageLightboxImage } from './ImageLightbox';
|