Skip to content

Commit 62f7ed2

Browse files
committed
Merge branch 'dev' into refactor/combine-button-directory
2 parents 4b0a061 + 6462398 commit 62f7ed2

File tree

237 files changed

+12253
-3148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+12253
-3148
lines changed

docs/best-practices.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,11 @@ export const query = graphql`
229229
`
230230
// These query results get passed as an object `props.data` to your component
231231
```
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"
239+
```

src/components/ActionCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import {
1010
useColorModeValue,
1111
LinkBoxProps,
1212
} from "@chakra-ui/react"
13-
import { GatsbyImage, IGatsbyImageData } from "gatsby-plugin-image"
13+
import { IGatsbyImageData } from "gatsby-plugin-image"
1414

1515
import Text from "./OldText"
1616
import { BaseLink } from "./Link"
17+
import GatsbyImage from "./GatsbyImage"
1718

1819
const linkBoxFocusStyles: BoxProps = {
1920
borderRadius: "base",
@@ -77,9 +78,8 @@ const ActionCard: React.FC<IProps> = ({
7778
boxShadow="inset 0px -1px 0px rgba(0, 0, 0, 0.1)"
7879
>
7980
{!isImageURL && (
80-
<Image
81+
<GatsbyImage
8182
alt={alt || ""}
82-
as={GatsbyImage}
8383
maxH="257px"
8484
maxW={{ base: "311px", sm: "372px" }}
8585
minW="100px"

src/components/AssetDownload/AssetDownloadImage.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react"
2-
import { Center, Img } from "@chakra-ui/react"
3-
import { GatsbyImage } from "gatsby-plugin-image"
2+
import { Center } from "@chakra-ui/react"
3+
import GatsbyImage from "../GatsbyImage"
44

55
import { getImage, ImageDataLike } from "../../utils/image"
66

@@ -13,8 +13,7 @@ const AssetDownloadImage = ({ image, alt }: Props) => {
1313
return (
1414
<Center border="1px" borderColor="white700" p={8} w="100%">
1515
{image && (
16-
<Img
17-
as={GatsbyImage}
16+
<GatsbyImage
1817
image={getImage(image)!}
1918
alt={alt}
2019
w="100%"

src/components/BugBountyPoints.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useState, useEffect } from "react"
22
import { useTheme } from "@emotion/react"
33
import { useStaticQuery, graphql } from "gatsby"
4-
import { GatsbyImage } from "gatsby-plugin-image"
54
import { Box, Flex, Icon } from "@chakra-ui/react"
65
import axios from "axios"
76

@@ -11,6 +10,7 @@ import InlineLink from "./Link"
1110
import Tooltip from "./Tooltip"
1211
import Text from "./OldText"
1312
import OldHeading from "./OldHeading"
13+
import GatsbyImage from "./GatsbyImage"
1414

1515
import { getImage } from "../utils/image"
1616
import { MdInfoOutline } from "react-icons/md"
@@ -175,21 +175,13 @@ const BugBountyPoints: React.FC<IProps> = () => {
175175
</Text>
176176
</Flex>
177177
<Flex align="center" wrap="wrap">
178-
<GatsbyImage
179-
image={getImage(data.dai)!}
180-
style={{ marginRight: "0.5rem" }}
181-
alt=""
182-
/>
178+
<GatsbyImage image={getImage(data.dai)!} alt="" me="2" />
183179
<Text fontSize="xl" m={0} mr={4}>
184180
{pointsInDAI} DAI
185181
</Text>
186182
</Flex>
187183
<Flex align="center" wrap="wrap">
188-
<GatsbyImage
189-
image={getImage(ethImage)!}
190-
style={{ marginRight: "0.5rem" }}
191-
alt=""
192-
/>
184+
<GatsbyImage image={getImage(ethImage)!} alt="" me="2" />
193185
<Text fontSize="xl" m={0} mr={4}>
194186
{pointsInETH} ETH
195187
</Text>

src/components/Callout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// Libraries
22
import React from "react"
3-
import { GatsbyImage, IGatsbyImageData } from "gatsby-plugin-image"
4-
import { Flex, FlexProps, Image } from "@chakra-ui/react"
3+
import { IGatsbyImageData } from "gatsby-plugin-image"
4+
import { Flex, FlexProps } from "@chakra-ui/react"
55

66
// Components
77
import Translation from "./Translation"
88
import Emoji from "./Emoji"
99
import Text from "./OldText"
10+
import GatsbyImage from "./GatsbyImage"
1011
import OldHeading from "./OldHeading"
1112

1213
import type { TranslationKey } from "../utils/translations"
@@ -49,8 +50,7 @@ const Callout: React.FC<IProps> = ({
4950
{...rest}
5051
>
5152
{image && (
52-
<Image
53-
as={GatsbyImage}
53+
<GatsbyImage
5454
image={image}
5555
alt={alt || ""}
5656
mt={-40}

src/components/CalloutBanner.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React from "react"
2-
import { GatsbyImage, IGatsbyImageData } from "gatsby-plugin-image"
2+
import { IGatsbyImageData } from "gatsby-plugin-image"
33
import { Flex, FlexProps, Image } from "@chakra-ui/react"
44

55
import Translation from "./Translation"
66
import Text from "./OldText"
77
import OldHeading from "./OldHeading"
8+
import GatsbyImage from "./GatsbyImage"
89
import { TranslationKey } from "../utils/translations"
910

1011
export interface IProps extends FlexProps {
@@ -33,8 +34,7 @@ const CalloutBanner: React.FC<IProps> = ({
3334
borderRadius="base"
3435
{...restProps}
3536
>
36-
<Image
37-
as={GatsbyImage}
37+
<GatsbyImage
3838
image={image}
3939
alt={alt}
4040
objectFit="contain"

src/components/CardList.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { ReactNode } from "react"
2-
import { GatsbyImage, IGatsbyImageData } from "gatsby-plugin-image"
2+
import { IGatsbyImageData } from "gatsby-plugin-image"
33
import {
44
Box,
55
BoxProps,
@@ -11,8 +11,9 @@ import {
1111
useColorModeValue,
1212
} from "@chakra-ui/react"
1313

14-
import * as url from "../utils/url"
1514
import { BaseLink } from "./Link"
15+
import GatsbyImage from "./GatsbyImage"
16+
import * as url from "../utils/url"
1617

1718
export type CardListItem = {
1819
title?: ReactNode
@@ -57,9 +58,7 @@ const Card = (props: CardListItem & Omit<StackProps, "title" | "id">) => {
5758

5859
return (
5960
<CardContainer {...rest}>
60-
{image && (
61-
<Box as={GatsbyImage} image={image} alt={alt || ""} minW="20px" />
62-
)}
61+
{image && <GatsbyImage image={image} alt={alt || ""} minW="20px" />}
6362
<Flex flex="1 1 75%" direction="column">
6463
{isLink ? (
6564
<LinkOverlay

src/components/DataProductCard.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react"
22

3-
import { GatsbyImage, IGatsbyImageData } from "gatsby-plugin-image"
3+
import { IGatsbyImageData } from "gatsby-plugin-image"
44
import {
55
Box,
66
Flex,
@@ -12,6 +12,7 @@ import {
1212
} from "@chakra-ui/react"
1313

1414
import Text from "./OldText"
15+
import GatsbyImage from "./GatsbyImage"
1516

1617
export interface DataRow {
1718
logo: IGatsbyImageData
@@ -65,8 +66,7 @@ const DataProductCard: React.FC<IProps> = ({
6566
minH="200px"
6667
bg={background}
6768
>
68-
<Image
69-
as={GatsbyImage}
69+
<GatsbyImage
7070
image={image}
7171
objectFit="cover"
7272
alt={alt ? alt : `${name} logo`}
@@ -123,8 +123,7 @@ const DataProductCard: React.FC<IProps> = ({
123123
>
124124
<Flex alignItems="center">
125125
{logo && (
126-
<Image
127-
as={GatsbyImage}
126+
<GatsbyImage
128127
image={logo}
129128
objectFit="cover"
130129
alt=""

src/components/ExpandableInfo.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { ReactNode } from "react"
2-
import { GatsbyImage, IGatsbyImageData } from "gatsby-plugin-image"
2+
import { IGatsbyImageData } from "gatsby-plugin-image"
33
import {
44
BackgroundProps,
55
Box,
@@ -17,6 +17,7 @@ import { motion } from "framer-motion"
1717
import { MdExpandMore } from "react-icons/md"
1818

1919
import Text from "./OldText"
20+
import GatsbyImage from "./GatsbyImage"
2021

2122
export interface IProps extends ChakraProps {
2223
children?: React.ReactNode

src/components/FindWallet/WalletTable/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Libraries
22
import React, { ReactNode } from "react"
3-
import { GatsbyImage } from "gatsby-plugin-image"
43
import { useTranslation } from "gatsby-plugin-react-i18next"
54
import Select from "react-select"
65
import { MdExpandLess, MdExpandMore } from "react-icons/md"
@@ -26,6 +25,7 @@ import {
2625
// Components
2726
import InlineLink, { IProps as LinkProps } from "../../Link"
2827
import { WalletMoreInfo } from "./WalletMoreInfo"
28+
import GatsbyImage from "../../GatsbyImage"
2929
import Text from "../../OldText"
3030

3131
// Icons
@@ -432,8 +432,7 @@ const WalletTable = ({ data, filters, walletData }: WalletTableProps) => {
432432
<Td lineHeight="revert">
433433
<FlexInfo>
434434
<Box>
435-
<Img
436-
as={GatsbyImage}
435+
<GatsbyImage
437436
image={getImage(data[wallet.image_name])!}
438437
alt=""
439438
objectFit="contain"

0 commit comments

Comments
 (0)