-
Notifications
You must be signed in to change notification settings - Fork 231
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
Fix prop type errors #1692
Fix prop type errors #1692
Conversation
Since #1627 we now render I think there are a few solutions to this and wanted to know everyones opinion:
PS: The current caption styling is only correct because we aren’t passing the required |
Following on from the above: Option 1 will work for all use cases but means we have to explicitly pass in a “typography” prop anywhere we render Paragraph. This then means for open source use of this component the application using it needs to pass a callback function to define the typography for the component. This feels like something that is very much a bespoke requirement for our application rather than for the component itself. Option 2 means we are making a bespoke component in Simorgh, (or this could be in Psammead but I don’t think it has much use case to be split out), which means any override going forward means a bespoke component in Simorgh. Option 3 could be a blueprint for creating a component which doesn’t explicitly need styling because it inherits from the parent (EG: , or etc). This could cause bugs if the inheritance is misconfigured. If used right this would mean there is less CSS for the browser to compute but in larger teams bugs are more likely so the risk might outweigh the benefit |
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 that summary, Phil.
I think option 3 would work best, since we have psammead-caption@1.1.3
to include styles relating to the <p>
and <i>
tags nested within the <figcaption>
element.
https://github.com/bbc/psammead/blob/d3f184ee554e32793feed3db65024ddb6db5c875/packages/components/psammead-caption/src/index.jsx#L39-L44
I've therefore suggested the changes to not pass in the script to the Paragraph component, so that the Caption typography styles can be retained.
Thinking this through I think we could have a combination of 1 and 3. Where the component accepts So given the
And in an example where we want to set the typography and not rely on inheritance:
|
@pjlee11 Sounds good. Will you agree that the making of the script field optional can be done separately to this PR? So that we can have the case 1 that you've stated in this PR. The second case shouldn't be needed for the caption - otherwise the typography styles for the caption will be overwritten by those for the paragraph. (Also, there's also a fourth way to address this issue. We could change caption to using a For now, I'm happy to go with the option that you've stated above - a the mix of cases 1 & 3. |
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. No more errors in the console. ✨
The following fixture data asset still have propTypes errors due:
The video propType failures will be fixed within #1636 |
LGTM. Happy for this to be merged. |
Resolves #1688
Resolves #1690
Overall change: Fix all prop types warnings in the console
Code changes:
superscript
as it will not be implemented as a fragment going forward (details)Test instructions
npm run dev
there should be no errors in the console relating to propTypes (There are some errors expected for the manifest because it 500's.)