Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support embedded Youtube Atom in Card #8075

Merged
merged 4 commits into from
Jul 5, 2023
Merged

Support embedded Youtube Atom in Card #8075

merged 4 commits into from
Jul 5, 2023

Conversation

mxdvl
Copy link
Contributor

@mxdvl mxdvl commented Jun 28, 2023

What does this change?

Enables support for showVideo from facia-tool, which allows videos to be played inline/embedded directly on fronts. Previously, it would redirect to the article itself.

A minimum Card width of one third or three columns is required for the YouTube atom to be embedded, similar to the existing Frontend logic.

Why?

Closes #6662

Known issues

There is currently no guarantee that the first atom will be the expected video, but it happens to be the case the vast majority of the time. See guardian/frontend#26247 for a possible fix.

Currently, only Youtube Atoms are supported.

Screenshots

Frontend DCR before DCR After
frontend before after

@github-actions
Copy link

github-actions bot commented Jun 28, 2023

Size Change: -22.7 kB (-4%)

Total Size: 622 kB

Filename Size Change
dotcom-rendering/dist/1981.modern.********************.js 0 B -3.92 kB (removed) 🏆
dotcom-rendering/dist/3267.modern.********************.js 0 B -3.14 kB (removed) 🏆
dotcom-rendering/dist/3890.modern.********************.js 0 B -2.3 kB (removed) 🏆
dotcom-rendering/dist/4482.modern.********************.js 0 B -4.98 kB (removed) 🏆
dotcom-rendering/dist/4931.modern.********************.js 0 B -3.25 kB (removed) 🏆
dotcom-rendering/dist/657.modern.********************.js 0 B -2.44 kB (removed) 🏆
dotcom-rendering/dist/771.modern.********************.js 0 B -3.17 kB (removed) 🏆
dotcom-rendering/dist/8082.modern.********************.js 0 B -3.97 kB (removed) 🏆
dotcom-rendering/dist/DiscussionContainer-importable.modern.********************.js 23.7 kB +1.5 kB (+7%) 🔍
dotcom-rendering/dist/LatestLinks-importable.modern.********************.js 4.64 kB +2.79 kB (+151%) 🆘
dotcom-rendering/dist/ShowMore-importable.modern.********************.js 5.39 kB +218 B (+4%)
ℹ️ View Unchanged
Filename Size Change
dotcom-rendering/dist/1179.modern.********************.js 2.49 kB 0 B
dotcom-rendering/dist/1244.modern.********************.js 868 B 0 B
dotcom-rendering/dist/1294.modern.********************.js 5.34 kB 0 B
dotcom-rendering/dist/1321.modern.********************.js 2.29 kB 0 B
dotcom-rendering/dist/1355.modern.********************.js 3.7 kB 0 B
dotcom-rendering/dist/1406.modern.********************.js 4.96 kB 0 B
dotcom-rendering/dist/1465.modern.********************.js 3.31 kB 0 B
dotcom-rendering/dist/1486.modern.********************.js 745 B 0 B
dotcom-rendering/dist/1848.modern.********************.js 644 B 0 B
dotcom-rendering/dist/187.modern.********************.js 3.22 kB 0 B
dotcom-rendering/dist/1948.modern.********************.js 1.88 kB 0 B
dotcom-rendering/dist/1987.modern.********************.js 3.5 kB 0 B
dotcom-rendering/dist/1997.modern.********************.js 746 B 0 B
dotcom-rendering/dist/2071.modern.********************.js 745 B 0 B
dotcom-rendering/dist/2087.modern.********************.js 3.56 kB 0 B
dotcom-rendering/dist/21.modern.********************.js 757 B 0 B
dotcom-rendering/dist/2126.modern.********************.js 886 B 0 B
dotcom-rendering/dist/2201.modern.********************.js 779 B 0 B
dotcom-rendering/dist/2226.modern.********************.js 25.3 kB 0 B
dotcom-rendering/dist/2228.modern.********************.js 900 B 0 B
dotcom-rendering/dist/2339.modern.********************.js 777 B 0 B
dotcom-rendering/dist/2494.modern.********************.js 779 B 0 B
dotcom-rendering/dist/275.modern.********************.js 697 B 0 B
dotcom-rendering/dist/3024.modern.********************.js 622 B 0 B
dotcom-rendering/dist/3146.modern.********************.js 6.52 kB 0 B
dotcom-rendering/dist/3239.modern.********************.js 4.89 kB 0 B
dotcom-rendering/dist/3314.modern.********************.js 6.21 kB 0 B
dotcom-rendering/dist/3358.modern.********************.js 636 B 0 B
dotcom-rendering/dist/3549.modern.********************.js 21.3 kB 0 B
dotcom-rendering/dist/356.modern.********************.js 826 B 0 B
dotcom-rendering/dist/3569.modern.********************.js 2.49 kB 0 B
dotcom-rendering/dist/3960.modern.********************.js 619 B 0 B
dotcom-rendering/dist/4008.modern.********************.js 11.2 kB 0 B
dotcom-rendering/dist/4113.modern.********************.js 758 B 0 B
dotcom-rendering/dist/421.modern.********************.js 2.61 kB 0 B
dotcom-rendering/dist/4424.modern.********************.js 3.64 kB 0 B
dotcom-rendering/dist/4734.modern.********************.js 760 B 0 B
dotcom-rendering/dist/4811.modern.********************.js 2.54 kB 0 B
dotcom-rendering/dist/5021.modern.********************.js 963 B 0 B
dotcom-rendering/dist/5071.modern.********************.js 942 B 0 B
dotcom-rendering/dist/5141.modern.********************.js 3.9 kB 0 B
dotcom-rendering/dist/5210.modern.********************.js 636 B 0 B
dotcom-rendering/dist/5474.modern.********************.js 620 B 0 B
dotcom-rendering/dist/5974.modern.********************.js 744 B 0 B
dotcom-rendering/dist/6030.modern.********************.js 3.84 kB 0 B
dotcom-rendering/dist/6118.modern.********************.js 680 B 0 B
dotcom-rendering/dist/640.modern.********************.js 710 B 0 B
dotcom-rendering/dist/6437.modern.********************.js 868 B 0 B
dotcom-rendering/dist/6534.modern.********************.js 574 B 0 B
dotcom-rendering/dist/6541.modern.********************.js 815 B 0 B
dotcom-rendering/dist/6840.modern.********************.js 4.77 kB 0 B
dotcom-rendering/dist/7074.modern.********************.js 20.3 kB 0 B
dotcom-rendering/dist/7133.modern.********************.js 697 B 0 B
dotcom-rendering/dist/7305.modern.********************.js 886 B 0 B
dotcom-rendering/dist/7401.modern.********************.js 689 B 0 B
dotcom-rendering/dist/7569.modern.********************.js 4.28 kB 0 B
dotcom-rendering/dist/7688.modern.********************.js 815 B 0 B
dotcom-rendering/dist/786.modern.********************.js 475 B 0 B
dotcom-rendering/dist/8112.modern.********************.js 3.35 kB 0 B
dotcom-rendering/dist/8165.modern.********************.js 926 B 0 B
dotcom-rendering/dist/8170.modern.********************.js 491 B 0 B
dotcom-rendering/dist/8268.modern.********************.js 5.57 kB 0 B
dotcom-rendering/dist/8447.modern.********************.js 966 B 0 B
dotcom-rendering/dist/8505.modern.********************.js 556 B 0 B
dotcom-rendering/dist/8555.modern.********************.js 689 B 0 B
dotcom-rendering/dist/8622.modern.********************.js 860 B 0 B
dotcom-rendering/dist/8638.modern.********************.js 833 B 0 B
dotcom-rendering/dist/8834.modern.********************.js 3.53 kB 0 B
dotcom-rendering/dist/9164.modern.********************.js 3.93 kB 0 B
dotcom-rendering/dist/9490.modern.********************.js 829 B 0 B
dotcom-rendering/dist/9766.modern.********************.js 4.64 kB 0 B
dotcom-rendering/dist/9812.modern.********************.js 2.75 kB 0 B
dotcom-rendering/dist/AlreadyVisited-importable.modern.********************.js 412 B 0 B
dotcom-rendering/dist/AnimatePulsingDots-importable.modern.********************.js 389 B 0 B
dotcom-rendering/dist/atomIframe.modern.********************.js 516 B 0 B
dotcom-rendering/dist/AudioAtomWrapper-importable.modern.********************.js 464 B 0 B
dotcom-rendering/dist/AustralianTerritorySwitcher-importable.modern.********************.js 4.43 kB 0 B
dotcom-rendering/dist/Branding-importable.modern.********************.js 2.19 kB 0 B
dotcom-rendering/dist/braze-web-sdk-core.modern.********************.js 36.9 kB 0 B
dotcom-rendering/dist/BrazeMessaging-importable.modern.********************.js 5.5 kB 0 B
dotcom-rendering/dist/CalloutBlockComponent-importable.modern.********************.js 6.47 kB 0 B
dotcom-rendering/dist/CalloutEmbedBlockComponent-importable.modern.********************.js 6.6 kB 0 B
dotcom-rendering/dist/Carousel-importable.modern.********************.js 5.96 kB +4 B (0%)
dotcom-rendering/dist/CarouselForNewsletters-importable.modern.********************.js 7.89 kB 0 B
dotcom-rendering/dist/ChartAtomWrapper-importable.modern.********************.js 476 B 0 B
dotcom-rendering/dist/CommentCount-importable.modern.********************.js 2.79 kB 0 B
dotcom-rendering/dist/discussion.modern.********************.js 394 B 0 B
dotcom-rendering/dist/DiscussionMeta-importable.modern.********************.js 3.74 kB 0 B
dotcom-rendering/dist/DocumentBlockComponent-importable.modern.********************.js 2.71 kB 0 B
dotcom-rendering/dist/EmbedBlockComponent-importable.modern.********************.js 3.25 kB 0 B
dotcom-rendering/dist/embedIframe.modern.********************.js 518 B 0 B
dotcom-rendering/dist/EnhancePinnedPost-importable.modern.********************.js 1.95 kB 0 B
dotcom-rendering/dist/FetchCommentCounts-importable.modern.********************.js 2.98 kB 0 B
dotcom-rendering/dist/FetchOnwardsData-importable.modern.********************.js 1.97 kB 0 B
dotcom-rendering/dist/FilterKeyEventsToggle-importable.modern.********************.js 3.42 kB 0 B
dotcom-rendering/dist/FocusStyles-importable.modern.********************.js 511 B 0 B
dotcom-rendering/dist/frameworks.modern.********************.js 20.8 kB 0 B
dotcom-rendering/dist/GetCricketScoreboard-importable.modern.********************.js 3.36 kB 0 B
dotcom-rendering/dist/GetMatchNav-importable.modern.********************.js 11.4 kB 0 B
dotcom-rendering/dist/GetMatchStats-importable.modern.********************.js 6.32 kB 0 B
dotcom-rendering/dist/GetMatchTabs-importable.modern.********************.js 2.42 kB 0 B
dotcom-rendering/dist/guardian-braze-components-banner.modern.********************.js 13.3 kB -1 B (0%)
dotcom-rendering/dist/guardian-braze-components-end-of-article.modern.********************.js 10.3 kB 0 B
dotcom-rendering/dist/GuideAtomWrapper-importable.modern.********************.js 476 B 0 B
dotcom-rendering/dist/HeaderTopBar-importable.modern.********************.js 10.8 kB 0 B
dotcom-rendering/dist/index.modern.********************.js 32.6 kB -42 B (0%)
dotcom-rendering/dist/InstagramBlockComponent-importable.modern.********************.js 2.78 kB 0 B
dotcom-rendering/dist/InteractiveBlockComponent-importable.modern.********************.js 5.8 kB 0 B
dotcom-rendering/dist/InteractiveContentsBlockComponent-importable.modern.********************.js 4.08 kB 0 B
dotcom-rendering/dist/InteractiveSupportButton-importable.modern.********************.js 4.14 kB 0 B
dotcom-rendering/dist/KeyEventsCarousel-importable.modern.********************.js 3.04 kB 0 B
dotcom-rendering/dist/KnowledgeQuizAtomWrapper-importable.modern.********************.js 483 B 0 B
dotcom-rendering/dist/LiveBlogEpic-importable.modern.********************.js 5.18 kB 0 B
dotcom-rendering/dist/Liveness-importable.modern.********************.js 5.53 kB 0 B
dotcom-rendering/dist/ManyNewsletterSignUp-importable.modern.********************.js 6.9 kB 0 B
dotcom-rendering/dist/MapEmbedBlockComponent-importable.modern.********************.js 5.31 kB 0 B
dotcom-rendering/dist/Metrics-importable.modern.********************.js 2.32 kB 0 B
dotcom-rendering/dist/MostViewedFooter-importable.modern.********************.js 5.36 kB 0 B
dotcom-rendering/dist/MostViewedFooterData-importable.modern.********************.js 7.57 kB 0 B
dotcom-rendering/dist/MostViewedRightWrapper-importable.modern.********************.js 3.8 kB 0 B
dotcom-rendering/dist/newsletterEmbedIframe.modern.********************.js 621 B 0 B
dotcom-rendering/dist/OnwardsUpper-importable.modern.********************.js 3.86 kB 0 B
dotcom-rendering/dist/PersonalityQuizAtomWrapper-importable.modern.********************.js 482 B 0 B
dotcom-rendering/dist/ProfileAtomWrapper-importable.modern.********************.js 478 B 0 B
dotcom-rendering/dist/QandaAtomWrapper-importable.modern.********************.js 477 B 0 B
dotcom-rendering/dist/ReaderRevenueDev-importable.modern.********************.js 460 B 0 B
dotcom-rendering/dist/readerRevenueDevUtils.modern.********************.js 3.01 kB 0 B
dotcom-rendering/dist/ReaderRevenueLinks-importable.modern.********************.js 5.85 kB 0 B
dotcom-rendering/dist/RecipeMultiplier-importable.modern.********************.js 3.26 kB 0 B
dotcom-rendering/dist/relativeTime.modern.********************.js 979 B 0 B
dotcom-rendering/dist/RichLinkComponent-importable.modern.********************.js 5.08 kB 0 B
dotcom-rendering/dist/SecureSignupIframe-importable.modern.********************.js 2.57 kB 0 B
dotcom-rendering/dist/SendAMessage-importable.modern.********************.js 4.37 kB 0 B
dotcom-rendering/dist/sentry.modern.********************.js 766 B 0 B
dotcom-rendering/dist/SetABTests-importable.modern.********************.js 3.75 kB 0 B
dotcom-rendering/dist/SetAdTargeting-importable.modern.********************.js 535 B 0 B
dotcom-rendering/dist/ShareCount-importable.modern.********************.js 2.92 kB 0 B
dotcom-rendering/dist/shimport.modern.********************.js 2.79 kB 0 B
dotcom-rendering/dist/ShowHideContainers-importable.modern.********************.js 719 B 0 B
dotcom-rendering/dist/SignInGateMain.modern.********************.js 2.96 kB 0 B
dotcom-rendering/dist/SignInGateMainCheckoutComplete.modern.********************.js 3.87 kB 0 B
dotcom-rendering/dist/SignInGateSelector-importable.modern.********************.js 3.9 kB 0 B
dotcom-rendering/dist/SlotBodyEnd-importable.modern.********************.js 2.91 kB 0 B
dotcom-rendering/dist/Snow-importable.modern.********************.js 4.22 kB 0 B
dotcom-rendering/dist/SpotifyBlockComponent-importable.modern.********************.js 5.16 kB 0 B
dotcom-rendering/dist/StickyBottomBanner-importable.modern.********************.js 4 kB 0 B
dotcom-rendering/dist/SubNav-importable.modern.********************.js 2.33 kB 0 B
dotcom-rendering/dist/SupportTheG-importable.modern.********************.js 5.96 kB 0 B
dotcom-rendering/dist/TableOfContents-importable.modern.********************.js 3.08 kB 0 B
dotcom-rendering/dist/TimelineAtomWrapper-importable.modern.********************.js 479 B 0 B
dotcom-rendering/dist/TopRightAdSlot-importable.modern.********************.js 634 B 0 B
dotcom-rendering/dist/TweetBlockComponent-importable.modern.********************.js 1.01 kB 0 B
dotcom-rendering/dist/UnsafeEmbedBlockComponent-importable.modern.********************.js 2.79 kB 0 B
dotcom-rendering/dist/VideoFacebookBlockComponent-importable.modern.********************.js 5.33 kB 0 B
dotcom-rendering/dist/VineBlockComponent-importable.modern.********************.js 2.65 kB 0 B
dotcom-rendering/dist/WeatherData-importable.modern.********************.js 4.33 kB 0 B
dotcom-rendering/dist/YoutubeBlockComponent-importable.modern.********************.js 953 B 0 B

compressed-size-action

@mxdvl mxdvl force-pushed the mxdvl/video-atom-in-card branch 2 times, most recently from fe71555 to 17bb65c Compare June 28, 2023 16:06
@mxdvl mxdvl changed the base branch from main to mxdvl/image-refactors June 28, 2023 16:10
@mxdvl mxdvl added the run_chromatic Runs chromatic when label is applied label Jun 28, 2023
@mxdvl mxdvl marked this pull request as ready for review June 28, 2023 16:13
@mxdvl mxdvl requested a review from a team as a code owner June 28, 2023 16:13
@mxdvl mxdvl force-pushed the mxdvl/video-atom-in-card branch from 17bb65c to 16b0ef7 Compare June 28, 2023 16:21
Copy link
Contributor Author

@mxdvl mxdvl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little code pointers below 👇

@@ -200,6 +200,7 @@ gen-schema:
@git add src/model/article-schema.json
@git add src/model/front-schema.json
@git add src/model/block-schema.json
@git add src/model/tag-front-schema.json
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small refactors since #7752 introduced the new schema

Comment on lines 198 to 212
// Size fixed to a 5:3 ratio
width: 500,
height: 300,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cards do not have a concept of an intrinsic size, and calculating the size of the poster image seemed brittle.

dotcom-rendering/src/types/front.ts Outdated Show resolved Hide resolved
dotcom-rendering/src/types/video.ts Outdated Show resolved Hide resolved
@mxdvl mxdvl added the 50% test label Jun 29, 2023
@mxdvl mxdvl mentioned this pull request Jun 29, 2023
13 tasks
Base automatically changed from mxdvl/image-refactors to main June 29, 2023 13:35
@mxdvl mxdvl force-pushed the mxdvl/video-atom-in-card branch from 16b0ef7 to b747b27 Compare June 29, 2023 14:05
@mxdvl mxdvl force-pushed the mxdvl/video-atom-in-card branch 2 times, most recently from 26309b2 to cf02622 Compare June 29, 2023 16:23
Copy link
Contributor

@jamesgorrie jamesgorrie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks great! Whilst it makes sense I got a bit confused.

Having two types for CardYoutubeVideo seemed a little leaky, especially as the transformation for either type is at different stages of the rendering pipeline (enhance vs cardWrappers.onlyKeepPlayIcon).

I wonder if we could make it more explicit of what we're doing with fewer transformations and follow some existing naming?

Here's a little pseudo code as I think I've been a little muddy in my explanation:

type DCRCardType = {
  // ...other props...

  // assuming this flattening is done as we prefer flat
  showMainVideo: FECardType.properties.showMainVideo;
  
  // video - this is identical to the image prop
  video = decideVideo(FECardType);
}



type FrontCard = {
  // ...other props...
  showVideo: DCRCardType.showMainVideo;
  video: DCRCardType.video;

  // Maybe this isn't size, but follows the same pattern as images
  // This gets in `cardWrappers` as that's what is aware of this context
  // it is existing also an explicit property, rather than a transformation to an existing property
  // it also doesn't leak the `show-only-icon` to `CardYoutubeVideo`
  videoSize: "unplayable" : "playable";
}

// Card.tsx
const Card = ({ showVideo, video, videoSize }) => {
  if (video && showVideo) {
    if (videoSize === "playable") <VideoPlayer />
    if (videoSize === "unplayable") <PosterWithIcon />
  } else {
    // image logic
  }
}

Comment on lines 478 to 479
{image.type === 'mainMedia' &&
mainVideo?.type !== 'embedded-playable-video' && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be tempted to swap this around to make the logic more analogous to:

if (isPlayableVideo) {
  <Youtube />
} else if (image = isMainMedia) {
  <CardPicture />
}

Not sure if it's clearer just took my a couple seconds to work out what was going on.

Suggested change
{image.type === 'mainMedia' &&
mainVideo?.type !== 'embedded-playable-video' && (
{mainVideo?.type !== 'embedded-playable-video' &&
image.type === 'mainMedia' && (

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering that too. Could not settle on a specific one so I’ll use your suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reasoning is that they aren't different types, it is rather a condition set by the parent component which has extra context.

Copy link
Contributor Author

@mxdvl mxdvl Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve refactored getImage so it becomes a discriminated union which helps clarify things a lot! It had strayed quite some way away from its original implementation in #6066 with #6815 and #7852.

dotcom-rendering/src/types/front.ts Outdated Show resolved Hide resolved
dotcom-rendering/src/types/front.ts Outdated Show resolved Hide resolved
@mxdvl mxdvl changed the base branch from main to mxdvl/refactor-ad-targeting June 30, 2023 13:51
@mxdvl mxdvl removed the run_chromatic Runs chromatic when label is applied label Jun 30, 2023
@mxdvl mxdvl force-pushed the mxdvl/refactor-ad-targeting branch from f2538d7 to d36891e Compare June 30, 2023 14:53
@mxdvl mxdvl force-pushed the mxdvl/video-atom-in-card branch 3 times, most recently from 838a3aa to 1257340 Compare June 30, 2023 16:21
@mxdvl mxdvl added the run_chromatic Runs chromatic when label is applied label Jun 30, 2023
expired?: boolean;
activeVersion?: number;
/** @deprecated */
channelId?: unknown;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are defaultHtml and channelId unknown and not string?

Copy link
Contributor Author

@mxdvl mxdvl Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on a similar question by @jamesgorrie I decided to remove them, but somehow forgot.

My thinking was that we knew these fields come through, but we are not currently using them in any meaningful way. I wanted to make it clear to future travellers. I’ll just comment them out for now.

@mxdvl mxdvl force-pushed the mxdvl/video-atom-in-card branch from 6757511 to b99c0c0 Compare July 3, 2023 09:03
@mxdvl mxdvl requested review from ioannakok and jamesgorrie July 3, 2023 09:25
Copy link
Contributor

@ioannakok ioannakok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! You have a +1 from me, don't know if it's best to also get @jamesgorrie's approval as he made all these great suggestions. My only doubt is:

export type VideoSize = 'playable' | 'unplayable';

If we could name this something more relevant to the values it gets, that would be preferable but it's not a blocker.

alt={byline ?? ''}
containerPalette={containerPalette}
format={format}
/>
</AvatarContainer>
)}
{image.type === 'video' && (
<div
data-chromatic="ignore"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chromatic will ignore the content of this element – ping @cemms1.

@mxdvl mxdvl force-pushed the mxdvl/video-atom-in-card branch 2 times, most recently from d96fdeb to 591a366 Compare July 4, 2023 09:47
@mxdvl mxdvl changed the base branch from main to ab/video-card-redesign July 4, 2023 09:50
@mxdvl
Copy link
Contributor Author

mxdvl commented Jul 4, 2023

Waiting on #7972 before merging cc @abeddow91

@mxdvl mxdvl force-pushed the mxdvl/video-atom-in-card branch from 591a366 to 30da4a6 Compare July 4, 2023 09:58
@abeddow91 abeddow91 force-pushed the ab/video-card-redesign branch from ea61540 to 1a01a5b Compare July 4, 2023 14:57
@mxdvl mxdvl force-pushed the mxdvl/video-atom-in-card branch from 30da4a6 to 3b08554 Compare July 4, 2023 15:18
Base automatically changed from ab/video-card-redesign to main July 4, 2023 15:36
@mxdvl mxdvl force-pushed the mxdvl/video-atom-in-card branch from 3b08554 to df5ac31 Compare July 4, 2023 17:00
@mxdvl mxdvl requested review from abeddow91 and ioannakok July 4, 2023 17:07
@@ -289,9 +309,7 @@ export type DCRFrontCard = {
byline?: string;
showByline?: boolean;
avatarUrl?: string;
mediaType?: MediaType;
mediaDuration?: number;
showMainVideo: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not find examples of when we want to hide the main video, so have removed as a simplication step.

Copy link
Member

@arelra arelra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A fine example of a collaborative PR!

@mxdvl mxdvl force-pushed the mxdvl/video-atom-in-card branch from df5ac31 to ba8703a Compare July 5, 2023 14:09
mxdvl added 3 commits July 5, 2023 16:21
renamed the method as it can handle more than images

we can narrow our types with a discriminated union
an empty array should result in no poster image available.
@mxdvl mxdvl force-pushed the mxdvl/video-atom-in-card branch from ba8703a to 9ddf882 Compare July 5, 2023 15:28
The settings comes from the facia-tool via Frontend,
when “Show Video” is enabled for a trail in a container,
it should be displayed as a playable video inline instead
or redirecting to the article itself.

Currently, only Youtube Atoms are supported.

There is currently no guarantee that the first atom will be the expected
video, but it happens to be the case the vast majority of the time

A minimum Card width of one third or three columns is required for
the YouTube atom to be embedded, similar to the existing Frontend logic:
https://github.com/guardian/frontend/blob/1c4555a9f/common/app/layout/cards/CardType.scala#L20-L23
@mxdvl mxdvl force-pushed the mxdvl/video-atom-in-card branch from 9ddf882 to 14f65ea Compare July 5, 2023 15:37
@mxdvl mxdvl merged commit b9be647 into main Jul 5, 2023
@mxdvl mxdvl deleted the mxdvl/video-atom-in-card branch July 5, 2023 16:35
mediaDuration:
faciaCard.properties.maybeContent?.elements.mediaAtoms[0]
?.duration,
showMainVideo: faciaCard.properties.showMainVideo,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrectly removing this caused #8227

/** For displaying embedded, playable videos directly in cards */
type Video = Media & {
type: 'Video';
elementId: string;
Copy link
Contributor Author

@mxdvl mxdvl Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not have been called elementId but simply id. It’s not the randomly generated frontend UUID, but rather a consistent value that uniquely identifies the main media atom.

Fix in #10218

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show video
4 participants