puedes corregir el error ?
Browse files- index.html +27 -59
index.html
CHANGED
|
@@ -52,47 +52,21 @@
|
|
| 52 |
|
| 53 |
const API_CONFIG = {
|
| 54 |
unsplash: {
|
| 55 |
-
url: '
|
| 56 |
-
params: {
|
| 57 |
-
|
| 58 |
-
client_id: 'YOUR_UNSPLASH_ACCESS_KEY'
|
| 59 |
-
},
|
| 60 |
-
transform: (data) => data.map(item => ({
|
| 61 |
-
url: item.urls.regular,
|
| 62 |
-
alt: item.alt_description || 'Unsplash Image',
|
| 63 |
-
author: item.user.name,
|
| 64 |
-
authorUrl: item.user.links.html
|
| 65 |
-
}))
|
| 66 |
},
|
| 67 |
pexels: {
|
| 68 |
-
url: '
|
| 69 |
-
params: {
|
| 70 |
-
|
| 71 |
-
},
|
| 72 |
-
headers: {
|
| 73 |
-
Authorization: 'YOUR_PEXELS_API_KEY'
|
| 74 |
-
},
|
| 75 |
-
transform: (data) => data.photos.map(photo => ({
|
| 76 |
-
url: photo.src.large,
|
| 77 |
-
alt: photo.photographer || 'Pexels Image',
|
| 78 |
-
author: photo.photographer,
|
| 79 |
-
authorUrl: photo.photographer_url
|
| 80 |
-
}))
|
| 81 |
},
|
| 82 |
pixabay: {
|
| 83 |
-
url: '
|
| 84 |
-
params: {
|
| 85 |
-
|
| 86 |
-
per_page: 5
|
| 87 |
-
},
|
| 88 |
-
transform: (data) => data.hits.map(hit => ({
|
| 89 |
-
url: hit.webformatURL,
|
| 90 |
-
alt: hit.tags || 'Pixabay Image',
|
| 91 |
-
author: hit.user,
|
| 92 |
-
authorUrl: `https://pixabay.com/users/${hit.user}-${hit.user_id}/`
|
| 93 |
-
}))
|
| 94 |
}
|
| 95 |
-
|
| 96 |
|
| 97 |
const fetchImages = async () => {
|
| 98 |
setIsLoading(true);
|
|
@@ -100,15 +74,15 @@
|
|
| 100 |
|
| 101 |
try {
|
| 102 |
const config = API_CONFIG[apiSource];
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
|
| 113 |
if (!response.ok) throw new Error(data.message || 'Failed to fetch images');
|
| 114 |
|
|
@@ -183,8 +157,8 @@
|
|
| 183 |
<h3 className="font-bold">Error Loading Images</h3>
|
| 184 |
</div>
|
| 185 |
<p className="mt-2">{error}</p>
|
| 186 |
-
|
| 187 |
-
|
| 188 |
onClick={fetchImages}
|
| 189 |
className="mt-4 bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-md transition-colors"
|
| 190 |
>
|
|
@@ -201,16 +175,10 @@
|
|
| 201 |
<div className="flex justify-between items-center mb-6">
|
| 202 |
<h1 className="text-3xl font-bold text-gray-800 dark:text-white">PixelFlow Carousel</h1>
|
| 203 |
<div className="flex space-x-4">
|
| 204 |
-
<
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
>
|
| 209 |
-
<option value="unsplash">Unsplash</option>
|
| 210 |
-
<option value="pexels">Pexels</option>
|
| 211 |
-
<option value="pixabay">Pixabay</option>
|
| 212 |
-
</select>
|
| 213 |
-
<button
|
| 214 |
onClick={toggleDarkMode}
|
| 215 |
className="p-2 rounded-full bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-200"
|
| 216 |
>
|
|
@@ -295,8 +263,8 @@
|
|
| 295 |
</div>
|
| 296 |
|
| 297 |
<div className="mt-6 text-center text-gray-600 dark:text-gray-400">
|
| 298 |
-
<p>
|
| 299 |
-
|
| 300 |
<button
|
| 301 |
onClick={fetchImages}
|
| 302 |
className="flex items-center text-sm bg-gray-100 dark:bg-gray-700 px-3 py-1 rounded-md"
|
|
|
|
| 52 |
|
| 53 |
const API_CONFIG = {
|
| 54 |
unsplash: {
|
| 55 |
+
url: '',
|
| 56 |
+
params: {},
|
| 57 |
+
transform: () => []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
},
|
| 59 |
pexels: {
|
| 60 |
+
url: '',
|
| 61 |
+
params: {},
|
| 62 |
+
transform: () => []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
},
|
| 64 |
pixabay: {
|
| 65 |
+
url: '',
|
| 66 |
+
params: {},
|
| 67 |
+
transform: () => []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
}
|
| 69 |
+
};
|
| 70 |
|
| 71 |
const fetchImages = async () => {
|
| 72 |
setIsLoading(true);
|
|
|
|
| 74 |
|
| 75 |
try {
|
| 76 |
const config = API_CONFIG[apiSource];
|
| 77 |
+
// Skip API calls and use placeholders directly since API keys aren't provided
|
| 78 |
+
setImages(Array(5).fill().map((_, i) => ({
|
| 79 |
+
url: `http://static.photos/nature/1024x576/${i+1}`,
|
| 80 |
+
alt: `Placeholder Image ${i+1}`,
|
| 81 |
+
author: 'Placeholder Author',
|
| 82 |
+
authorUrl: '#'
|
| 83 |
+
})));
|
| 84 |
+
return;
|
| 85 |
+
const data = await response.json();
|
| 86 |
|
| 87 |
if (!response.ok) throw new Error(data.message || 'Failed to fetch images');
|
| 88 |
|
|
|
|
| 157 |
<h3 className="font-bold">Error Loading Images</h3>
|
| 158 |
</div>
|
| 159 |
<p className="mt-2">{error}</p>
|
| 160 |
+
<p className="mt-2 text-sm">Using static placeholder images.</p>
|
| 161 |
+
<button
|
| 162 |
onClick={fetchImages}
|
| 163 |
className="mt-4 bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-md transition-colors"
|
| 164 |
>
|
|
|
|
| 175 |
<div className="flex justify-between items-center mb-6">
|
| 176 |
<h1 className="text-3xl font-bold text-gray-800 dark:text-white">PixelFlow Carousel</h1>
|
| 177 |
<div className="flex space-x-4">
|
| 178 |
+
<div className="bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-white px-3 py-2 rounded-md">
|
| 179 |
+
Static Photos
|
| 180 |
+
</div>
|
| 181 |
+
<button
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
onClick={toggleDarkMode}
|
| 183 |
className="p-2 rounded-full bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-200"
|
| 184 |
>
|
|
|
|
| 263 |
</div>
|
| 264 |
|
| 265 |
<div className="mt-6 text-center text-gray-600 dark:text-gray-400">
|
| 266 |
+
<p>Browse the static image carousel using navigation controls</p>
|
| 267 |
+
<div className="mt-2 flex justify-center space-x-4">
|
| 268 |
<button
|
| 269 |
onClick={fetchImages}
|
| 270 |
className="flex items-center text-sm bg-gray-100 dark:bg-gray-700 px-3 py-1 rounded-md"
|