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

Fix Nav styles to match DS header #10823

Merged
merged 11 commits into from
Aug 23, 2023
Merged

Fix Nav styles to match DS header #10823

merged 11 commits into from
Aug 23, 2023

Conversation

pettinarip
Copy link
Member

@pettinarip pettinarip commented Jul 30, 2023

Description

This PR fixes the styles issues reported in #10807 but also refactor the Nav component to match the DS.

TODO

  • replace & remove deprecated icon variant
  • update docs if necessary
  • @TylerAPfledderer see if we can still use the previous api for the Button theme (using isSecondary) and refactor accordingly

Related Issue

#9546
Fixes #10807

Comment on lines 91 to 92
variant="secondaryGhost"
px={1.5}
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to have your 👀 on this PR @TylerAPfledderer, especially with the following changes:

1st change is in the Button component, where I had to remove the sx inner logic because otherwise, I wasn't able to override the px prop. Not sure exactly why (I think it is because the sx prop has more priority than the style props).

2nd change is a consequence of the 1st one. Since I removed the usage of useStyleConfig and sx from the Button component (and ButtonLink), I started to see the warning about the isSecondary flag. I ended up removing it and creating 2 new variants to cover the secondary cases. Not ideal I think, but it worked and is simple to understand.

Let me know what do you think about these changes or if you have any concerns. Also, feel free to test the rest of the changes as well and leave any comments :)

Copy link
Contributor

Choose a reason for hiding this comment

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

To the first, I can see where the issue would happen, so this is definitely cleaner! 😄

As to the second, it is certainly a matter of preference. I guess here it is readability versus overkill? I'm good with this though! Indeed still easy to roll with.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @TylerAPfledderer

This PR is a draft because I wanted to first check with you about it and see if you had a workaround to keep the same convention you built (with simpler variants + the isSecondary flag). Tbh I don't like having variants called "secondaryOutline" hahaha.

So, let me know if you prefer to hold on a bit here and see if you can add the necessary changes to make this work with the original convention you did.

Copy link
Contributor

Choose a reason for hiding this comment

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

@pettinarip ok! We can hold here while I check it out 😁

Copy link
Member Author

Choose a reason for hiding this comment

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

Awesome thanks!

LMK if you can add commits to this PR (I doubt it) or create a new PR off this branch and we can merge it back.

Copy link
Contributor

Choose a reason for hiding this comment

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

When I try to clone this, it fails to create a branch. Only establishing the upstream (maybe) but stays on the dev branch with all the changes you have made staged

isDarkTheme ? "Switch to Light Theme" : "Switch to Dark Theme"
}
icon={<Icon as={isDarkTheme ? MdWbSunny : MdBrightness2} />}
variant="icon"
Copy link
Member Author

Choose a reason for hiding this comment

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

Trying to remove as much as I can the icon variant to finally delete it from the theme.

mobileNavProps,
} = useNav({ path })
const searchModalDisclosure = useDisclosure()
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved the search modal logic to the parent to avoid using refs which was causing me a headache.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good call here 😅

)
)

const Search = forwardRef<{}, "button">((_, ref) => {
const searchButtonRef = React.useRef<HTMLButtonElement>(null)
const { isOpen, onClose, onOpen } = useDisclosure()
Copy link
Member Author

Choose a reason for hiding this comment

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

Main change here was the removal of this line. It was moved to the parent component (the Nav).

@gatsby-cloud
Copy link

gatsby-cloud bot commented Jul 30, 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.

Only one additional thought I had here. 😄

Comment on lines 85 to 96
<Button
aria-label={
isDarkTheme
? "Switch to Light Theme"
: "Switch to Dark Theme"
}
variant="secondaryGhost"
px={1.5}
onClick={toggleColorMode}
>
<Icon as={isDarkTheme ? MdWbSunny : MdBrightness2} />
</Button>
Copy link
Contributor

Choose a reason for hiding this comment

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

Using IconButton also works here, and still simplified from the original

Suggested change
<Button
aria-label={
isDarkTheme
? "Switch to Light Theme"
: "Switch to Dark Theme"
}
variant="secondaryGhost"
px={1.5}
onClick={toggleColorMode}
>
<Icon as={isDarkTheme ? MdWbSunny : MdBrightness2} />
</Button>
<IconButton
icon={isDarkTheme ? <MdWbSunny /> : <MdBrightness2 />}
aria-label={
isDarkTheme
? "Switch to Light Theme"
: "Switch to Dark Theme"
}
variant="secondaryGhost"
px={1.5}
onClick={toggleColorMode}
/>

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding this point, I wasn't able to do that. I mean, the IconButton implementation was adding a different padding or margin (can't remember) to the inner icon, so that is why I ended up using the normal Button. Not sure if we should add something on the theme config to fix this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why it would be doing that. I'm not seeing that issue when I try to apply it. Maybe something to follow up with later once this PR gets pushed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm probably I was just doing silly things and it works fine xD

Yea...lets leave it for now and we can tackle it later.

@github-actions github-actions bot added the content 🖋️ This involves copy additions or edits label Aug 17, 2023
@pettinarip pettinarip marked this pull request as ready for review August 17, 2023 13:20
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.

Nice!

@corwintines corwintines merged commit 89d9efa into dev Aug 23, 2023
@corwintines corwintines deleted the fix-nav branch August 23, 2023 05:07
This was referenced Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content 🖋️ This involves copy additions or edits
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect font size in color mode and language buttons
3 participants