@thead-vantage/react 2.23.0 → 2.25.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": "@thead-vantage/react",
3
- "version": "2.23.0",
3
+ "version": "2.25.0",
4
4
  "description": "React components and utilities for TheAd Vantage ad platform integration",
5
5
  "main": "./src/index.ts",
6
6
  "module": "./src/index.ts",
@@ -238,75 +238,79 @@ export function AdBanner({
238
238
 
239
239
  return (
240
240
  <div className={`relative ${className}`}>
241
+ <div className="relative">
242
+ <a
243
+ href={ad.targetUrl}
244
+ onClick={handleClick}
245
+ target="_blank"
246
+ rel="noopener noreferrer"
247
+ className="block"
248
+ >
249
+ {(ad.type === 'image' || ad.type === 'standard') && ad.contentUrl ? (
250
+ <Image
251
+ src={ad.contentUrl}
252
+ alt={ad.name}
253
+ width={ad.width || 300}
254
+ height={ad.height || 250}
255
+ className="rounded-t"
256
+ unoptimized
257
+ />
258
+ ) : (
259
+ <div className="flex items-center justify-center bg-gray-200 dark:bg-gray-700 rounded-t" style={{ width: ad.width || 300, height: ad.height || 250 }}>
260
+ <span className="text-sm text-gray-500">Ad content</span>
261
+ </div>
262
+ )}
263
+ </a>
264
+ {showImpressionFinished && impressionStatus !== 'pending' && (
265
+ <div className="absolute top-2 right-2">
266
+ {impressionStatus === 'counting' ? (
267
+ <svg
268
+ className="w-5 h-5 text-gray-400 animate-spin"
269
+ xmlns="http://www.w3.org/2000/svg"
270
+ fill="none"
271
+ viewBox="0 0 24 24"
272
+ >
273
+ <circle
274
+ className="opacity-25"
275
+ cx="12"
276
+ cy="12"
277
+ r="10"
278
+ stroke="currentColor"
279
+ strokeWidth="4"
280
+ />
281
+ <path
282
+ className="opacity-75"
283
+ fill="currentColor"
284
+ d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
285
+ />
286
+ </svg>
287
+ ) : impressionStatus === 'completed' ? (
288
+ <svg
289
+ className="w-5 h-5 text-green-500"
290
+ xmlns="http://www.w3.org/2000/svg"
291
+ viewBox="0 0 20 20"
292
+ fill="currentColor"
293
+ >
294
+ <path
295
+ fillRule="evenodd"
296
+ d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
297
+ clipRule="evenodd"
298
+ />
299
+ </svg>
300
+ ) : null}
301
+ </div>
302
+ )}
303
+ </div>
304
+ {/* TheAd Vantage branding bar */}
241
305
  <a
242
- href={ad.targetUrl}
243
- onClick={handleClick}
306
+ href="https://www.thead-vantage.com"
244
307
  target="_blank"
245
308
  rel="noopener noreferrer"
246
- className="block"
309
+ className="block bg-black text-yellow-400 hover:text-yellow-300 text-xs font-medium py-1.5 px-2 text-center rounded-b transition-colors"
310
+ style={{ width: ad.width || 300 }}
247
311
  >
248
- {(ad.type === 'image' || ad.type === 'standard') && ad.contentUrl ? (
249
- <Image
250
- src={ad.contentUrl}
251
- alt={ad.name}
252
- width={ad.width || 300}
253
- height={ad.height || 250}
254
- className="rounded"
255
- unoptimized
256
- onError={(e) => {
257
- // If the logo fails to load (e.g., not in public folder when installed from npm),
258
- // try loading from CDN
259
- if (ad.id === 'thead-vantage-fallback' && ad.contentUrl === '/TheAd-Vantage-Logo.png') {
260
- const target = e.target as HTMLImageElement;
261
- target.src = 'https://www.thead-vantage.com/assets/TheAd-Vantage-Logo.png';
262
- }
263
- }}
264
- />
265
- ) : (
266
- <div className="flex items-center justify-center bg-gray-200 dark:bg-gray-700 rounded" style={{ width: ad.width || 300, height: ad.height || 250 }}>
267
- <span className="text-sm text-gray-500">Ad content</span>
268
- </div>
269
- )}
312
+ Advertise with thead-vantage.com
270
313
  </a>
271
- {showImpressionFinished && impressionStatus !== 'pending' && (
272
- <div className="absolute top-2 right-2">
273
- {impressionStatus === 'counting' ? (
274
- <svg
275
- className="w-5 h-5 text-gray-400 animate-spin"
276
- xmlns="http://www.w3.org/2000/svg"
277
- fill="none"
278
- viewBox="0 0 24 24"
279
- >
280
- <circle
281
- className="opacity-25"
282
- cx="12"
283
- cy="12"
284
- r="10"
285
- stroke="currentColor"
286
- strokeWidth="4"
287
- />
288
- <path
289
- className="opacity-75"
290
- fill="currentColor"
291
- d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
292
- />
293
- </svg>
294
- ) : impressionStatus === 'completed' ? (
295
- <svg
296
- className="w-5 h-5 text-green-500"
297
- xmlns="http://www.w3.org/2000/svg"
298
- viewBox="0 0 20 20"
299
- fill="currentColor"
300
- >
301
- <path
302
- fillRule="evenodd"
303
- d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
304
- clipRule="evenodd"
305
- />
306
- </svg>
307
- ) : null}
308
- </div>
309
- )}
310
314
  {devMode && (
311
315
  <p className="text-xs text-gray-500 mt-1">[DEV] No tracking active</p>
312
316
  )}
@@ -3,28 +3,50 @@
3
3
  *
4
4
  * Provides fallback assets that work both in the library and when installed from npm.
5
5
  *
6
- * Note: When the library is installed from npm, the public folder isn't available.
7
- * The logo is loaded from a CDN URL that works in all environments.
6
+ * The logo is imported as a module so it gets bundled with the library.
7
+ * Next.js will process this import and create a URL that works in consuming applications.
8
8
  */
9
9
 
10
+ // Import the logo image - Next.js will process this and bundle it
11
+ // When the library is used in other Next.js apps, the image will be available
12
+ import theadVantageLogoSrc from '../assets/TheAd-Vantage-Logo.png';
13
+
10
14
  /**
11
15
  * Get the URL for the TheAd Vantage logo fallback ad
12
16
  *
13
- * Uses a CDN URL that works when the library is installed from npm.
14
- * For local development of the library itself, it will try the public folder first.
17
+ * Uses the imported image module. Next.js processes image imports and creates
18
+ * a URL that points to the bundled asset. This works when the library is installed
19
+ * from npm because the image is included in the library bundle.
15
20
  */
16
21
  export function getTheadVantageLogoUrl(): string {
17
- // Check if we're in the library's own development environment
18
- // (where the public folder exists)
19
- if (typeof window !== 'undefined') {
20
- // Try public folder first (works in library's own dev environment)
21
- // This will 404 when installed from npm, but that's okay - the Image component will handle it
22
- // and we can add error handling if needed
23
- return '/TheAd-Vantage-Logo.png';
22
+ // Next.js processes image imports and returns either:
23
+ // - A string URL (in some configurations)
24
+ // - An object with src, width, height properties (typical Next.js behavior)
25
+
26
+ if (typeof theadVantageLogoSrc === 'string') {
27
+ return theadVantageLogoSrc;
28
+ }
29
+
30
+ // Next.js Image import typically returns an object with src property
31
+ if (typeof theadVantageLogoSrc === 'object' && theadVantageLogoSrc !== null) {
32
+ // Check for src property (Next.js ImageStaticImport type)
33
+ if ('src' in theadVantageLogoSrc) {
34
+ return (theadVantageLogoSrc as { src: string }).src;
35
+ }
36
+ // Some bundlers might return the object directly with a default export
37
+ if ('default' in theadVantageLogoSrc) {
38
+ const defaultExport = (theadVantageLogoSrc as { default: string | { src: string } }).default;
39
+ if (typeof defaultExport === 'string') {
40
+ return defaultExport;
41
+ }
42
+ if (typeof defaultExport === 'object' && defaultExport !== null && 'src' in defaultExport) {
43
+ return (defaultExport as { src: string }).src;
44
+ }
45
+ }
24
46
  }
25
47
 
26
- // Server-side: return public folder path
27
- return '/TheAd-Vantage-Logo.png';
48
+ // Fallback to CDN if import doesn't work as expected
49
+ return 'https://www.thead-vantage.com/assets/TheAd-Vantage-Logo.png';
28
50
  }
29
51
 
30
52
  /**