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

[UI lib] Button, Link & ButtonLink components #7438

Merged
merged 38 commits into from
Sep 1, 2022

Conversation

pettinarip
Copy link
Member

@pettinarip pettinarip commented Aug 15, 2022

Migration of Button, Link & ButtonLink components.

Description

This PR includes the migration of some core components that are a bit related between them. The PR does not only migrate the components to chakra, it also includes refactors on each one of them.

Notes for the reviewer:

  • The main files to review are:
    • in the theme configuration folder (src/@chakra-ui)
    • and the mentioned components on the title
  • The rest are little adjustments to satisfy the newer components.
  • As this PR touches all the pages, lets try to test as many pages as we can.
  • The Button styles are the new styles from the design system.

Things to test or consider:

  • Button & Link styles
    • in light & dark mode
    • states (hover, active, disabled)
  • Link functionality
    • Intl support
    • RTL support
    • External, hashed, static links

Test env: https://ethereumorgwebsitedev01-chakrabuttonlinkcomponent.gtsb.io/

Figma: https://www.figma.com/file/NrNxGjBL0Yl1PrNrOT8G2B/ethereum.org-Design-System

Related Issue

Epic #6374

@github-actions github-actions bot added content 🖋️ This involves copy additions or edits review needed 👀 labels Aug 15, 2022
@gatsby-cloud
Copy link

gatsby-cloud bot commented Aug 15, 2022

Gatsby Cloud Build Report

ethereum-org-website-dev

🎉 Your build was successful! See the Deploy preview here.

Build Details

View the build logs here.

🕐 Build time: 20m

toId?: string
}

const Button: React.FC<IProps> = ({ toId, children, ...props }) => {
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'm calling this component Button bc it is the same Chakra button but with the scrolling feature. This way, you will just use this button component in the codebase.

import Button from 'components/Button'

On the other hand, we could break them out by calling this component ButtonScroll and using it only where we need to use the auto-scrolling.

import ButtonScroll from 'components/ButtonScroll'

// for the rest, we use the native chakra button
import Button from 'chakra/Button'

I just wanted to check if you have a preference.

<Button
variant="outline"
color="primary"
borderColor="primary"
Copy link
Member Author

@pettinarip pettinarip Aug 15, 2022

Choose a reason for hiding this comment

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

  • TODO: create new variant for this case (is defined in the design system)

throw new Error("Either 'to' or 'href' props must be provided")
}
// TODO: in the next PR we are going to deprecate `to` prop and just use `href`
const to = (toProp || href)!
Copy link
Member Author

@pettinarip pettinarip Aug 15, 2022

Choose a reason for hiding this comment

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

In a next PR we are going to just use href for everything. I didn't want to include that change here since it touches a massive amount of files.

Copy link
Member

Choose a reason for hiding this comment

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

SGTM

@@ -194,7 +194,7 @@ const config: GatsbyConfig = {
{
resolve: "@chakra-ui/gatsby-plugin",
options: {
resetCSS: false,
resetCSS: true,
Copy link
Member Author

Choose a reason for hiding this comment

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

We have enabled the reset from Chakra. It does seem to be working fine so far. I haven't seen any conflict yet.

@pettinarip pettinarip self-assigned this Aug 16, 2022
@pettinarip pettinarip marked this pull request as ready for review August 16, 2022 01:41
@nloureiro
Copy link
Contributor

The focus on the links is too strong. We don't have this on production. We probably need to rethink the focus style on the link.

Screen.Recording.2022-08-30.at.09.41.21.mov

I got it; it's the box shadow that has to disappear.

Screen.Recording.2022-08-30.at.09.48.55.mov

@pettinarip
Copy link
Member Author

@nloureiro thanks for the review.

re: focus border, I agree that the border is too thick & doesn't look nice on the links. I don't like too much the idea of hiding it until we rethink it. I'll try to copy the previous version to have at least some focus indicator for a11y purposes.
image
What do you think?


re: the other issues:

  • The initial flashing will be covered in a different PR since it is an already known issue.
  • The other problems where you have a mixed color mode in different sections, thats weird. I think is the same issue @minimalsm is having with the breadcrumbs colors. I couldn't reproduce it in my local or in the test env....I think it is related to some weird state in the localstorage. Would you be able to clear the localstorage and test it again?

@nloureiro
Copy link
Contributor

@nloureiro thanks for the review.

re: focus border, I agree that the border is too thick & doesn't look nice on the links. I don't like too much the idea of hiding it until we rethink it. I'll try to copy the previous version to have at least some focus indicator for a11y purposes. image What do you think?

re: the other issues:

  • The initial flashing will be covered in a different PR since it is an already known issue.
  • The other problems where you have a mixed color mode in different sections, thats weird. I think is the same issue @minimalsm is having with the breadcrumbs colors. I couldn't reproduce it in my local or in the test env....I think it is related to some weird state in the localstorage. Would you be able to clear the localstorage and test it again?

regarding the :focus
I'm not sure of your idea here, but that will affect all the tags, right?
How would it work in the side navigation?

we should have :focus for accessibility affordance, what do you think about this for now? then I will revisit this on the Design system and open a PR to fix accordantly.
@minimalsm and @konopkja : any thoughts here?
Screen Shot 2022-08-30 02 25 19 PM

@minimalsm
Copy link
Contributor

minimalsm commented Aug 30, 2022

@pettinarip yeah, I can't reproduce anymore (even without clearing my local storage). I'm not sure what's going on.

====

Re: focus. I don't think the focus style is too much. The weird part is that it is persisting on page transitions. Can we stop that?

I also (personally) wouldn't have onClick focus as the most common convention seems to be for keyboard usage only (but I could be wrong here)

Edit: This appears to be an issue with Chakra. The problem is resolved in their Storybook.. Bumping Chakra version might solve this? cc: @nloureiro @pettinarip

@pettinarip
Copy link
Member Author

@nloureiro I like that style. I'll implement that for now.

@minimalsm interesting. Yes, I can confirm it is a v2 improvement. But good for us, we have already a PR opened for that #7617 👍🏼

@nloureiro
Copy link
Contributor

@minimalsm : to reproduce the theme bug

  1. follow this link in safari > https://ethereumorgwebsitedev01-chakrabuttonlinkcomponent.gtsb.io/en/
  2. change the theme

@nloureiro nloureiro mentioned this pull request Aug 30, 2022
@corwintines
Copy link
Member

Was doing some testing on my end to see if I could replicate any of the themeing issues, but haven't been able to reproduce them on my side. Tested in Safari, Chrome, Brave, and Firefox.

@pettinarip
Copy link
Member Author

@nloureiro @minimalsm @corwintines

I’ve updated the PR with the new focus style on the Links in order to let you guys see the results.

The problem is the inconsistency with other focus styles we have.

  • We are using links not just for text but sometimes to wrap icons or buttons

image

  • You can see on the nav dropdowns that the focus style is different. This is because those navs are not links, so they are not inheriting the link styles

image

  • Some cards are wrapped with a Link.

image

  • Another example of icons

image


I would propose to keep the previous focus styles (the ones we currently have in prod) for the links. To keep it simple for the scope of this PR & for consistency.

If you agree then I can modify them to be the same as before. Then, once we have a clear style for the focus in links, we can dedicate a new PR just for that.

In summary, my idea is:

  • Button: we apply the new focus styles (the ones that are in the Design System)
  • Link: keep the current styles that are in prod

@nloureiro
Copy link
Contributor

@nloureiro @minimalsm @corwintines

I’ve updated the PR with the new focus style on the Links in order to let you guys see the results.

The problem is the inconsistency with other focus styles we have.

  • We are using links not just for text but sometimes to wrap icons or buttons

image

  • You can see on the nav dropdowns that the focus style is different. This is because those navs are not links, so they are not inheriting the link styles

image

  • Some cards are wrapped with a Link.

image

  • Another example of icons

image

I would propose to keep the previous focus styles (the ones we currently have in prod) for the links. To keep it simple for the scope of this PR & for consistency.

If you agree then I can modify them to be the same as before. Then, once we have a clear style for the focus in links, we can dedicate a new PR just for that.

In summary, my idea is:

  • Button: we apply the new focus styles (the ones that are in the Design System)
  • Link: keep the current styles that are in prod

errr... this is messy.
I've tried some variations and it's not easy to keep a consistent :focus beahiver with the actual code.
Probably we need to work this on a component level.

For these reason I agree on keep the production :focus, that is basically no :focus at all. Then we need to discuss how to precess here.

@@ -755,14 +755,15 @@ const GlobalStyle: React.FC = () => {
/* Anchor tag styles */
/* Selected specifically for mdx rendered side icon link */
.header-anchor {
position: relative;
position: relative !important;
Copy link
Member Author

Choose a reason for hiding this comment

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

Due to some sort of build order, these styles are being overridden by the default styles that come with the plugin https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-remark-autolink-headers/src/gatsby-ssr.js#L15 thats why I had to put those !important.

I'll see if I can revert these changes in the #7564 PR.

@pettinarip
Copy link
Member Author

Cool! I've updated the PR leaving the :focus-visible as outline: auto, to be handled by the browser.

Copy link
Contributor

@minimalsm minimalsm left a comment

Choose a reason for hiding this comment

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

This is what I'm getting now for focus state.

Screenshot 2022-08-31 at 16 58 17

This does not seem like very good for accessibility.

Given that the Chakra update removes the on-click focus and the page transition issue (which I found out is actually strict WCAG, but we don't need to follow IMO), would we be better just keeping the focus styling before the revisions here?

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 job @pettinarip!

@pettinarip pettinarip merged commit 593a84c into dev Sep 1, 2022
@pettinarip pettinarip deleted the chakra-buttonlink-component branch September 1, 2022 15:44
@corwintines corwintines mentioned this pull request Sep 1, 2022
svg {
height: 1.5rem;
&.flip {
transform: scaleY(-1);
Copy link
Member

Choose a reason for hiding this comment

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

@pettinarip pettinarip mentioned this pull request Sep 24, 2022
80 tasks
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.

5 participants