Skip to content

Conversation

@minimalsm
Copy link
Contributor

Description

Migrate UpgradeTableOfContents from styled component to ChakraUI

Related Issue

#6374

@vercel
Copy link

vercel bot commented Sep 6, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
ethereum-org-website ❌ Failed (Inspect) Sep 6, 2022 at 6:23PM (UTC)

overflow-y: auto;
`

const OuterList = styled(motion.ul)`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Motion ul wasn't doing anything? I've removed it.

Copy link
Member

Choose a reason for hiding this comment

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

🤔 yeah, I don't see that we are doing any animation with it. Fine with removing it.


const OuterList = styled(motion.ul)`
list-style-type: none;
list-style-image: none;
Copy link
Contributor Author

@minimalsm minimalsm Sep 6, 2022

Choose a reason for hiding this comment

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

I have no idea what list-style-image was supposed to do, but it also appeared to be doing nothing when I tested removing it—so I just left it out as I wasn't sure the best way to approach this in Chakra.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, its fine to remove it since those styles are going to be covered by the Chakra component now.

I guess we had it here to do some kind of reset and make sure this doesn't do anything unexpected.

Comment on lines +128 to +131
m={0}
py={0}
ps={4}
pe={1}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is always using the shorthand our preference?

Copy link
Member

Choose a reason for hiding this comment

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

I would say so but I don't have a strong preference.

As a side note, in this particular case, we are going to style the native Chakra component (on the theme definition), as we did with the Button and the Link.

py={0}
ps={4}
pe={1}
fontSize="1.25rem"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pettinarip I couldn't find anything in the design system for 20px fonts.

Copy link
Member

Choose a reason for hiding this comment

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

In this case, we should use xl.

xl === 1.25rem Here you can see the different values for fontSize https://chakra-ui.com/docs/styled-system/theme#typography

pe={1}
fontSize="1.25rem"
fontWeight="normal"
lineHeight="1.6"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No variables for this, Chakra defaults don't cover 1.6.

Copy link
Member

Choose a reason for hiding this comment

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

In this case, we should just use the raw value: 1.6rem.

Copy link
Member

@pettinarip pettinarip Sep 7, 2022

Choose a reason for hiding this comment

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

Another thought I had, could you try to remove it and test if it works? because we are defining in the global styles 1.6rem as the default.

import { motion } from "framer-motion"
import { Link } from "gatsby"
import styled from "@emotion/styled"
import { Box, Link, ListItem, UnorderedList } from "@chakra-ui/react"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Am I correct in thinking that we import Link directly from Chakra as our Link component is already extending it?

Copy link
Member

Choose a reason for hiding this comment

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

No, we should use our custom src/components/Link component since it uses Gatsby Link under the hood.

The Chakra Link will only have the same styles but not our custom logic.

position: relative;
display: inline-block;
color: ${(props) => props.theme.colors.text300};
margin-bottom: 0.5rem !important;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

!important wasn't needed here, but I'm not clear how we'd implement it if it was.

Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't need to use !important with Chakra anymore since now, all the styles are props, and the way you override styles is by overriding those props.

Example:

// our custom Link component
function Link(props) {
  return <ChakraLink p={4} {...props} />
}

// overriding styles
<Link p={0} />

@gatsby-cloud
Copy link

gatsby-cloud bot commented Sep 6, 2022

✅ ethereum-org-website-dev deploy preview ready

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.

Good job! I've replied to your comments with some recommendations. LMK what do you think 👍🏼

import { motion } from "framer-motion"
import { Link } from "gatsby"
import styled from "@emotion/styled"
import { Box, Link, ListItem, UnorderedList } from "@chakra-ui/react"
Copy link
Member

Choose a reason for hiding this comment

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

No, we should use our custom src/components/Link component since it uses Gatsby Link under the hood.

The Chakra Link will only have the same styles but not our custom logic.


const OuterList = styled(motion.ul)`
list-style-type: none;
list-style-image: none;
Copy link
Member

Choose a reason for hiding this comment

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

Yes, its fine to remove it since those styles are going to be covered by the Chakra component now.

I guess we had it here to do some kind of reset and make sure this doesn't do anything unexpected.

overflow-y: auto;
`

const OuterList = styled(motion.ul)`
Copy link
Member

Choose a reason for hiding this comment

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

🤔 yeah, I don't see that we are doing any animation with it. Fine with removing it.

Comment on lines +128 to +131
m={0}
py={0}
ps={4}
pe={1}
Copy link
Member

Choose a reason for hiding this comment

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

I would say so but I don't have a strong preference.

As a side note, in this particular case, we are going to style the native Chakra component (on the theme definition), as we did with the Button and the Link.

py={0}
ps={4}
pe={1}
fontSize="1.25rem"
Copy link
Member

Choose a reason for hiding this comment

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

In this case, we should use xl.

xl === 1.25rem Here you can see the different values for fontSize https://chakra-ui.com/docs/styled-system/theme#typography

pe={1}
fontSize="1.25rem"
fontWeight="normal"
lineHeight="1.6"
Copy link
Member

Choose a reason for hiding this comment

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

In this case, we should just use the raw value: 1.6rem.

<OuterList>
<Box
as="aside"
className={className}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we are passing any className to this component in any of the uses. I would recommend removing it since we should handle all the styles using props.

{items.map((item, index) => (
<ListItem key={index}>
<ListItem margin={0} key={index}>
<div>
Copy link
Member

Choose a reason for hiding this comment

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

Could we remove those divs?

@corwintines corwintines merged commit d852268 into dev Oct 24, 2022
@corwintines corwintines deleted the migrateUpgradeTOCToChakra branch October 24, 2022 21:08
@corwintines corwintines mentioned this pull request Oct 25, 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.

4 participants