-
Notifications
You must be signed in to change notification settings - Fork 17
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
Display image credit for lead images #1190
Conversation
@@ -9,4 +10,10 @@ | |||
<%= caption %> | |||
</figcaption> | |||
<% end %> | |||
|
|||
<% if credit.present? %> | |||
<figcredit class="app-c-figure__figcredit"> |
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.
I assume this wasn't meant to be custom element but rather part of the <figcaption>
or a separate <span>
?
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.
What is figcaption
? We were trying to follow the pattern defined by captions, but weren't sure where this element is defined.
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.
Should we just make it a span
?
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.
<figcaption>
is a defined element representing a caption or a legend associated with an image/figure. They must be placed inside a <figure>
element to be semantically correct. There is no html element for credits though, so we can use a generic tag (i.e. <span>
or we can include the credits inside the <figcaption>
element.
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.
TIL! I thought figcaption was something we'd made up!
I'll use figcaption
for consistency.
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.
As @vanitabarrett mentioned, <figure>
should only have one <figcaption>
so it probably makes more sense to be included in the existing tag.
97ab837
to
d9e8ed1
Compare
d9e8ed1
to
3d17a39
Compare
@leenagupte Would it make more sense to just include the credit as part of the original image figcaption element? E.g:
|
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.
I'm not sure about having 2 figcaption elements when there is both a caption and a credit. I think it would make more sense to include the credit text inside the figcaption?
3d17a39
to
82b95cf
Compare
@vanitabarrett @alex-ju I've made the changes you recommended and fixed-up. |
82b95cf
to
778ec0f
Compare
.app-c-figure__figcaption-text { | ||
margin-bottom: $gutter-one-third; | ||
|
||
@include media(mobile) { |
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.
We normally try and do mobile-first development, which means our CSS should be based on mobile devices and we should add any other styling for larger screen sizes in media queries. So in this case, it would mean swapping round the CSS you've added here.
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.
@vanitabarrett Updated and fixed up.
<figcaption class="app-c-figure__figcaption"> | ||
<%= caption %> | ||
<% unless caption.blank? %> | ||
<div class="app-c-figure__figcaption-text"> |
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.
Could we use paragraph tags here instead of divs? For both app-c-figure__figcaption-text
and app-c-figure__figcaption-credit
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.
Sure! Not sure what the difference re: <p>
and <div>
is to be honest.
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.
Visually, they probably look the same unless you add your own styling. It's more about the semantics - a <p>
(paragraph tag) is designed to wrap text, whereas a <div>
is just a general containing element (which we tend to use for grouping or layout). Using semantic HTML means we are properly describing what the document/page is made up of: a load of div
elements won't tell you a lot, but things like p
, image
, a
etc give you more information.
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.
I hope that makes sense! 🙂
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.
@vanitabarrett updated and fixed up.
|
||
<% if credit.present? %> | ||
<div class="app-c-figure__figcaption-credit"> | ||
Image credit: <%= credit %> |
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.
Should "Image credit" come from a translation file?
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.
Do you know what happens if there isn't a translation available for the other languages?
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.
I thought it fell back to the english one... but you can provide a default too?
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.
You're right.
The I18n library will use English as a default locale, i.e. if a different locale is not set, :en will be used for looking up translations.
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.
@vanitabarrett I've added a translation.
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.
@vanitabarrett Updated and fixed up.
Adds a margin to the bottom of the caption in desktop view. This works as a line-break between the caption and in the image credit. The extra line isn't displayed on mobiles as this follows the pattern being developed for displaying image credits on inline images
778ec0f
to
54ab422
Compare
54ab422
to
e995617
Compare
@@ -14,7 +14,7 @@ | |||
|
|||
<% if credit.present? %> | |||
<p class="app-c-figure__figcaption-credit"> | |||
Image credit: <%= credit %> | |||
<%= I18n.t("components.figure.image_credit") %>: <%= credit %> |
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.
You could make the credit part of the translation string. E.g: I18n.t("component.figure.image_credit, credit: credit)
and then in the translation file something like image_credit: "Image credit: %{credit}"
But that's not necessary, this is fine too 👍
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.
I like that better!
The translations default to English if there isn't an entry for a locale.
Content Items affected: * Case Study * Fatality Notice * News Articles * Speech * Take Part * World Location News Article At the moment only the Content Publisher app supports image credits, so they will only be displayed on news articles for the time being.
e995617
to
9cfd024
Compare
Looks great! 💯 |
Trello: https://trello.com/c/hGmJ5BfV
Related to:
Motivation
Content Publisher allows publishers to add an image credit, but we are not displaying this data on the frontend
Expected changes
Desktop
Mobile
Paired with @DilwoarH