-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add Youtube Embed Support to the ImageCard Component #3156
Conversation
df63f91
to
1d83fb6
Compare
@patrickpatrickpatrick lovely work. Small thing: I'd split this commit 1d83fb6 first into one where you refactor to split the partial, and then add in the youtube bits |
47b18ad
to
53711a2
Compare
53711a2
to
bbe47c0
Compare
bbe47c0
to
f09e622
Compare
f09e622
to
bb4b1f0
Compare
This is to support the upcoming YouTube card component [1] that makes use of YouTube thumbnails. Unlike most of the host directives in this file this one specifies the scheme to be https. My understanding is that it was an earlier mistake of ours not to specify schemes, since we expect any of these resources to be https. At a later point we can migrate the others. [1]: alphagov/govuk_publishing_components#3156
This is to support the upcoming YouTube card component [1] that makes use of YouTube thumbnails. Unlike most of the host directives in this file this one specifies the scheme to be https. My understanding is that it was an earlier mistake of ours not to specify schemes, since we expect any of these resources to be https. At a later point we can migrate the others. [1]: alphagov/govuk_publishing_components#3156
Obviously still draft so I won't do a full review but one concern I'd like to raise. At the moment the component auditing relies on the fact that component files use the same name for themselves (i.e. the image card component has an image card template, image card scss file, etc.) in order to report accurate information, but this change looks like it might break that convention. Would it be possible to have the filenames for the various parts of this match the component names in order to preserve how the auditing works? Happy to discuss if this isn't clear. |
I believe this should be the case in the way I've implemented it. Youtube card has a youtube_card.html.erb, yotube_card.js, youtube_card.scss; Image card has a image_card.html.erb, image_card.scss and media card has a media_card.html.erb and media_card.scss. |
Thanks for the offline chat @patrickpatrickpatrick I think I understand this better now. As discussed, I've plugged this branch into an application to test how the auditing responds. The auditing isn't detecting that the image card and youtube card components contain media card, and therefore doesn't correctly report problems to do with assets (e.g. not including the media card scss). It does allow for components that contain other components, but in this case the media card is considered a partial and not a top level component - it's importing There's a similar problem with the 'suggested imports for this application' functionality (which appears on the front page of the component guide inside an application). Not sure what to do about this - we don't want to make the media card its own component, but image card and youtube card rely on the assets from media card. Some options:
(I think this will be ultimately solved by the work being done where components include their own assets, but that's a little while off yet unfortunately) |
I think of those options, the later option might be the best solution here. The reason I implemented this way was to reduce the amount of logic required by just being to call the specific card that we want to use directly, but this way I could I always put that logic in the helper. Will get to implementing it! |
bb4b1f0
to
3933015
Compare
0079e99
to
b7bb983
Compare
b7bb983
to
4805dae
Compare
10c14d9
to
42d8c86
Compare
42d8c86
to
071b5c5
Compare
app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss
Outdated
Show resolved
Hide resolved
app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss
Outdated
Show resolved
Hide resolved
071b5c5
to
ed6747c
Compare
ed6747c
to
4f1147e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this all looks good now, good job. One conflict to fix and might be worth squashing some of the commits together, but otherwise good 👍
4f1147e
to
e66bdb4
Compare
e66bdb4
to
59856c3
Compare
59856c3
to
d9bef15
Compare
d9bef15
to
6e658b9
Compare
As part of the redesign for the Number 10 organisation page we want to be able to embed Youtube videos in the image card component. This commit adds a youtube_video_id parameter to the ImageCardHelper as well as several functions for generating a youtube link using a thumbnail of the given youtube video. This link will replaced by the embed if the JS is able to run. Now we have added a Youtube embed to the image card, we need to add some tests to the image_card spec. This makes sure that we are adding the data attribute required for the javascript to work and also that the fallback link is correctly generated from the helper. We don't test the embed itself because we are simply running the YoutubeLinkEnhancement module without modifications. This already has tests written for it. In this commit, we have also have added the functionality for turning a link to Youtube into an embed in the image card to image_card.js. This function uses the existing YoutubeLinkEnhancement module from Govspeak. There was only one minor modification needed to be made to YoutubeLinkEnhancement for this to work, which was to allow specifying a class to be appended to the Youtube embed. Have also added the data-attribute required for the ImageCard js module to be initialised in the image card partial if youtube_video_id has been passed to it.
When a user has JS/cookies disabled, the Youtube embed in image card will not be generated. Instead the user will see the link to the Youtube video. This comprises of a thumbnail of the video as well as a text description of the video. To make it more clear that the link is going to Youtube, we have overlaid on top of the thumbnail a Youtube icon. To make it clear that the user has focused the link to the Youtube video, focus style has been added to the text of the link when the link is focused.
6e658b9
to
e577752
Compare
What
New variant of image card that supports embedding a Youtube video.
More Details
ImageCardHelper modified to accept a youtube_video_id and a set of new functions for generating a Youtube embed and a placeholder link using a thumbnail of the Youtube embed.
YoutubeLinkEnhancement can accept an override class if you want an alternative class to be appended to the youtube embed that isn't
gem-c-govspeak__youtube-video
.Why
As part of the new design for No. 10 organisation page we need to be able to show promotional content with embeddable videos. Promotional content currently uses the image card component, so this PR adds support for embedding specifically Youtube videos into the image card component. Youtube embed functionality already exists in govspeak, therefore we are using that to generate the embed as it already has the functionality we need.
Screenshot