Skip to content
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

Added hover animations for nav icons #11075

Merged
merged 22 commits into from
Oct 3, 2023
Merged

Added hover animations for nav icons #11075

merged 22 commits into from
Oct 3, 2023

Conversation

rohan9024
Copy link
Contributor

@rohan9024 rohan9024 commented Sep 5, 2023

For context, refer this PR--> #10811

These were the changes requested-

  1. Icon sizes should go back to original
  2. The gap between icons increased, this should be the same as before
  3. Add the .env.example file back
  4. The highlight of the language icon and text should be in sync

Changes done by me-

  1. Icon sizes changed to original
  2. Fixed gap between icons
  3. Added back the .env.example
  4. When hovered over text the language icon, transition applies on icon.

Here is the working,

Home._.ethereum.org.-.Brave.2023-09-05.22-07-35.mp4

@gatsby-cloud
Copy link

gatsby-cloud bot commented Sep 5, 2023

✅ ethereum-org-website-dev deploy preview ready

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 @rohan9024! I have some suggestions below for now.

src/components/Nav/index.tsx Outdated Show resolved Hide resolved
src/components/Nav/index.tsx Outdated Show resolved Hide resolved
src/components/Nav/index.tsx Outdated Show resolved Hide resolved
Comment on lines 130 to 144
<Box mr={2} mt={2}>
{" "}
{/* Add spacing between the text and the icon */}
<Icon
as={MdLanguage}
style={{
transition: "transform 0.3s ease-in-out, color 0.2s", // Apply the transition to the icon
transform: languagesHover
? "rotate(30deg)"
: "rotate(0deg)", // Rotate the icon to 30 degrees on hover
color: languagesHover ? "blue" : "inherit", // Change color to blue on hover
}}
/>
</Box>
<span>Languages {i18n.language.toUpperCase()}</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is excessive. The Chakra Button which ButtonLink uses has the props leftIcon and rightIcon which handle alignment of an icon against text. The spacing of token 2 is already the default.

<ButtonLink
  // -- Other props -- //
  leftIcon={
    <Icon {...iconProps} />
  }
>
  Languages {i18n.language.toUpperCase()}
</ButtonLink>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohan9024 this suggested change is still outstanding :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rohan9024 I don't see that this was implemented. I think this change is important to simplify the overall code and to use the already provided Chakra api.

Marking it as unresolved for now.

src/components/Nav/index.tsx Outdated Show resolved Hide resolved
src/components/Nav/index.tsx Outdated Show resolved Hide resolved
Comment on lines 135 to 139
style={{
transition: "transform 0.3s ease-in-out, color 0.2s", // Apply the transition to the icon
transform: languagesHover
? "rotate(30deg)"
: "rotate(0deg)", // Rotate the icon to 30 degrees on hover
Copy link
Contributor

@TylerAPfledderer TylerAPfledderer Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of pretty cool things to do here. Both transition and transform are style props, so they should not be under the style prop.

Secondly, we can put transform under the hover pseudo and not waste energy on useState. This is a two step process.

  1. Add data-group to ButtonLink
  2. In the Icon use the _groupHover prop which will target data-group with a descendant selector. so when hovering ButtonLink the styles under this prop will trigger. Then no need for this ternary!

So in short...

<ButtonLink
  // -- Other props -- //
  data-group
  leftIcon={
    <Icon
      as={MdLanguage}
      transition="transform 0.3s ease-in-out, color 0.2s"
      // _groupHover renders "[data-group]:hover &"
      _groupHover={{
        transform: "rotate(30deg)"
      }}
    />
  }
/>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohan9024 marking this as unresolved.

Currently we have the _groupHover but not the data-group set in the parent ButtonLink.

src/components/Nav/index.tsx Outdated Show resolved Hide resolved
rohan9024 and others added 6 commits September 19, 2023 19:57
Co-authored-by: Tyler Pfledderer <tyler.pfledderer@gmail.com>
Co-authored-by: Tyler Pfledderer <tyler.pfledderer@gmail.com>
Co-authored-by: Tyler Pfledderer <tyler.pfledderer@gmail.com>
Co-authored-by: Tyler Pfledderer <tyler.pfledderer@gmail.com>
Co-authored-by: Tyler Pfledderer <tyler.pfledderer@gmail.com>
Co-authored-by: Tyler Pfledderer <tyler.pfledderer@gmail.com>
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.

I missed one! :D

src/components/Nav/index.tsx Outdated Show resolved Hide resolved
@rohan9024
Copy link
Contributor Author

rohan9024 commented Sep 19, 2023

@TylerAPfledderer Thanks for providing your valuable suggestions😊. I have made the changes you've requested. Incase if I have missed out on something please guide me✌

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.

Hey @rohan9024 I've noticed that the PR is failing to build.

The error is that the ButtonLink doesn't have an href prop which is a required prop.

So, I ran this PR locally and fixed that to see the result and this is how I see the button now:
image

You can see that the icon is displayed as a button and that is a bit vertically misaligned.

As I said in the comment below, I think that by removing the nested ButtonLink, that should fix these visual issues.

Comment on lines 118 to 120
<ButtonLink
data-group
leftIcon={
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I follow what we are trying to do here but currently, you have a nested ButtonLink inside another ButtonLink, resulting in a nested a tag.

I guess that what we would like to do here is to render just the icon, right? and add the data-group tag on the parent ButtonLink.

====
Note aside, the build is failing because this ButtonLink is missing the href prop.

Copy link
Contributor

@TylerAPfledderer TylerAPfledderer Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, the example I gave was not suggesting nested, but a simplified version of what the component should look like with that data-* prop and the leftIcon prop.

It was only meant as a simplified example; not to actually simplify it that much! 😅

@rohan9024
Copy link
Contributor Author

Hey @rohan9024 I've noticed that the PR is failing to build.

The error is that the ButtonLink doesn't have an href prop which is a required prop.

So, I ran this PR locally and fixed that to see the result and this is how I see the button now: image

You can see that the icon is displayed as a button and that is a bit vertically misaligned.

As I said in the comment below, I think that by removing the nested ButtonLink, that should fix these visual issues.

@pettinarip Alright got it! Updating the code.....

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.

@rohan9024 I've added a few comments to make this cleaner. There are also 2 change requests added by Tyler that should be tackled as well.

Thanks for the time you have put in this. Let me know if you need help doing any of these changes or if I wasn't clear enough.

src/components/Nav/index.tsx Outdated Show resolved Hide resolved
src/components/Nav/index.tsx Outdated Show resolved Hide resolved
src/components/Nav/index.tsx Outdated Show resolved Hide resolved
src/components/Nav/index.tsx Outdated Show resolved Hide resolved
src/components/Nav/index.tsx Outdated Show resolved Hide resolved
src/components/Nav/index.tsx Outdated Show resolved Hide resolved
src/components/Nav/index.tsx Outdated Show resolved Hide resolved
yarn.lock Outdated Show resolved Hide resolved
Copy link
Member

@corwintines corwintines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rohan9024

I committed a few changes to get this over the finish line:

  • Took text out of a span, and added the translated template string back here (just reverted your change really around this)
  • Added the leftIcon back in for the ButtonLink and removed the Icon you had added (reverted to how to use the ButtonLink component)
  • Added animation to the icon for languages, which you can check out in the hover styles if interested.
  • Removed unused useState code

@corwintines corwintines merged commit 18b51b5 into ethereum:dev Oct 3, 2023
3 of 4 checks passed
@gitpoap-bot
Copy link

gitpoap-bot bot commented Oct 3, 2023

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

Be sure to join the Ethereum.org discord if you are interested in contributing further to the project or have any questions for the team.

GitPOAP: 2023 Ethereum.org Contributor:

GitPOAP: 2023 Ethereum.org Contributor GitPOAP Badge

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

Learn more about GitPOAPs here.

This was referenced Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies 📦 Changes related to project dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants