Skip to content

Commit 0f69c2a

Browse files
committed
chore: upadte docs/best-practices.md
1 parent 3204fc8 commit 0f69c2a

File tree

1 file changed

+7
-60
lines changed

1 file changed

+7
-60
lines changed

docs/best-practices.md

Lines changed: 7 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Markdown will be translated as whole pages of content, so no specific action is
5252

5353
- _tl;dr Each individual JSON entry should be a complete phrase by itself_
5454

55-
- This is done using the `Translation` component. However there is an alternative method for regular JS: using the `t` function from `gatsby-plugin-react-i18next`
55+
- This is done using the `Translation` component. However there is an alternative method for regular JS: using the `t` function from `next-i18next`
5656

5757
- **Method one: `<Translation />` component (preferred if only needed in JSX)**
5858

@@ -66,7 +66,7 @@ Markdown will be translated as whole pages of content, so no specific action is
6666
- **Method two: `t()`**
6767

6868
```tsx
69-
import { useTranslation } from "gatsby-plugin-react-i18next"
69+
import { useTranslation } from "next-i18next"
7070
7171
// Utilize anywhere in JS using
7272
const { t } = useTranslation()
@@ -104,7 +104,7 @@ export default ComponentName
104104

105105
We use [Chakra UI](https://chakra-ui.com/).
106106

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.
107+
`src/@chakra-ui/theme.ts` - Holds all the theme configuration. This is where you can find the colors, fonts, component themes, variants, etc.
108108

109109
- Wrappers or layout divs
110110

@@ -149,7 +149,7 @@ Use [the Chakra default breakpoints](https://chakra-ui.com/docs/styled-system/th
149149
<Text color="primary.base" bg="background.base" />
150150
```
151151

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)
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/@chakra-ui//semanticTokens.ts)
153153

154154
> Note 2: all the previous colors defined in the old theme `src/theme.ts` were
155155
> ported into the new theme for compatibility reasons. Those colors will
@@ -177,63 +177,10 @@ import { BsQuestionSquareFill } from "react-icons/bs"
177177
;<Icon as={BsQuestionSquareFill} />
178178
```
179179

180-
## Image loading and API calls using GraphQL
180+
## Using custom `Image` component
181181

182-
- [Gatsby + GraphQL](https://www.gatsbyjs.com/docs/graphql/) used for loading of images and preferred for API calls (in lieu of REST, if possible/practical). Utilizes static page queries that run at build time, not at run time, optimizing performance.
183-
- Image loading example:
182+
[Next Image](https://nextjs.org/docs/pages/api-reference/components/image) is the component of choice to handle responsive images. However, we use a custom version of this component that is properly optimized with Chakra. This way we can use style props from Chakra but still be able to forward common or Next Image-specific props to the component for correct usage and rendering.
184183

185184
```tsx
186-
import { graphql } from "gatsby"
187-
188-
export const query = graphql`
189-
query {
190-
hero: file(relativePath: { eq: "developers-eth-blocks.png" }) {
191-
childImageSharp {
192-
gatsbyImageData(
193-
width: 800
194-
layout: FIXED
195-
placeholder: BLURRED
196-
quality: 100
197-
)
198-
}
199-
}
200-
}
201-
`
202-
// These query results get passed as an object `props.data` to your component
203-
```
204-
205-
- API call example:
206-
207-
```tsx
208-
import { graphql } from "gatsby"
209-
210-
export const repoInfo = graphql`
211-
fragment repoInfo on GitHub_Repository {
212-
stargazerCount
213-
languages(orderBy: { field: SIZE, direction: DESC }, first: 2) {
214-
nodes {
215-
name
216-
}
217-
}
218-
url
219-
}
220-
`
221-
export const query = graphql`
222-
query {
223-
hardhatGitHub: github {
224-
repository(owner: "nomiclabs", name: "hardhat") {
225-
...repoInfo
226-
}
227-
}
228-
}
229-
`
230-
// These query results get passed as an object `props.data` to your component
231-
```
232-
233-
### Using custom `GatsbyImage`
234-
235-
[GatsbyImage](https://www.gatsbyjs.com/plugins/gatsby-plugin-image/) is the component of choice to handle responsive images processed through graphql. However, we use a custom version of this component that is properly optimized with Chakra. This way we can use style props from Chakra but still be able to forward common or GatsbyImage-specific props to the Gatsby component for correct usage and rendering.
236-
237-
```tsx
238-
import GatsbyImage from "./components/GatsbyImage"
185+
import { Image } from "@/components/Image"
239186
```

0 commit comments

Comments
 (0)