Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.

Commit 48b69b4

Browse files
Merge pull request #42 from Financial-Times/add-duration
Add duration to heavy template
2 parents 8d25844 + ae4240c commit 48b69b4

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/data-model/fragments.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ module.exports = {
6969
height
7070
ratio
7171
}
72+
...on Video {
73+
duration
74+
}
7275
}
7376
`,
7477
teaserTopStory: `

src/presenters/teaser-presenter.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ const TeaserPresenter = class TeaserPresenter {
9595
}
9696
}
9797

98+
// returns duration in the format m:ss
99+
get formattedDuration () {
100+
const duration = this.data.duration;
101+
if (duration > 0) {
102+
const minutes = Math.floor(duration / (1000 * 60));
103+
const seconds = Math.round(duration / 1000) - (minutes * 60);
104+
return `${minutes}.${seconds < 10 ? '0' : ''}${seconds}`;
105+
}
106+
}
107+
98108
//returns prefix for timestamp (null / 'new' / 'updated')
99109
timeStatus () {
100110
const now = Date.now();

templates/partials/display-tag.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
{{@nTeaserPresenter.displayTag.prefLabel}}
88
</a>
99
{{/if}}
10+
{{#with @nTeaserPresenter.formattedDuration}}
11+
<p class="o-teaser__duration">{{this}}min</p>
12+
{{/with}}
1013
{{#if advertiser}}
1114
<span class="o-teaser__promoted-prefix">{{promotedByPrefix}}</span> by <span class="o-teaser__promoted-by">{{advertiser}}</span>
1215
{{/if}}

0 commit comments

Comments
 (0)