willytpfw commited on
Commit
dac72ca
·
verified ·
1 Parent(s): 315a976

puedes corregir el error ?

Browse files
Files changed (1) hide show
  1. index.html +27 -59
index.html CHANGED
@@ -52,47 +52,21 @@
52
 
53
  const API_CONFIG = {
54
  unsplash: {
55
- url: 'https://api.unsplash.com/photos/random',
56
- params: {
57
- count: 5,
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: 'https://api.pexels.com/v1/curated',
69
- params: {
70
- per_page: 5
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: 'https://pixabay.com/api/',
84
- params: {
85
- key: 'YOUR_PIXABAY_API_KEY',
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
- const params = new URLSearchParams(config.params).toString();
104
- const url = `${config.url}?${params}`;
105
-
106
- const options = {
107
- headers: config.headers || {}
108
- };
109
-
110
- const response = await fetch(url, options);
111
- const data = await response.json();
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
- <p className="mt-2 text-sm">Using placeholder images instead.</p>
187
- <button
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
- <select
205
- value={apiSource}
206
- onChange={(e) => setApiSource(e.target.value)}
207
- className="bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-white px-3 py-2 rounded-md"
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>Click on navigation arrows or dots to browse manually</p>
299
- <div className="mt-2 flex justify-center space-x-4">
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"