-
Notifications
You must be signed in to change notification settings - Fork 54
Conversation
This PR hasn't fixed - Considered making height & width props optional in UPDATE - Closed #2523 and instead provided a default value for the height and width |
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 was running an out of date version of the branch.
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.
Looks great.
@@ -41,9 +52,15 @@ AmpMediaPlayer.propTypes = { | |||
placeholderSrc: string.isRequired, | |||
placeholderSrcset: string, | |||
title: string.isRequired, | |||
alt: string, |
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 this be a required prop?
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.
Also, the width
and height
are required in the AmpImg
component.
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.
Added the alt, width and height as optional props because the <AmpMediaPlayer />
seems to work without them - as it's getting the height and width from the StyledVideoContainer
and StyledAudioContainer
height: 640, | ||
width: 450, |
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.
Where are we getting this values from?
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.
Provided random default values as I was not sure where to get the specific height and width
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.
Let's have null
as the default values. The same thing we have on psammead-image
component
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.
When height and width are null, the error changes to Warning: Failed prop type: The prop height is marked as required in AmpImg, but its value is null.
. React doesn't allow required props to be null. Found this issue on that - facebook/react#3163
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 think the width and height should be required since they are in the AmpImg
component. Can you double-check this with @RayNjeri, please?
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.
Thanks for catching this. I think height
and width
should be required props here and not given arbitrary default values.
Given the width and height are only used before the AMP runtime fetches the image, can we compute values matching the aspect ratio based on portrait
, see how we do https://github.com/bbc/psammead/blob/7b7d4eb86022e7edbfa37bd1a43c4d1633f6f967/packages/components/psammead-media-player/src/index.jsx#L11 and pass these in?
If it doesn't look straightforward I'm happy if you want to create a separate issue for the articles pod to implement that and we live with the warnings for now.
… into 2497-fix-prop-type-warnings
… into 2497-fix-prop-type-warnings
packages/components/psammead-media-player/src/index.stories.jsx
Outdated
Show resolved
Hide resolved
packages/components/psammead-media-player/src/index.stories.jsx
Outdated
Show resolved
Hide resolved
placeholderSrc, | ||
placeholderSrcset, | ||
title, | ||
alt, |
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 don't think we need a new alt
prop, it can be hardcoded to ""
on L41 for consistency with #2476
height: 640, | ||
width: 450, |
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.
Thanks for catching this. I think height
and width
should be required props here and not given arbitrary default values.
Given the width and height are only used before the AMP runtime fetches the image, can we compute values matching the aspect ratio based on portrait
, see how we do https://github.com/bbc/psammead/blob/7b7d4eb86022e7edbfa37bd1a43c4d1633f6f967/packages/components/psammead-media-player/src/index.jsx#L11 and pass these in?
If it doesn't look straightforward I'm happy if you want to create a separate issue for the articles pod to implement that and we live with the warnings for now.
Added a height and width of 16 or 9 depending on if |
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.
Thanks for the changes.
Resolves #2497
Overall change: Add notes to
psammead-media-player
stories. Fix prop type warnings.Code changes: