From 4471f0bf90671eba3736e20e7d673410be235539 Mon Sep 17 00:00:00 2001 From: Pablo Pettinari Date: Mon, 25 Jul 2022 16:11:28 -0300 Subject: [PATCH 01/15] implement emotion --- docs/best-practices.md | 4 +- gatsby-config.ts | 2 +- package.json | 7 +- src/components/Accordion.tsx | 2 +- src/components/ActionCard.tsx | 2 +- src/components/AdoptionChart.tsx | 3 +- src/components/AssetDownload.tsx | 2 +- src/components/BannerGrid/index.tsx | 2 +- src/components/BannerNotification.tsx | 2 +- src/components/BeaconChainActions.tsx | 2 +- src/components/BoxGrid.tsx | 2 +- src/components/Breadcrumbs.tsx | 2 +- src/components/BugBountyCards.tsx | 2 +- src/components/BugBountyPoints.tsx | 8 +- src/components/ButtonDropdown.tsx | 2 +- src/components/ButtonLink.tsx | 2 +- src/components/CallToContribute.tsx | 2 +- src/components/Callout.tsx | 2 +- src/components/CalloutBanner.tsx | 2 +- src/components/Card.tsx | 2 +- src/components/CardList.tsx | 2 +- src/components/Checkbox.tsx | 6 +- src/components/CodeModal.tsx | 2 +- src/components/Codeblock.tsx | 9 +- src/components/Contributors.tsx | 2 +- src/components/DataProductCard.tsx | 2 +- src/components/DismissibleCard.tsx | 2 +- src/components/DocLink.tsx | 3 +- src/components/DocsNav.tsx | 2 +- src/components/Emoji.tsx | 2 +- src/components/EnergyConsumptionChart.tsx | 4 +- src/components/EthExchanges.js | 2 +- src/components/EthPriceCard.tsx | 2 +- src/components/EthVideo.tsx | 8 +- src/components/EventCard.tsx | 2 +- src/components/ExpandableCard.tsx | 2 +- src/components/ExpandableInfo.tsx | 2 +- src/components/FeedbackCard.tsx | 2 +- src/components/FeedbackWidget.tsx | 2 +- src/components/FileContributors.tsx | 19 +- .../FindWallet/WalletFilterSidebar.tsx | 2 +- .../FindWallet/WalletPersonasSidebar.tsx | 9 +- src/components/FindWallet/WalletTable.tsx | 2 +- src/components/Footer.tsx | 2 +- src/components/GhostCard.tsx | 2 +- src/components/GitStars.tsx | 2 +- src/components/GlobalStyle.tsx | 173 +++++++++++ src/components/HorizontalCard.tsx | 2 +- src/components/Icon.tsx | 2 +- src/components/ImageCard.tsx | 2 +- src/components/InfoBanner.tsx | 2 +- src/components/Layer2/Layer2Onboard.tsx | 2 +- src/components/Layer2ProductCard.tsx | 2 +- src/components/Layout.tsx | 7 +- src/components/Leaderboard.tsx | 2 +- src/components/Link.tsx | 2 +- src/components/Logo.tsx | 6 +- src/components/MarkdownTable.tsx | 2 +- src/components/MatomoOptOut.tsx | 2 +- src/components/MeetupList.tsx | 2 +- src/components/MergeArticleList.tsx | 2 +- src/components/MergeInfographic.tsx | 2 +- src/components/Modal.tsx | 2 +- src/components/Morpher.tsx | 2 +- src/components/NakedButton.tsx | 2 +- src/components/Nav/Dropdown.tsx | 2 +- src/components/Nav/Menu.tsx | 2 +- src/components/Nav/Mobile.tsx | 2 +- src/components/Nav/index.tsx | 2 +- src/components/OrderedList.tsx | 2 +- src/components/PageHero.tsx | 2 +- src/components/Pill.tsx | 2 +- src/components/PreMergeBanner.tsx | 2 +- src/components/ProductCard.tsx | 2 +- src/components/ProductList.tsx | 2 +- src/components/ReleaseBanner.tsx | 2 +- src/components/Roadmap.tsx | 2 +- src/components/RollupProductDevDoc.tsx | 2 +- src/components/Search/Input.tsx | 2 +- src/components/Search/index.tsx | 2 +- src/components/SectionNav.tsx | 2 +- src/components/SelectableCard.js | 2 +- src/components/ShardChainsList.tsx | 2 +- src/components/SharedStyledComponents.tsx | 2 +- src/components/SideNav.tsx | 2 +- src/components/SideNavMobile.tsx | 2 +- src/components/SimpleTable.tsx | 2 +- src/components/SkipLink.tsx | 2 +- src/components/Slider.tsx | 3 +- src/components/SocialListItem.tsx | 2 +- src/components/StablecoinAccordion.tsx | 2 +- src/components/StablecoinBoxGrid.tsx | 2 +- .../Staking/StakingCommunityCallout.tsx | 2 +- src/components/Staking/StakingComparison.tsx | 7 +- .../Staking/StakingConsiderations.tsx | 2 +- src/components/Staking/StakingGuides.tsx | 2 +- src/components/Staking/StakingHierarchy.tsx | 2 +- .../Staking/StakingHomeTableOfContents.tsx | 2 +- .../Staking/StakingHowSoloWorks.tsx | 2 +- .../Staking/StakingLaunchpadWidget.tsx | 2 +- .../Staking/StakingProductsCardGrid.tsx | 7 +- src/components/Staking/StakingStatsBox.tsx | 2 +- src/components/StatLoadingMessage.tsx | 2 +- src/components/StatsBoxGrid.tsx | 2 +- src/components/TableOfContents.tsx | 2 +- src/components/Tabs.tsx | 2 +- src/components/Tag.tsx | 2 +- src/components/TitleCardList.tsx | 2 +- src/components/Tooltip.tsx | 2 +- src/components/TranslationBanner.tsx | 2 +- src/components/TranslationBannerLegal.tsx | 2 +- src/components/TranslationLeaderboard.tsx | 2 +- src/components/TranslationsInProgress.tsx | 2 +- src/components/Trilemma.tsx | 2 +- src/components/TutorialMetadata.tsx | 2 +- src/components/TutorialTags.tsx | 2 +- src/components/UpcomingEventsList.tsx | 2 +- src/components/UpgradeArticles.tsx | 2 +- src/components/UpgradeBannerNotification.tsx | 2 +- src/components/UpgradeStatus.tsx | 2 +- src/components/UpgradeTableOfContents.tsx | 2 +- src/components/VisuallyHidden.tsx | 2 +- src/components/YouTube.tsx | 2 +- src/pages-conditional/dapps.tsx | 2 +- src/pages-conditional/eth.tsx | 2 +- src/pages-conditional/wallets.tsx | 2 +- src/pages-conditional/what-is-ethereum.tsx | 3 +- src/pages/404.tsx | 2 +- src/pages/assets.tsx | 8 +- src/pages/bug-bounty.tsx | 8 +- src/pages/community.tsx | 2 +- .../translation-program/acknowledgements.tsx | 7 +- .../translation-program/contributors.tsx | 2 +- src/pages/developers/index.tsx | 2 +- src/pages/developers/learning-tools.tsx | 2 +- src/pages/developers/local-environment.tsx | 2 +- src/pages/developers/tutorials.tsx | 2 +- src/pages/get-eth.tsx | 2 +- src/pages/index.tsx | 2 +- src/pages/languages.tsx | 2 +- src/pages/layer-2.js | 2 +- src/pages/learn/index.tsx | 2 +- src/pages/run-a-node.js | 2 +- src/pages/stablecoins.js | 2 +- src/pages/staking/deposit-contract.tsx | 2 +- src/pages/staking/index.tsx | 2 +- src/pages/studio.tsx | 2 +- src/pages/upgrades/get-involved/index.tsx | 8 +- src/pages/upgrades/index.js | 2 +- src/pages/upgrades/vision.js | 2 +- src/pages/wallets/find-wallet.tsx | 2 +- src/styled.d.ts | 6 +- src/templates/docs.tsx | 2 +- src/templates/staking.tsx | 2 +- src/templates/static.tsx | 2 +- src/templates/tutorial.tsx | 2 +- src/templates/upgrade.tsx | 2 +- src/templates/use-cases.tsx | 2 +- src/theme.ts | 219 +------------ yarn.lock | 289 ++++++++++++------ 160 files changed, 583 insertions(+), 518 deletions(-) create mode 100644 src/components/GlobalStyle.tsx diff --git a/docs/best-practices.md b/docs/best-practices.md index 560704e6d70..55bc8560500 100644 --- a/docs/best-practices.md +++ b/docs/best-practices.md @@ -111,7 +111,7 @@ export default ComponentName ```tsx // Example of styling syntax using styled-components - import styled from "styled-components" + import styled from "@emotion/styled" const GenericButton = styled.div` width: 200px; @@ -135,7 +135,7 @@ export default ComponentName ```tsx // Example of theme.ts usage - import styled from "styled-components" + import styled from "@emotion/styled" const Container = styled.div` background: ${(props) => props.theme.colors.background}; diff --git a/gatsby-config.ts b/gatsby-config.ts index df51dfec412..8e3a913ee74 100644 --- a/gatsby-config.ts +++ b/gatsby-config.ts @@ -185,7 +185,7 @@ const config: GatsbyConfig = { }, }, // CSS in JS - `gatsby-plugin-styled-components`, + `gatsby-plugin-emotion`, // Source assets { resolve: `gatsby-source-filesystem`, diff --git a/package.json b/package.json index b94493f8871..39ba1674e60 100644 --- a/package.json +++ b/package.json @@ -9,13 +9,14 @@ "private": false, "dependencies": { "@apollo/client": "^3.3.13", + "@emotion/react": "^11.9.3", + "@emotion/styled": "^11.9.3", "@formatjs/intl-locale": "^2.4.14", "@formatjs/intl-numberformat": "^6.1.4", "@mdx-js/mdx": "^1.6.5", "@mdx-js/react": "^1.6.5", "algoliasearch": "^4.3.0", "axios": "^0.21.2", - "babel-plugin-styled-components": "^1.10.7", "browser-lang": "^0.1.0", "browserslist": "^4.21.0", "clipboard": "^2.0.6", @@ -26,6 +27,7 @@ "focus-trap-react": "^8.11.2", "framer-motion": "^4.1.3", "gatsby": "^4.15.0", + "gatsby-plugin-emotion": "^7.19.0", "gatsby-plugin-gatsby-cloud": "^4.3.0", "gatsby-plugin-image": "^2.0.0", "gatsby-plugin-manifest": "^4.10.1", @@ -37,7 +39,6 @@ "gatsby-plugin-react-svg": "^3.1.0", "gatsby-plugin-sharp": "^4.10.0", "gatsby-plugin-sitemap": "^5.0.0", - "gatsby-plugin-styled-components": "^5.0.0", "gatsby-remark-autolink-headers": "^5.0.0", "gatsby-remark-copy-linked-files": "^5.0.0", "gatsby-remark-images": "^6.0.0", @@ -67,7 +68,6 @@ "react-intl": "^3.12.1", "react-select": "^4.3.0", "recharts": "^2.1.9", - "styled-components": "^5.1.1", "styled-system": "^5.1.5", "unist-util-visit-parents": "^2.1.2" }, @@ -80,7 +80,6 @@ "@types/react": "^17.0.39", "@types/react-dom": "^17.0.11", "@types/react-instantsearch-dom": "^6.12.3", - "@types/styled-components": "^5.1.25", "@types/styled-system": "^5.1.15", "babel-preset-gatsby": "^2.14.0", "github-slugger": "^1.3.0", diff --git a/src/components/Accordion.tsx b/src/components/Accordion.tsx index af7313bbbea..b8c7b36338f 100644 --- a/src/components/Accordion.tsx +++ b/src/components/Accordion.tsx @@ -1,4 +1,4 @@ -import styled from "styled-components" +import styled from "@emotion/styled" // TODO add motion animation // import { motion } from "framer-motion" import { FakeLink } from "./SharedStyledComponents" diff --git a/src/components/ActionCard.tsx b/src/components/ActionCard.tsx index df1c95d7f33..11e85d2aec1 100644 --- a/src/components/ActionCard.tsx +++ b/src/components/ActionCard.tsx @@ -1,5 +1,5 @@ import React from "react" -import styled from "styled-components" +import styled from "@emotion/styled" import { GatsbyImage } from "gatsby-plugin-image" import Link from "./Link" diff --git a/src/components/AdoptionChart.tsx b/src/components/AdoptionChart.tsx index b15b228cc12..b383d988a86 100644 --- a/src/components/AdoptionChart.tsx +++ b/src/components/AdoptionChart.tsx @@ -1,5 +1,6 @@ import React from "react" -import styled, { useTheme } from "styled-components" +import { useTheme } from "@emotion/react" +import styled from "@emotion/styled" const Container = styled.div` display: flex; diff --git a/src/components/AssetDownload.tsx b/src/components/AssetDownload.tsx index cd70401518a..1a477c88af0 100644 --- a/src/components/AssetDownload.tsx +++ b/src/components/AssetDownload.tsx @@ -1,5 +1,5 @@ import React from "react" -import styled from "styled-components" +import styled from "@emotion/styled" import { GatsbyImage, getImage, getSrc } from "gatsby-plugin-image" import Translation from "../components/Translation" diff --git a/src/components/BannerGrid/index.tsx b/src/components/BannerGrid/index.tsx index 9f070162204..574bc9c511c 100644 --- a/src/components/BannerGrid/index.tsx +++ b/src/components/BannerGrid/index.tsx @@ -1,4 +1,4 @@ -import styled from "styled-components" +import styled from "@emotion/styled" export const Banner = styled.div` width: 100%; diff --git a/src/components/BannerNotification.tsx b/src/components/BannerNotification.tsx index 794894e108f..11f6503d62d 100644 --- a/src/components/BannerNotification.tsx +++ b/src/components/BannerNotification.tsx @@ -1,5 +1,5 @@ import React from "react" -import styled from "styled-components" +import styled from "@emotion/styled" export interface IStyledBanner { shouldShow: boolean diff --git a/src/components/BeaconChainActions.tsx b/src/components/BeaconChainActions.tsx index d7710ee4f21..51cdca046ca 100644 --- a/src/components/BeaconChainActions.tsx +++ b/src/components/BeaconChainActions.tsx @@ -1,7 +1,7 @@ import React from "react" import { useStaticQuery, graphql } from "gatsby" import { getImage } from "gatsby-plugin-image" -import styled from "styled-components" +import styled from "@emotion/styled" import { useIntl } from "react-intl" import { translateMessageId } from "../utils/translations" diff --git a/src/components/BoxGrid.tsx b/src/components/BoxGrid.tsx index 8c8bb329ecc..a64ec7663ed 100644 --- a/src/components/BoxGrid.tsx +++ b/src/components/BoxGrid.tsx @@ -1,5 +1,5 @@ import React, { useState } from "react" -import styled from "styled-components" +import styled from "@emotion/styled" import Emoji from "./Emoji" export interface IBoxItem { diff --git a/src/components/Breadcrumbs.tsx b/src/components/Breadcrumbs.tsx index f2b4b4dabf6..607a4bdfe6d 100644 --- a/src/components/Breadcrumbs.tsx +++ b/src/components/Breadcrumbs.tsx @@ -1,5 +1,5 @@ import React from "react" -import styled from "styled-components" +import styled from "@emotion/styled" import { useIntl } from "react-intl" import Link from "./Link" diff --git a/src/components/BugBountyCards.tsx b/src/components/BugBountyCards.tsx index b084c10fd9c..50daca7cdb0 100644 --- a/src/components/BugBountyCards.tsx +++ b/src/components/BugBountyCards.tsx @@ -1,5 +1,5 @@ import React from "react" -import styled from "styled-components" +import styled from "@emotion/styled" import { TranslationKey } from "../utils/translations" import ButtonLink from "./ButtonLink" diff --git a/src/components/BugBountyPoints.tsx b/src/components/BugBountyPoints.tsx index 490492e255e..19d12668418 100644 --- a/src/components/BugBountyPoints.tsx +++ b/src/components/BugBountyPoints.tsx @@ -1,8 +1,8 @@ import React, { useContext, useState, useEffect } from "react" -import { ThemeContext } from "styled-components" +import { useTheme } from "@emotion/react" import { useStaticQuery, graphql } from "gatsby" import { GatsbyImage, getImage } from "gatsby-plugin-image" -import styled from "styled-components" +import styled from "@emotion/styled" import axios from "axios" import Emoji from "./Emoji" @@ -103,8 +103,8 @@ const BugBountyPoints: React.FC = () => { currentDAIPriceUSD: 1, hasError: false, }) - const themeContext = useContext(ThemeContext) - const isDarkTheme = themeContext.isDark + const theme = useTheme() + const isDarkTheme = theme.isDark useEffect(() => { axios diff --git a/src/components/ButtonDropdown.tsx b/src/components/ButtonDropdown.tsx index 957fee6cc5f..803caa62705 100644 --- a/src/components/ButtonDropdown.tsx +++ b/src/components/ButtonDropdown.tsx @@ -1,6 +1,6 @@ // Libraries import React, { useState, createRef } from "react" -import styled from "styled-components" +import styled from "@emotion/styled" import { useIntl } from "react-intl" import { motion } from "framer-motion" diff --git a/src/components/ButtonLink.tsx b/src/components/ButtonLink.tsx index b5cd8ac16c3..d852bff3bfd 100644 --- a/src/components/ButtonLink.tsx +++ b/src/components/ButtonLink.tsx @@ -1,5 +1,5 @@ import React from "react" -import styled from "styled-components" +import styled from "@emotion/styled" import { margin, MarginProps } from "styled-system" import { scrollIntoView } from "../utils/scrollIntoView" diff --git a/src/components/CallToContribute.tsx b/src/components/CallToContribute.tsx index 5acf63c4f4e..c22f9ad8e33 100644 --- a/src/components/CallToContribute.tsx +++ b/src/components/CallToContribute.tsx @@ -1,5 +1,5 @@ import React from "react" -import styled from "styled-components" +import styled from "@emotion/styled" import Link from "./Link" import ButtonLink from "./ButtonLink" import Icon from "./Icon" diff --git a/src/components/Callout.tsx b/src/components/Callout.tsx index 1831d1cd56d..c693df91968 100644 --- a/src/components/Callout.tsx +++ b/src/components/Callout.tsx @@ -1,6 +1,6 @@ // Libraries import React from "react" -import styled from "styled-components" +import styled from "@emotion/styled" import { GatsbyImage } from "gatsby-plugin-image" import Translation from "./Translation" import { TranslationKey } from "../utils/translations" diff --git a/src/components/CalloutBanner.tsx b/src/components/CalloutBanner.tsx index 45b99715c87..25cac746bb5 100644 --- a/src/components/CalloutBanner.tsx +++ b/src/components/CalloutBanner.tsx @@ -1,5 +1,5 @@ import React from "react" -import styled from "styled-components" +import styled from "@emotion/styled" import { GatsbyImage } from "gatsby-plugin-image" import Translation from "./Translation" diff --git a/src/components/Card.tsx b/src/components/Card.tsx index 706d6f56b96..bba088be74c 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -1,5 +1,5 @@ import React, { ReactNode } from "react" -import styled from "styled-components" +import styled from "@emotion/styled" import Emoji from "./Emoji" const StyledCard = styled.div` diff --git a/src/components/CardList.tsx b/src/components/CardList.tsx index 7d3e5243841..e9b30893093 100644 --- a/src/components/CardList.tsx +++ b/src/components/CardList.tsx @@ -1,5 +1,5 @@ import React, { ReactNode } from "react" -import styled from "styled-components" +import styled from "@emotion/styled" import { GatsbyImage } from "gatsby-plugin-image" import Link from "./Link" diff --git a/src/components/Checkbox.tsx b/src/components/Checkbox.tsx index fa11d530c85..07a63007991 100644 --- a/src/components/Checkbox.tsx +++ b/src/components/Checkbox.tsx @@ -1,12 +1,12 @@ import React from "react" -import styled from "styled-components" +import styled from "@emotion/styled" const CheckboxContainer = styled.div` display: inline-block; vertical-align: middle; ` -const HiddenCheckbox = styled.input.attrs({ type: "checkbox" })` +const HiddenCheckbox = styled.input` border: 0; clip: rect(0 0 0 0); height: 1px; @@ -76,7 +76,7 @@ const Checkbox: React.FC = ({ } return ( - +