Skip to content

Conversation

@victorpatru
Copy link
Contributor

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

@gatsby-cloud
Copy link

gatsby-cloud bot commented Oct 13, 2022

✅ ethereum-org-website-dev deploy preview ready

@victorpatru victorpatru changed the title refactor: migrate the merge infographic component from emotion to chakraui refactor: migrate the merge infographic component from emotion to chakraui #6374 Oct 16, 2022
Copy link
Contributor

@TylerAPfledderer TylerAPfledderer left a 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 😄

Comment on lines 87 to 100
<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}`,
}}
>
Copy link
Contributor

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.

Suggested change
<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! 😄

Copy link
Member

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.

<ExecutionLayer aria-hidden="true">
<Box
position="absolute"
top="44%"
Copy link
Contributor

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.

Copy link
Member

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.

aria-hidden="true"
>
<Text x="2%" y="35%" fontSize={lg}>
<text x="2%" y="35%" fontSize={lg} textAnchor="start" fill="currentColor">
Copy link
Contributor

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",
  },
})

Copy link
Member

@pettinarip pettinarip left a 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.

Comment on lines 87 to 100
<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}`,
}}
>
Copy link
Member

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.

<ExecutionLayer aria-hidden="true">
<Box
position="absolute"
top="44%"
Copy link
Member

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.

@victorpatru
Copy link
Contributor Author

Committed the changes we've discussed. Thanks @pettinarip @TylerAPfledderer

aria-hidden="true"
>
<Text x="2%" y="35%" fontSize={lg}>
<Text x="2%" y="35%" fontSize={lg} textAnchor="start" fill="currentColor">
Copy link
Contributor

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. 😄

@victorpatru
Copy link
Contributor Author

The build kept failing because the AspectRatio Chakra element expects a single child element. It should be fixed now 😄

Copy link
Member

@pettinarip pettinarip left a 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 🥳!

@pettinarip pettinarip merged commit d7b54e8 into ethereum:dev Oct 29, 2022
@gitpoap-bot
Copy link

gitpoap-bot bot commented Oct 29, 2022

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

GitPOAP: 2022 Ethereum.org Contributor:

GitPOAP: 2022 Ethereum.org Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.

@pettinarip
Copy link
Member

@all-contributors please add @victorpatru for code

@allcontributors
Copy link
Contributor

@pettinarip

I've put up a pull request to add @victorpatru! 🎉

@pettinarip pettinarip mentioned this pull request Oct 29, 2022
80 tasks
@corwintines corwintines mentioned this pull request Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants