-
Couldn't load subscription status.
- Fork 5.3k
refactor: migrate the merge infographic component from emotion to chakraui #6374 #8246
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
Conversation
✅ ethereum-org-website-dev deploy preview ready
|
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.
Hey @victorpatru ! I got a chance to take a look at your changes and provided some feedback for you 😄
src/components/MergeInfographic.tsx
Outdated
| <VStack | ||
| className={className} | ||
| role="img" | ||
| aria-label={translateMessageId( | ||
| "page-upgrades-merge-infographic-alt-text", | ||
| intl | ||
| )} | ||
| position="relative" | ||
| width="100%" | ||
| sx={{ | ||
| isolation: "isolate", | ||
| aspectRatio: `${25 / 11}`, | ||
| }} | ||
| > |
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.
Because the aspectRatio prop is used, I think it would be better to use the AspectRatio component instead, else Box.
VStack doesn't make sense here because there are no visually stacking elements in the DOM flow (just about everything is absolute-positioned instead), and VStack by default renders a marginTop for each child element. In this case, it's simply rendering unnecessary space. :)
With AspectRatio you can use the ratio prop instead with the needed value.
NOTE: All the child components will need to be wrapped in a div because AspectRatio is looking for a single child. Else it'll break the SSR.
| <VStack | |
| className={className} | |
| role="img" | |
| aria-label={translateMessageId( | |
| "page-upgrades-merge-infographic-alt-text", | |
| intl | |
| )} | |
| position="relative" | |
| width="100%" | |
| sx={{ | |
| isolation: "isolate", | |
| aspectRatio: `${25 / 11}`, | |
| }} | |
| > | |
| <AspectRatio | |
| className={className} | |
| role="img" | |
| aria-label={translateMessageId( | |
| "page-upgrades-merge-infographic-alt-text", | |
| intl | |
| )} | |
| position="relative" | |
| width="100%" | |
| ratio={25 / 11} | |
| sx={{ | |
| isolation: "isolate", | |
| }} | |
| > |
This component will provide more robust positioning and sizing logic. I wonder if @pettinarip agrees on this approach instead of just using Box! 😄
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.
Great suggestion, yes. Lets try to use as much as we can the Chakra components. And good point about the usage of VStack, I think its not necessary here.
src/components/MergeInfographic.tsx
Outdated
| <ExecutionLayer aria-hidden="true"> | ||
| <Box | ||
| position="absolute" | ||
| top="44%" |
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.
top should have the value of 40% 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.
That is weird. You are correct, in the code we have 40% but in prod, inspecting the element using the dev tools, it says 44% 🤷🏼 whatever...both values work fine at the end IMO.
src/components/MergeInfographic.tsx
Outdated
| aria-hidden="true" | ||
| > | ||
| <Text x="2%" y="35%" fontSize={lg}> | ||
| <text x="2%" y="35%" fontSize={lg} textAnchor="start" fill="currentColor"> |
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.
With all of the text elements, you could do the same as the Background svg in using the Chakra factory, so you can keep the code DRY with the textAnchor and fill props.
const Text = chakra("text", {
baseStyle: {
textAnchor: "start",
fill: "currentColor",
},
})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.
Great job @victorpatru! this is looking great.
Lets implement the AspectRatio component in this refactor. With that, I think we can call this done.
src/components/MergeInfographic.tsx
Outdated
| <VStack | ||
| className={className} | ||
| role="img" | ||
| aria-label={translateMessageId( | ||
| "page-upgrades-merge-infographic-alt-text", | ||
| intl | ||
| )} | ||
| position="relative" | ||
| width="100%" | ||
| sx={{ | ||
| isolation: "isolate", | ||
| aspectRatio: `${25 / 11}`, | ||
| }} | ||
| > |
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.
Great suggestion, yes. Lets try to use as much as we can the Chakra components. And good point about the usage of VStack, I think its not necessary here.
src/components/MergeInfographic.tsx
Outdated
| <ExecutionLayer aria-hidden="true"> | ||
| <Box | ||
| position="absolute" | ||
| top="44%" |
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.
That is weird. You are correct, in the code we have 40% but in prod, inspecting the element using the dev tools, it says 44% 🤷🏼 whatever...both values work fine at the end IMO.
|
Committed the changes we've discussed. Thanks @pettinarip @TylerAPfledderer |
src/components/MergeInfographic.tsx
Outdated
| aria-hidden="true" | ||
| > | ||
| <Text x="2%" y="35%" fontSize={lg}> | ||
| <Text x="2%" y="35%" fontSize={lg} textAnchor="start" fill="currentColor"> |
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.
Whoops! Straggler textAnchor and fill after making that new component. 😄
|
The build kept failing because the AspectRatio Chakra element expects a single child element. It should be fixed now 😄 |
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.
LGTM! thanks for the great work you did here @victorpatru 🙏🏼
Be sure to join the discord if you are interested in contributing further to the project or have any questions for the team. And we've just released our 2022 POAPs so remember to claim yours also 🥳!
|
Congrats, your important contribution to this open-source project has earned you a GitPOAP! GitPOAP: 2022 Ethereum.org Contributor: Head to gitpoap.io & connect your GitHub account to mint! Learn more about GitPOAPs here. |
|
@all-contributors please add @victorpatru for code |
|
I've put up a pull request to add @victorpatru! 🎉 |

Hey @pettinarip, I've gone ahead and fixed the bugs that I encountered during the migration of the MergeInfographic component.
I wasn't sure about the best practices to fixing the bugs to a pull request so I closed the previous pull request and created a new one with my final version. (would love some insight on whether this was the right approach).
Related Issue #6374