Skip to content

Commit

Permalink
Merge pull request #774 from Financial-Times/am/inject-promotional-co…
Browse files Browse the repository at this point in the history
…ntent

[CON-3298] Inject promotional content inside Teaser
  • Loading branch information
metart43 authored Apr 10, 2024
2 parents 849491d + 0018228 commit 6f53c5b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions components/x-teaser/Props.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface Features {
showVideo?: boolean
showRelatedLinks?: boolean
showCustomSlot?: boolean
showPromotionalContent?: boolean
}

export interface General {
Expand Down
26 changes: 14 additions & 12 deletions components/x-teaser/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Because teasers are very complex with thousands of possible permutations the com
- Headshot, an image of the content author when content is published in their column
- Video, for video content able to play videos in-situ
- Custom slot, a free slot to insert custom components or markup
- Promotional content, a slot to insert promotional content of different types such as but not limited to: clips, interactive graphics, etc.

![screenshot of a teaser with features highlighted](https://user-images.githubusercontent.com/271645/38372758-7b55beac-38e7-11e8-9529-6286f384b7ce.png)

Expand Down Expand Up @@ -107,18 +108,19 @@ As covered in the [features](#features) documentation the teaser properties, or

#### Feature Props

| Feature | Type | Notes |
| ------------------ | ------- | --------------------------------------- |
| `showMeta` | Boolean |
| `showTitle` | Boolean |
| `showStandfirst` | Boolean |
| `showStatus` | Boolean |
| `showImage` | Boolean |
| `showHeadshot` | Boolean | Takes precedence over image |
| `showVideo` | Boolean | Takes precedence over image or headshot |
| `showGuidance` | Boolean | Show video captions guidance |
| `showRelatedLinks` | Boolean |
| `showCustomSlot` | Boolean |
| Feature | Type | Notes |
| ------------------------ | ------- | --------------------------------------- |
| `showMeta` | Boolean |
| `showTitle` | Boolean |
| `showStandfirst` | Boolean |
| `showStatus` | Boolean |
| `showImage` | Boolean |
| `showHeadshot` | Boolean | Takes precedence over image |
| `showVideo` | Boolean | Takes precedence over image or headshot |
| `showGuidance` | Boolean | Show video captions guidance |
| `showRelatedLinks` | Boolean |
| `showCustomSlot` | Boolean |
| `showPromotionalContent` | Boolean |

#### General Props

Expand Down
7 changes: 7 additions & 0 deletions components/x-teaser/src/PromotionaContent.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { h } from '@financial-times/x-engine'

const PromotionalContent = ({ promotionalContent }) => (
<div className="o-teaser__promotional-content">{promotionalContent}</div>
)

export default PromotionalContent
2 changes: 2 additions & 0 deletions components/x-teaser/src/Teaser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Status from './Status'
import Standfirst from './Standfirst'
import Title from './Title'
import Video from './Video'
import PromotionalContent from './PromotionaContent'
import { media } from './concerns/rules'
import presets from './concerns/presets'

Expand All @@ -24,6 +25,7 @@ const Teaser = (props) => (
{props.showCustomSlot ? <CustomSlot {...props} /> : null}
{media(props) === 'headshot' ? <Headshot {...props} /> : null}
</Content>
{media(props) === 'promotionalContent' ? <PromotionalContent {...props} /> : null}
{media(props) === 'image' ? <Image {...props} /> : null}
{props.showRelatedLinks ? <RelatedLinks {...props} /> : null}
</Container>
Expand Down
4 changes: 4 additions & 0 deletions components/x-teaser/src/concerns/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const rulesets = {
if (props.showImage && props.image && props.image.url) {
return 'image'
}

if (props.showPromotionalContent && props.promotionalContent) {
return 'promotionalContent'
}
},
theme: (props) => {
if (props.theme) {
Expand Down

0 comments on commit 6f53c5b

Please sign in to comment.