@financial-times/x-teaser 10.1.0 → 10.1.2

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/Props.d.ts CHANGED
@@ -142,6 +142,7 @@ export interface Media {
142
142
  url: string
143
143
  width: number
144
144
  height: number
145
+ altText?: string
145
146
  }
146
147
 
147
148
  export interface Indicators {
@@ -20,7 +20,8 @@
20
20
  "image": {
21
21
  "url": "http://com.ft.imagepublish.upp-prod-eu.s3.amazonaws.com/a27ce49b-85b8-445b-b883-db6e2f533194",
22
22
  "width": 1920,
23
- "height": 1080
23
+ "height": 1080,
24
+ "altText": "Image alt text"
24
25
  },
25
26
  "video": {
26
27
  "url": "https://next-media-api.ft.com/renditions/15218247321960/640x360.mp4",
@@ -569,7 +569,7 @@ exports[`x-teaser / snapshots renders a Hero teaser with video data 1`] = `
569
569
  }
570
570
  >
571
571
  <img
572
- alt=""
572
+ alt="Image alt text"
573
573
  className="o-teaser__image"
574
574
  src="https://www.ft.com/__origami/service/image/v2/images/raw/http%3A%2F%2Fcom.ft.imagepublish.upp-prod-eu.s3.amazonaws.com%2Fa27ce49b-85b8-445b-b883-db6e2f533194?source=next&fit=scale-down&dpr=2&width=340"
575
575
  />
@@ -1647,7 +1647,7 @@ exports[`x-teaser / snapshots renders a HeroOverlay teaser with video data 1`] =
1647
1647
  }
1648
1648
  >
1649
1649
  <img
1650
- alt=""
1650
+ alt="Image alt text"
1651
1651
  className="o-teaser__image"
1652
1652
  src="https://www.ft.com/__origami/service/image/v2/images/raw/http%3A%2F%2Fcom.ft.imagepublish.upp-prod-eu.s3.amazonaws.com%2Fa27ce49b-85b8-445b-b883-db6e2f533194?source=next&fit=scale-down&dpr=2&width=640"
1653
1653
  />
@@ -2067,7 +2067,7 @@ exports[`x-teaser / snapshots renders a HeroVideo teaser with video data 1`] = `
2067
2067
  }
2068
2068
  >
2069
2069
  <img
2070
- alt=""
2070
+ alt="Image alt text"
2071
2071
  className="o-teaser__image"
2072
2072
  src="https://www.ft.com/__origami/service/image/v2/images/raw/http%3A%2F%2Fcom.ft.imagepublish.upp-prod-eu.s3.amazonaws.com%2Fa27ce49b-85b8-445b-b883-db6e2f533194?source=next&fit=scale-down&dpr=2&width=420"
2073
2073
  />
@@ -2781,7 +2781,7 @@ exports[`x-teaser / snapshots renders a Large teaser with video data 1`] = `
2781
2781
  }
2782
2782
  >
2783
2783
  <img
2784
- alt=""
2784
+ alt="Image alt text"
2785
2785
  className="o-teaser__image"
2786
2786
  src="https://www.ft.com/__origami/service/image/v2/images/raw/http%3A%2F%2Fcom.ft.imagepublish.upp-prod-eu.s3.amazonaws.com%2Fa27ce49b-85b8-445b-b883-db6e2f533194?source=next&fit=scale-down&dpr=2&width=340"
2787
2787
  />
@@ -3859,7 +3859,7 @@ exports[`x-teaser / snapshots renders a SmallHeavy teaser with video data 1`] =
3859
3859
  }
3860
3860
  >
3861
3861
  <img
3862
- alt=""
3862
+ alt="Image alt text"
3863
3863
  className="o-teaser__image"
3864
3864
  src="https://www.ft.com/__origami/service/image/v2/images/raw/http%3A%2F%2Fcom.ft.imagepublish.upp-prod-eu.s3.amazonaws.com%2Fa27ce49b-85b8-445b-b883-db6e2f533194?source=next&fit=scale-down&dpr=2&width=240"
3865
3865
  />
@@ -5131,7 +5131,7 @@ exports[`x-teaser / snapshots renders a TopStoryLandscape teaser with video data
5131
5131
  }
5132
5132
  >
5133
5133
  <img
5134
- alt=""
5134
+ alt="Image alt text"
5135
5135
  className="o-teaser__image"
5136
5136
  src="https://www.ft.com/__origami/service/image/v2/images/raw/http%3A%2F%2Fcom.ft.imagepublish.upp-prod-eu.s3.amazonaws.com%2Fa27ce49b-85b8-445b-b883-db6e2f533194?source=next&fit=scale-down&dpr=2&width=640"
5137
5137
  />
@@ -211,21 +211,23 @@ const aspectRatio = ({
211
211
  return null;
212
212
  };
213
213
  const NormalImage = ({
214
- src
214
+ src,
215
+ alt
215
216
  }) => xEngine.h("img", {
216
217
  className: "o-teaser__image",
217
218
  src: src,
218
- alt: ""
219
+ alt: alt
219
220
  });
220
221
  const LazyImage = ({
221
222
  src,
222
- lazyLoad
223
+ lazyLoad,
224
+ alt
223
225
  }) => {
224
226
  const lazyClassName = typeof lazyLoad === 'string' ? lazyLoad : '';
225
227
  return xEngine.h("img", {
226
228
  className: `o-teaser__image ${lazyClassName}`,
227
229
  "data-src": src,
228
- alt: ""
230
+ alt: alt
229
231
  });
230
232
  };
231
233
  var Image = (({
@@ -246,6 +248,7 @@ var Image = (({
246
248
  quality: 'highest'
247
249
  } : {};
248
250
  const imageSrc = useImageService ? imageService(image.url, ImageSizes[imageSize], options) : image.url;
251
+ const alt = (image.altText || '').trim();
249
252
  const ImageComponent = imageLazyLoad ? LazyImage : NormalImage;
250
253
  return xEngine.h("div", {
251
254
  className: "o-teaser__image-container js-teaser-image-container"
@@ -263,7 +266,8 @@ var Image = (({
263
266
  }
264
267
  }, xEngine.h(ImageComponent, {
265
268
  src: imageSrc,
266
- lazyLoad: imageLazyLoad
269
+ lazyLoad: imageLazyLoad,
270
+ alt: alt
267
271
  }))));
268
272
  });
269
273
 
@@ -295,21 +295,23 @@ var aspectRatio = function aspectRatio(_ref) {
295
295
  return null;
296
296
  };
297
297
  var NormalImage = function NormalImage(_ref2) {
298
- var src = _ref2.src;
298
+ var src = _ref2.src,
299
+ alt = _ref2.alt;
299
300
  return xEngine.h("img", {
300
301
  className: "o-teaser__image",
301
302
  src: src,
302
- alt: ""
303
+ alt: alt
303
304
  });
304
305
  };
305
306
  var LazyImage = function LazyImage(_ref3) {
306
307
  var src = _ref3.src,
307
- lazyLoad = _ref3.lazyLoad;
308
+ lazyLoad = _ref3.lazyLoad,
309
+ alt = _ref3.alt;
308
310
  var lazyClassName = typeof lazyLoad === 'string' ? lazyLoad : '';
309
311
  return xEngine.h("img", {
310
312
  className: "o-teaser__image ".concat(lazyClassName),
311
313
  "data-src": src,
312
- alt: ""
314
+ alt: alt
313
315
  });
314
316
  };
315
317
  var Image = (function (_ref4) {
@@ -329,6 +331,7 @@ var Image = (function (_ref4) {
329
331
  quality: 'highest'
330
332
  } : {};
331
333
  var imageSrc = useImageService ? imageService(image.url, ImageSizes[imageSize], options) : image.url;
334
+ var alt = (image.altText || '').trim();
332
335
  var ImageComponent = imageLazyLoad ? LazyImage : NormalImage;
333
336
  return xEngine.h("div", {
334
337
  className: "o-teaser__image-container js-teaser-image-container"
@@ -346,7 +349,8 @@ var Image = (function (_ref4) {
346
349
  }
347
350
  }, xEngine.h(ImageComponent, {
348
351
  src: imageSrc,
349
- lazyLoad: imageLazyLoad
352
+ lazyLoad: imageLazyLoad,
353
+ alt: alt
350
354
  }))));
351
355
  });
352
356
 
@@ -205,21 +205,23 @@ const aspectRatio = ({
205
205
  return null;
206
206
  };
207
207
  const NormalImage = ({
208
- src
208
+ src,
209
+ alt
209
210
  }) => h("img", {
210
211
  className: "o-teaser__image",
211
212
  src: src,
212
- alt: ""
213
+ alt: alt
213
214
  });
214
215
  const LazyImage = ({
215
216
  src,
216
- lazyLoad
217
+ lazyLoad,
218
+ alt
217
219
  }) => {
218
220
  const lazyClassName = typeof lazyLoad === 'string' ? lazyLoad : '';
219
221
  return h("img", {
220
222
  className: `o-teaser__image ${lazyClassName}`,
221
223
  "data-src": src,
222
- alt: ""
224
+ alt: alt
223
225
  });
224
226
  };
225
227
  var Image = (({
@@ -240,6 +242,7 @@ var Image = (({
240
242
  quality: 'highest'
241
243
  } : {};
242
244
  const imageSrc = useImageService ? imageService(image.url, ImageSizes[imageSize], options) : image.url;
245
+ const alt = (image.altText || '').trim();
243
246
  const ImageComponent = imageLazyLoad ? LazyImage : NormalImage;
244
247
  return h("div", {
245
248
  className: "o-teaser__image-container js-teaser-image-container"
@@ -257,7 +260,8 @@ var Image = (({
257
260
  }
258
261
  }, h(ImageComponent, {
259
262
  src: imageSrc,
260
- lazyLoad: imageLazyLoad
263
+ lazyLoad: imageLazyLoad,
264
+ alt: alt
261
265
  }))));
262
266
  });
263
267
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/x-teaser",
3
- "version": "10.1.0",
3
+ "version": "10.1.2",
4
4
  "description": "This module provides templates for use with o-teaser. Teasers are used to present content.",
5
5
  "source": "src/Teaser.jsx",
6
6
  "main": "dist/Teaser.cjs.js",
@@ -18,7 +18,7 @@
18
18
  "author": "",
19
19
  "license": "ISC",
20
20
  "dependencies": {
21
- "@financial-times/x-engine": "^10.1.0",
21
+ "@financial-times/x-engine": "^10.1.2",
22
22
  "date-fns": "^1.29.0",
23
23
  "dateformat": "^3.0.3"
24
24
  },
package/src/Image.jsx CHANGED
@@ -17,11 +17,11 @@ const aspectRatio = ({ width, height }) => {
17
17
  return null
18
18
  }
19
19
 
20
- const NormalImage = ({ src }) => <img className="o-teaser__image" src={src} alt="" />
20
+ const NormalImage = ({ src, alt }) => <img className="o-teaser__image" src={src} alt={alt} />
21
21
 
22
- const LazyImage = ({ src, lazyLoad }) => {
22
+ const LazyImage = ({ src, lazyLoad, alt }) => {
23
23
  const lazyClassName = typeof lazyLoad === 'string' ? lazyLoad : ''
24
- return <img className={`o-teaser__image ${lazyClassName}`} data-src={src} alt="" />
24
+ return <img className={`o-teaser__image ${lazyClassName}`} data-src={src} alt={alt} />
25
25
  }
26
26
 
27
27
  export default ({ relativeUrl, url, image, imageSize, imageLazyLoad, imageHighestQuality, ...props }) => {
@@ -32,6 +32,7 @@ export default ({ relativeUrl, url, image, imageSize, imageLazyLoad, imageHighes
32
32
  const useImageService = !(image.url.startsWith('data:') || image.url.startsWith('blob:'))
33
33
  const options = imageSize === 'XXL' && imageHighestQuality ? { quality: 'highest' } : {}
34
34
  const imageSrc = useImageService ? imageService(image.url, ImageSizes[imageSize], options) : image.url
35
+ const alt = (image.altText || '').trim()
35
36
  const ImageComponent = imageLazyLoad ? LazyImage : NormalImage
36
37
 
37
38
  return (
@@ -43,9 +44,10 @@ export default ({ relativeUrl, url, image, imageSize, imageLazyLoad, imageHighes
43
44
  'data-trackable': 'image-link',
44
45
  tabIndex: '-1',
45
46
  'aria-hidden': 'true'
46
- }}>
47
+ }}
48
+ >
47
49
  <div className="o-teaser__image-placeholder" style={{ paddingBottom: aspectRatio(image) }}>
48
- <ImageComponent src={imageSrc} lazyLoad={imageLazyLoad} />
50
+ <ImageComponent src={imageSrc} lazyLoad={imageLazyLoad} alt={alt} />
49
51
  </div>
50
52
  </Link>
51
53
  </div>