Skip to content

Commit 7f37ded

Browse files
authored
Merge pull request #10575 from ethereum/cleanup-ui-migration
Cleanup UI migration
2 parents 8830d2b + 7f73cd7 commit 7f37ded

File tree

14 files changed

+125
-861
lines changed

14 files changed

+125
-861
lines changed

docs/best-practices.md

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -102,45 +102,58 @@ export default ComponentName
102102

103103
## Styling
104104

105-
- `src/theme.ts` - Declares site color themes, breakpoints and other constants (try to utilize these colors first)
106-
- We use [emotion](https://emotion.sh/)
105+
We use [Chakra UI](https://chakra-ui.com/).
107106

108-
- Tagged template literals are used to style custom components
107+
`src/@chakra-ui/gatsby-plugin/theme.ts` - Holds all the theme configuration. This is where you can find the colors, fonts, component themes, variants, etc.
109108

110-
```tsx
111-
// Example of styling syntax using emotion
112-
113-
import styled from "@emotion/styled"
114-
115-
const GenericButton = styled.div`
116-
width: 200px;
117-
height: 50px;
118-
`
119-
const PrimaryButton = styled(GenericButton)`
120-
background: blue;
121-
`
122-
const SecondaryButton = styled(GenericButton)`
123-
background: red;
124-
`
125-
126-
// These are each components, capitalized by convention, and can be used within JSX code
127-
// ie: <PrimaryButton>Text</PrimaryButton>
128-
```
109+
- Wrappers or layout divs
129110

130-
- Values from `src/theme.ts` are automatically passed as a prop object to styled components
111+
Use the [native layouts components](https://chakra-ui.com/docs/components/box)
131112

132-
```tsx
133-
// Example of theme.ts usage
113+
```tsx
114+
<Stack direction='row'>
115+
```
134116

135-
import styled from "@emotion/styled"
117+
Center things using the `<Center />` component
136118

137-
const Container = styled.div`
138-
background: ${(props) => props.theme.colors.background};
139-
@media (max-width: ${(props) => props.theme.breakpoints.s}) {
140-
font-size: #{(props) => props.theme.fontSized.s};
141-
}
142-
`
143-
```
119+
```tsx
120+
<Center h="100px">
121+
```
122+
123+
- Group buttons using `<ButtonGroup />` or `<Wrap />`
124+
125+
```tsx
126+
<ButtonGroup variant='outline' spacing={2}>
127+
<Button>Button 1</Button>
128+
<Button>Button 2</Button>
129+
</ButtonGroup>
130+
131+
// or
132+
<Wrap spacing={2}>
133+
<WrapItem><Button variant="outline">Button 1</Button></WrapItem>
134+
<WrapItem><Button variant="outline">Button 2</Button></WrapItem>
135+
</Wrap>
136+
```
137+
138+
- Breakpoints
139+
140+
Use [the Chakra default breakpoints](https://chakra-ui.com/docs/styled-system/theme#breakpoints).
141+
142+
```tsx
143+
<Container display={{ base: "block", sm: "flex" }} />
144+
```
145+
146+
- Theme colors
147+
148+
```tsx
149+
<Text color="primary.base" bg="background.base" />
150+
```
151+
152+
> Note the dotted notation. In Chakra, the values are referred to as "semantic tokens" and the new theme applies a nested structure of like tokens for better organization. See [semanticTokens.ts](../src/%40chakra-ui/gatsby-plugin/semanticTokens.ts)
153+
154+
> Note 2: all the previous colors defined in the old theme `src/theme.ts` were
155+
> ported into the new theme for compatibility reasons. Those colors will
156+
> transition out of the codebase as we adopt the DS colors.
144157

145158
- [Framer Motion](https://www.framer.com/motion/) - An open source and production-ready motion library for React on the web, used for our animated designs
146159
- **Emojis**: We use [Twemoji](https://twemoji.twitter.com/), an open-source emoji set created by Twitter. These are hosted by us, and used to provide a consistent experience across operating systems.
@@ -154,29 +167,14 @@ import Emoji from "./Emoji"
154167
```
155168

156169
- **Icons**: We use [React Icons](https://react-icons.github.io/react-icons/)
157-
- `src/components/Icon.ts` is the component used to import icons to be used
158-
- If an icon you want to use is not listed you will need to add it to this file
159-
160-
`src/components/Icon.ts`:
161-
162-
```tsx
163-
// Example of how to add new icon not listed
164-
import { ZzIconName } from "react-icons/zz"
165-
166-
// Then add to IconContext.Provider children:
167-
{
168-
name === "alias" && <ZzIconName />
169-
}
170-
```
171-
172-
From React component:
170+
with [Chakra UI Icon component](https://chakra-ui.com/docs/components/icon/usage)
173171

174172
```tsx
175-
// Example of icon use
176-
import Icon from "./Icon"
173+
import { Icon } from "@chakra-ui/react"
174+
import { BsQuestionSquareFill } from "react-icons/bs"
177175
178-
// Within JSX:
179-
;<Icon name="alias" />
176+
// wrap your imported icon with the `Icon` component from Chakra UI
177+
;<Icon as={BsQuestionSquareFill} />
180178
```
181179

182180
## Image loading and API calls using GraphQL

docs/chakra-migration-guide.md

Lines changed: 0 additions & 169 deletions
This file was deleted.

0 commit comments

Comments
 (0)