@financial-times/x-teaser 20.0.0-beta.1 → 20.0.0-beta.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
@@ -66,7 +66,7 @@ export interface Meta {
66
66
  /** @deprecated - use metaLinks instead */
67
67
  metaLink?: MetaLink
68
68
  /** @deprecated - use metaLinks instead
69
- * allback used if the parentId is the same as the display concept */
69
+ * Fallback used if the parentId is the same as the display concept */
70
70
  metaAltLink?: MetaLink
71
71
  /** Promoted content type */
72
72
  promotedPrefixText?: string
@@ -0,0 +1,19 @@
1
+ import sameLabel from '../src/concerns/same-label'
2
+
3
+ describe('same-label', () => {
4
+ describe('when label matches context.parentLabel', () => {
5
+ it('returns true', () => {
6
+ const context = { parentLabel: 'Opinion' }
7
+ const label = 'Opinion'
8
+ expect(sameLabel(context, label)).toBe(true)
9
+ })
10
+ })
11
+
12
+ describe('when label does not match context.parentLabel', () => {
13
+ it('returns false', () => {
14
+ const context = { parentLabel: 'Opinion' }
15
+ const label = 'News'
16
+ expect(sameLabel(context, label)).toBe(false)
17
+ })
18
+ })
19
+ })
@@ -342,9 +342,10 @@ var Image = ({
342
342
  }))));
343
343
  };
344
344
 
345
- const sameLabel = (context = {}, label) => {
346
- return label && context && context.parentLabel && label === context.parentLabel;
347
- };
345
+ function sameLabel(context = {}, label) {
346
+ return Boolean(label && label === (context === null || context === void 0 ? void 0 : context.parentLabel));
347
+ }
348
+
348
349
  const isLegacyMode = metaLinks => !Array.isArray(metaLinks);
349
350
  const getDisplayLink = ({
350
351
  metaLink,
@@ -664,7 +665,7 @@ var Title = ({
664
665
  className: 'js-teaser-heading-link',
665
666
  'aria-label': ariaLabel
666
667
  }
667
- }), showTitlePrefix && titlePrefix && xEngine.h("span", {
668
+ }), showTitlePrefix && titlePrefix && !sameLabel(props.context, titlePrefix) && xEngine.h("span", {
668
669
  className: "o-teaser__heading-prefix"
669
670
  }, `${titlePrefix}. `), displayTitle));
670
671
  };
@@ -856,6 +857,7 @@ Only render the Headshot when the media rule `headshot` is true,
856
857
  which means `showByline` is falsy. */
857
858
  media(props) === 'headshot' ? xEngine.h(Headshot, props) : null), media(props) === 'promotionalContent' ? xEngine.h(PromotionalContent, props) : null, media(props) === 'image' ? xEngine.h(Image, props) : null, props.showRelatedLinks ? xEngine.h(RelatedLinks, props) : null);
858
859
 
860
+ exports.Byline = Byline;
859
861
  exports.Container = Container;
860
862
  exports.Content = Content;
861
863
  exports.CustomSlot = CustomSlot;
@@ -485,11 +485,12 @@ var Image = (function (_ref4) {
485
485
  }))));
486
486
  });
487
487
 
488
- var sameLabel = function sameLabel() {
488
+ function sameLabel() {
489
489
  var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
490
490
  var label = arguments.length > 1 ? arguments[1] : undefined;
491
- return label && context && context.parentLabel && label === context.parentLabel;
492
- };
491
+ return Boolean(label && label === (context === null || context === void 0 ? void 0 : context.parentLabel));
492
+ }
493
+
493
494
  var isLegacyMode = function isLegacyMode(metaLinks) {
494
495
  return !Array.isArray(metaLinks);
495
496
  };
@@ -817,7 +818,7 @@ var Title = (function (_ref) {
817
818
  className: 'js-teaser-heading-link',
818
819
  'aria-label': ariaLabel
819
820
  }
820
- }), showTitlePrefix && titlePrefix && xEngine.h("span", {
821
+ }), showTitlePrefix && titlePrefix && !sameLabel(props.context, titlePrefix) && xEngine.h("span", {
821
822
  className: "o-teaser__heading-prefix"
822
823
  }, "".concat(titlePrefix, ". ")), displayTitle));
823
824
  });
@@ -1016,6 +1017,7 @@ var Teaser = function Teaser(props) {
1016
1017
  media(props) === 'headshot' ? xEngine.h(Headshot, props) : null), media(props) === 'promotionalContent' ? xEngine.h(PromotionalContent, props) : null, media(props) === 'image' ? xEngine.h(Image, props) : null, props.showRelatedLinks ? xEngine.h(RelatedLinks, props) : null);
1017
1018
  };
1018
1019
 
1020
+ exports.Byline = Byline;
1019
1021
  exports.Container = Container;
1020
1022
  exports.Content = Content;
1021
1023
  exports.CustomSlot = CustomSlot;
@@ -336,9 +336,10 @@ var Image = ({
336
336
  }))));
337
337
  };
338
338
 
339
- const sameLabel = (context = {}, label) => {
340
- return label && context && context.parentLabel && label === context.parentLabel;
341
- };
339
+ function sameLabel(context = {}, label) {
340
+ return Boolean(label && label === (context === null || context === void 0 ? void 0 : context.parentLabel));
341
+ }
342
+
342
343
  const isLegacyMode = metaLinks => !Array.isArray(metaLinks);
343
344
  const getDisplayLink = ({
344
345
  metaLink,
@@ -658,7 +659,7 @@ var Title = ({
658
659
  className: 'js-teaser-heading-link',
659
660
  'aria-label': ariaLabel
660
661
  }
661
- }), showTitlePrefix && titlePrefix && h("span", {
662
+ }), showTitlePrefix && titlePrefix && !sameLabel(props.context, titlePrefix) && h("span", {
662
663
  className: "o-teaser__heading-prefix"
663
664
  }, `${titlePrefix}. `), displayTitle));
664
665
  };
@@ -850,4 +851,4 @@ Only render the Headshot when the media rule `headshot` is true,
850
851
  which means `showByline` is falsy. */
851
852
  media(props) === 'headshot' ? h(Headshot, props) : null), media(props) === 'promotionalContent' ? h(PromotionalContent, props) : null, media(props) === 'image' ? h(Image, props) : null, props.showRelatedLinks ? h(RelatedLinks, props) : null);
852
853
 
853
- export { Container, Content, CustomSlot, Headshot, Image, Meta, RelatedLinks, Standfirst, Status, Teaser, Title, Video, presets };
854
+ export { Byline, Container, Content, CustomSlot, Headshot, Image, Meta, RelatedLinks, Standfirst, Status, Teaser, Title, Video, presets };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/x-teaser",
3
- "version": "20.0.0-beta.1",
3
+ "version": "20.0.0-beta.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": "^20.0.0-beta.1",
21
+ "@financial-times/x-engine": "^20.0.0-beta.2",
22
22
  "dateformat": "^3.0.3"
23
23
  },
24
24
  "devDependencies": {
package/src/MetaLink.jsx CHANGED
@@ -1,8 +1,5 @@
1
1
  import { h } from '@financial-times/x-engine'
2
-
3
- const sameLabel = (context = {}, label) => {
4
- return label && context && context.parentLabel && label === context.parentLabel
5
- }
2
+ import sameLabel from './concerns/same-label'
6
3
 
7
4
  const isLegacyMode = (metaLinks) => !Array.isArray(metaLinks)
8
5
 
package/src/Teaser.jsx CHANGED
@@ -46,6 +46,7 @@ export {
46
46
  Headshot,
47
47
  Image,
48
48
  Meta,
49
+ Byline,
49
50
  RelatedLinks,
50
51
  Standfirst,
51
52
  Status,
package/src/Title.jsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import { h } from '@financial-times/x-engine'
2
2
  import Link from './Link'
3
+ import sameLabel from './concerns/same-label'
3
4
 
4
5
  export default ({
5
6
  title,
@@ -33,7 +34,7 @@ export default ({
33
34
  'aria-label': ariaLabel
34
35
  }}
35
36
  >
36
- {showTitlePrefix && titlePrefix && (
37
+ {showTitlePrefix && titlePrefix && !sameLabel(props.context, titlePrefix) && (
37
38
  <span className="o-teaser__heading-prefix">{`${titlePrefix}. `}</span>
38
39
  )}
39
40
  {displayTitle}
@@ -0,0 +1,3 @@
1
+ export default function sameLabel(context = {}, label) {
2
+ return Boolean(label && label === context?.parentLabel)
3
+ }