@windrun-huaiin/third-ui 5.11.3 → 5.11.5
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/dist/main/index.js +41 -31
- package/dist/main/index.js.map +1 -1
- package/dist/main/index.mjs +32 -22
- package/dist/main/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/main/ai-prompt-textarea.tsx +2 -2
- package/src/main/gallery.tsx +24 -7
package/package.json
CHANGED
|
@@ -212,8 +212,8 @@ export function AIPromptTextarea({
|
|
|
212
212
|
className={cn(
|
|
213
213
|
'w-full p-4 bg-transparent transition-colors text-foreground placeholder-muted-foreground placeholder:text-base disabled:bg-muted disabled:cursor-not-allowed resize-none',
|
|
214
214
|
isEmbedded
|
|
215
|
-
? 'border-0 hover:border-2 hover:border-purple-500 focus:border-2 focus:border-purple-500'
|
|
216
|
-
: 'border-2 border-border rounded-lg hover:border-purple-500 focus:border-purple-500',
|
|
215
|
+
? 'border-0 hover:border-2 hover:border-purple-500 focus:outline-none focus:border-2 focus:border-purple-500'
|
|
216
|
+
: 'border-2 border-border rounded-lg hover:border-purple-500 focus:outline-none focus:border-purple-500',
|
|
217
217
|
className
|
|
218
218
|
)}
|
|
219
219
|
style={{ minHeight: `${minHeight}px` }}
|
package/src/main/gallery.tsx
CHANGED
|
@@ -5,14 +5,22 @@ import { useTranslations } from 'next-intl'
|
|
|
5
5
|
import Image from "next/image"
|
|
6
6
|
import { GradientButton } from "@third-ui/fuma/mdx/gradient-button"
|
|
7
7
|
import { cn } from '@lib/utils';
|
|
8
|
+
import { useState } from 'react';
|
|
9
|
+
|
|
10
|
+
interface GalleryItem {
|
|
11
|
+
url: string;
|
|
12
|
+
altMsg: string;
|
|
13
|
+
}
|
|
8
14
|
|
|
9
15
|
export function Gallery({ sectionClassName }: { sectionClassName?: string }) {
|
|
10
16
|
const t = useTranslations('gallery');
|
|
11
|
-
const galleryItems = t.raw('prompts') as
|
|
17
|
+
const galleryItems = t.raw('prompts') as GalleryItem[];
|
|
18
|
+
const defaultImgUrl = t.raw('defaultImgUrl') as string;
|
|
19
|
+
const [imageErrors, setImageErrors] = useState<Set<number>>(new Set());
|
|
12
20
|
|
|
13
|
-
const handleDownload = async (index: number) => {
|
|
21
|
+
const handleDownload = async (item: GalleryItem, index: number) => {
|
|
14
22
|
try {
|
|
15
|
-
const response = await fetch(
|
|
23
|
+
const response = await fetch(item.url);
|
|
16
24
|
const blob = await response.blob();
|
|
17
25
|
const url = window.URL.createObjectURL(blob);
|
|
18
26
|
const a = document.createElement('a');
|
|
@@ -27,6 +35,14 @@ export function Gallery({ sectionClassName }: { sectionClassName?: string }) {
|
|
|
27
35
|
}
|
|
28
36
|
};
|
|
29
37
|
|
|
38
|
+
const handleImageError = (index: number) => {
|
|
39
|
+
setImageErrors(prev => new Set(prev).add(index));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const getImageSrc = (item: GalleryItem, index: number) => {
|
|
43
|
+
return imageErrors.has(index) ? defaultImgUrl : item.url;
|
|
44
|
+
};
|
|
45
|
+
|
|
30
46
|
return (
|
|
31
47
|
<section id="gallery" className={cn("container mx-auto px-4 py-20 scroll-mt-20", sectionClassName)}>
|
|
32
48
|
<h2 className="text-3xl md:text-4xl font-bold text-center mb-6">
|
|
@@ -36,18 +52,19 @@ export function Gallery({ sectionClassName }: { sectionClassName?: string }) {
|
|
|
36
52
|
{t('description')}
|
|
37
53
|
</p>
|
|
38
54
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
39
|
-
{galleryItems.map((
|
|
55
|
+
{galleryItems.map((item, index) => (
|
|
40
56
|
<div key={index} className="group relative overflow-hidden rounded-xl">
|
|
41
57
|
<Image
|
|
42
|
-
src={
|
|
43
|
-
alt=
|
|
58
|
+
src={getImageSrc(item, index)}
|
|
59
|
+
alt={item.altMsg}
|
|
44
60
|
width={600}
|
|
45
61
|
height={600}
|
|
46
62
|
className="w-full h-80 object-cover transition duration-300 group-hover:scale-105"
|
|
63
|
+
onError={() => handleImageError(index)}
|
|
47
64
|
/>
|
|
48
65
|
<div className="absolute inset-0 flex items-end justify-end p-4 opacity-0 group-hover:opacity-100 transition duration-300">
|
|
49
66
|
<button
|
|
50
|
-
onClick={() => handleDownload(index)}
|
|
67
|
+
onClick={() => handleDownload(item, index)}
|
|
51
68
|
className="bg-black/50 hover:bg-black/70 p-2 rounded-full text-white/80 hover:text-white transition-all duration-300"
|
|
52
69
|
>
|
|
53
70
|
<icons.Download className="h-5 w-5 text-white" />
|