From f76bc143cc491e2d5ae74c64894e07bfb7e26bec Mon Sep 17 00:00:00 2001 From: Brad Garropy Date: Tue, 27 Apr 2021 23:28:25 -0500 Subject: [PATCH] dark mode. (#205) --- gatsby-config.js | 14 + package-lock.json | 259 ++++++++++++++++++ package.json | 2 + src/components/ColorTheme/ColorTheme.js | 48 ++++ src/components/ColorTheme/ColorTheme.test.js | 30 ++ src/components/ColorTheme/index.js | 1 + src/components/Hamburger/Hamburger.js | 7 +- src/components/Hamburger/Hamburger.test.js | 17 +- src/components/Header/Header.js | 14 +- src/components/Header/Header.test.js | 7 + src/components/Hero/Hero.js | 5 +- src/components/LatestVideos/LatestVideos.js | 7 +- src/components/Layout/Layout.js | 5 +- src/components/LinkButton/LinkButton.js | 6 +- src/components/Logo/Logo.js | 1 + .../MobileNavigation/MobileNavigation.js | 15 +- .../MobileNavigation/MobileNavigation.test.js | 79 +++--- src/components/Navigation/Navigation.js | 3 +- src/components/Now/Now.js | 6 +- src/components/Podcast/Podcast.js | 15 +- src/components/PostList/PostList.js | 1 + src/components/PostMeta/PostMeta.js | 2 +- src/components/PostSearchBar/PostSearchBar.js | 3 +- src/components/PostTitle/PostTitle.js | 2 +- src/components/Project/Project.js | 7 +- src/components/SocialLink/SocialLink.js | 3 +- src/context/App.js | 3 + src/context/index.js | 1 + src/hooks/index.js | 1 + src/hooks/useApp.js | 9 + src/pages/404.js | 5 +- src/pages/blog.js | 5 +- src/pages/contact.js | 5 +- src/pages/hire-me.js | 5 +- src/pages/index.js | 5 +- src/pages/now.js | 5 +- src/pages/resume.js | 5 +- src/pages/sponsors.js | 10 +- src/pages/uses.js | 5 +- src/styles/GlobalStyles.js | 21 +- src/styles/partials.js | 3 +- src/svg/moon.svg | 14 + src/svg/sun.svg | 14 + src/templates/now.js | 5 +- src/templates/post.js | 5 +- src/templates/topic.js | 5 +- src/test-utils/file.js | 1 + src/test-utils/generators.js | 12 + src/test-utils/mocks.js | 8 + 49 files changed, 566 insertions(+), 145 deletions(-) create mode 100644 src/components/ColorTheme/ColorTheme.js create mode 100644 src/components/ColorTheme/ColorTheme.test.js create mode 100644 src/components/ColorTheme/index.js create mode 100644 src/context/index.js create mode 100644 src/hooks/useApp.js create mode 100644 src/svg/moon.svg create mode 100644 src/svg/sun.svg create mode 100644 src/test-utils/file.js create mode 100644 src/test-utils/generators.js diff --git a/gatsby-config.js b/gatsby-config.js index 40e6ecd2..66bd9ab4 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -190,6 +190,20 @@ const config = { { resolve: "@bradgarropy/gatsby-plugin-seo", }, + { + resolve: "gatsby-plugin-react-svg", + options: { + rule: { + include: /svg/, + }, + }, + }, + { + resolve: "gatsby-plugin-layout", + options: { + component: require.resolve("./src/components/Layout/Layout.js"), + }, + }, ], } diff --git a/package-lock.json b/package-lock.json index 543c3801..613578cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,9 @@ "gatsby-plugin-catch-links": "^3.0.0", "gatsby-plugin-google-analytics": "^3.0.0", "gatsby-plugin-image": "^1.0.1", + "gatsby-plugin-layout": "^2.4.0", "gatsby-plugin-react-helmet": "^4.0.0", + "gatsby-plugin-react-svg": "^3.0.1", "gatsby-plugin-sharp": "^3.0.1", "gatsby-plugin-sitemap": "^3.0.0", "gatsby-plugin-styled-components": "^4.0.0", @@ -17843,6 +17845,20 @@ "react-dom": "^16.9.0 || ^17.0.0" } }, + "node_modules/gatsby-plugin-layout": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/gatsby-plugin-layout/-/gatsby-plugin-layout-2.4.0.tgz", + "integrity": "sha512-NXX+bMDWmsb8r/GE5GHG1rSpypYCi7wUEuWf1ceDRafpEO8Bo4jI2Sx777vunTUgWLq6SN92EgUBm6d8D5AcfQ==", + "dependencies": { + "@babel/runtime": "^7.12.5" + }, + "engines": { + "node": ">=12.13.0" + }, + "peerDependencies": { + "gatsby": "^3.0.0-next.0" + } + }, "node_modules/gatsby-plugin-page-creator": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/gatsby-plugin-page-creator/-/gatsby-plugin-page-creator-3.3.0.tgz", @@ -17879,6 +17895,17 @@ "react-helmet": "^5.1.3 || ^6.0.0" } }, + "node_modules/gatsby-plugin-react-svg": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/gatsby-plugin-react-svg/-/gatsby-plugin-react-svg-3.0.1.tgz", + "integrity": "sha512-bjVSCAOeRWmf5a96/BL81sHITGFV/2Ql+IwP3ET5O5BZYOpt0f7QVCspkvCj0hsy4BJgCgANpzFstuaxUNsojA==", + "dependencies": { + "svg-react-loader": "^0.4.4" + }, + "peerDependencies": { + "gatsby": "^3.0.0 || ^2.0.0" + } + }, "node_modules/gatsby-plugin-sharp": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/gatsby-plugin-sharp/-/gatsby-plugin-sharp-3.3.0.tgz", @@ -31185,6 +31212,11 @@ } ] }, + "node_modules/ramda": { + "version": "0.21.0", + "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.21.0.tgz", + "integrity": "sha1-oAGr7bP/YQd9T/HVd9RN536NCjU=" + }, "node_modules/randomatic": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-3.1.1.tgz", @@ -32756,6 +32788,11 @@ "aproba": "^1.1.1" } }, + "node_modules/rx": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/rx/-/rx-4.1.0.tgz", + "integrity": "sha1-pfE/957zt0D+MKqAP7CfmIBdR4I=" + }, "node_modules/rx-lite": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", @@ -35047,6 +35084,107 @@ "node": ">=8" } }, + "node_modules/svg-react-loader": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/svg-react-loader/-/svg-react-loader-0.4.6.tgz", + "integrity": "sha512-HVEypjWQsQuJdBIPzXGxpmQsQts7QwfQuYgK1rah6BVCMoLNSCh/ESKVNd7/tHq8DkWYHHTyaUMDA1FjqZYrgA==", + "dependencies": { + "css": "2.2.4", + "loader-utils": "1.1.0", + "ramda": "0.21.0", + "rx": "4.1.0", + "traverse": "0.6.6", + "xml2js": "0.4.17" + } + }, + "node_modules/svg-react-loader/node_modules/big.js": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", + "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==", + "engines": { + "node": "*" + } + }, + "node_modules/svg-react-loader/node_modules/css": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz", + "integrity": "sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw==", + "dependencies": { + "inherits": "^2.0.3", + "source-map": "^0.6.1", + "source-map-resolve": "^0.5.2", + "urix": "^0.1.0" + } + }, + "node_modules/svg-react-loader/node_modules/emojis-list": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/svg-react-loader/node_modules/json5": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", + "bin": { + "json5": "lib/cli.js" + } + }, + "node_modules/svg-react-loader/node_modules/loader-utils": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz", + "integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=", + "dependencies": { + "big.js": "^3.1.3", + "emojis-list": "^2.0.0", + "json5": "^0.5.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/svg-react-loader/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/svg-react-loader/node_modules/source-map-resolve": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", + "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", + "dependencies": { + "atob": "^2.1.2", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" + } + }, + "node_modules/svg-react-loader/node_modules/xml2js": { + "version": "0.4.17", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz", + "integrity": "sha1-F76T6q4/O3eTWceVtBlwWogX6Gg=", + "dependencies": { + "sax": ">=0.6.0", + "xmlbuilder": "^4.1.0" + } + }, + "node_modules/svg-react-loader/node_modules/xmlbuilder": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.2.1.tgz", + "integrity": "sha1-qlijBBoGb5DqoWwvU4n/GfP0YaU=", + "dependencies": { + "lodash": "^4.0.0" + }, + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/svgo": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/svgo/-/svgo-1.3.2.tgz", @@ -35765,6 +35903,11 @@ "node": ">=8" } }, + "node_modules/traverse": { + "version": "0.6.6", + "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.6.tgz", + "integrity": "sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc=" + }, "node_modules/trim": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", @@ -53028,6 +53171,14 @@ "prop-types": "^15.7.2" } }, + "gatsby-plugin-layout": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/gatsby-plugin-layout/-/gatsby-plugin-layout-2.4.0.tgz", + "integrity": "sha512-NXX+bMDWmsb8r/GE5GHG1rSpypYCi7wUEuWf1ceDRafpEO8Bo4jI2Sx777vunTUgWLq6SN92EgUBm6d8D5AcfQ==", + "requires": { + "@babel/runtime": "^7.12.5" + } + }, "gatsby-plugin-page-creator": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/gatsby-plugin-page-creator/-/gatsby-plugin-page-creator-3.3.0.tgz", @@ -53051,6 +53202,14 @@ "@babel/runtime": "^7.12.5" } }, + "gatsby-plugin-react-svg": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/gatsby-plugin-react-svg/-/gatsby-plugin-react-svg-3.0.1.tgz", + "integrity": "sha512-bjVSCAOeRWmf5a96/BL81sHITGFV/2Ql+IwP3ET5O5BZYOpt0f7QVCspkvCj0hsy4BJgCgANpzFstuaxUNsojA==", + "requires": { + "svg-react-loader": "^0.4.4" + } + }, "gatsby-plugin-sharp": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/gatsby-plugin-sharp/-/gatsby-plugin-sharp-3.3.0.tgz", @@ -63118,6 +63277,11 @@ "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==" }, + "ramda": { + "version": "0.21.0", + "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.21.0.tgz", + "integrity": "sha1-oAGr7bP/YQd9T/HVd9RN536NCjU=" + }, "randomatic": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-3.1.1.tgz", @@ -64340,6 +64504,11 @@ "aproba": "^1.1.1" } }, + "rx": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/rx/-/rx-4.1.0.tgz", + "integrity": "sha1-pfE/957zt0D+MKqAP7CfmIBdR4I=" + }, "rx-lite": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", @@ -66198,6 +66367,91 @@ } } }, + "svg-react-loader": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/svg-react-loader/-/svg-react-loader-0.4.6.tgz", + "integrity": "sha512-HVEypjWQsQuJdBIPzXGxpmQsQts7QwfQuYgK1rah6BVCMoLNSCh/ESKVNd7/tHq8DkWYHHTyaUMDA1FjqZYrgA==", + "requires": { + "css": "2.2.4", + "loader-utils": "1.1.0", + "ramda": "0.21.0", + "rx": "4.1.0", + "traverse": "0.6.6", + "xml2js": "0.4.17" + }, + "dependencies": { + "big.js": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", + "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==" + }, + "css": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz", + "integrity": "sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw==", + "requires": { + "inherits": "^2.0.3", + "source-map": "^0.6.1", + "source-map-resolve": "^0.5.2", + "urix": "^0.1.0" + } + }, + "emojis-list": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=" + }, + "json5": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=" + }, + "loader-utils": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz", + "integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=", + "requires": { + "big.js": "^3.1.3", + "emojis-list": "^2.0.0", + "json5": "^0.5.0" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + }, + "source-map-resolve": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", + "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", + "requires": { + "atob": "^2.1.2", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" + } + }, + "xml2js": { + "version": "0.4.17", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz", + "integrity": "sha1-F76T6q4/O3eTWceVtBlwWogX6Gg=", + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": "^4.1.0" + } + }, + "xmlbuilder": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.2.1.tgz", + "integrity": "sha1-qlijBBoGb5DqoWwvU4n/GfP0YaU=", + "requires": { + "lodash": "^4.0.0" + } + } + } + }, "svgo": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/svgo/-/svgo-1.3.2.tgz", @@ -66780,6 +67034,11 @@ "punycode": "^2.1.1" } }, + "traverse": { + "version": "0.6.6", + "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.6.tgz", + "integrity": "sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc=" + }, "trim": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", diff --git a/package.json b/package.json index a80068e6..23075c26 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,9 @@ "gatsby-plugin-catch-links": "^3.0.0", "gatsby-plugin-google-analytics": "^3.0.0", "gatsby-plugin-image": "^1.0.1", + "gatsby-plugin-layout": "^2.4.0", "gatsby-plugin-react-helmet": "^4.0.0", + "gatsby-plugin-react-svg": "^3.0.1", "gatsby-plugin-sharp": "^3.0.1", "gatsby-plugin-sitemap": "^3.0.0", "gatsby-plugin-styled-components": "^4.0.0", diff --git a/src/components/ColorTheme/ColorTheme.js b/src/components/ColorTheme/ColorTheme.js new file mode 100644 index 00000000..5ea546c4 --- /dev/null +++ b/src/components/ColorTheme/ColorTheme.js @@ -0,0 +1,48 @@ +import {useApp} from "hooks" +import {useEffect} from "react" +import styled from "styled-components" +import Moon from "svg/moon.svg" +import Sun from "svg/sun.svg" + +const ThemeToggle = styled.button` + cursor: pointer; + border: none; + background: none; + padding: 0rem; + height: 1.5rem; +` + +const ColorTheme = () => { + const {theme, setTheme} = useApp() + const label = theme === "light" ? "dark" : "light" + + useEffect(() => { + const root = document.documentElement + + root.style.setProperty( + "--background", + theme === "light" ? "var(--white)" : "var(--black)", + ) + + root.style.setProperty( + "--text", + theme === "light" ? "var(--black)" : "var(--white)", + ) + }, [theme]) + + const onClick = () => { + if (theme === "light") { + setTheme("dark") + } else { + setTheme("light") + } + } + + return ( + + {theme === "light" ? : } + + ) +} + +export default ColorTheme diff --git a/src/components/ColorTheme/ColorTheme.test.js b/src/components/ColorTheme/ColorTheme.test.js new file mode 100644 index 00000000..81ca4dce --- /dev/null +++ b/src/components/ColorTheme/ColorTheme.test.js @@ -0,0 +1,30 @@ +import {render, screen} from "@testing-library/react" +import userEvent from "@testing-library/user-event" +import ColorTheme from "components/ColorTheme" +import {useApp} from "hooks" +import {generateAppCtx} from "test-utils/generators" + +const mockAppCtxLight = generateAppCtx({theme: "light"}) +const mockAppCtxDark = generateAppCtx({theme: "dark"}) + +jest.mock("hooks") + +test("toggles dark mode", () => { + useApp.mockReturnValue(mockAppCtxLight) + + render() + + userEvent.click(screen.getByLabelText("dark")) + expect(mockAppCtxLight.setTheme).toHaveBeenCalledTimes(1) + expect(mockAppCtxLight.setTheme).toHaveBeenCalledWith("dark") +}) + +test("toggles light mode", () => { + useApp.mockReturnValue(mockAppCtxDark) + + render() + + userEvent.click(screen.getByLabelText("light")) + expect(mockAppCtxDark.setTheme).toHaveBeenCalledTimes(1) + expect(mockAppCtxDark.setTheme).toHaveBeenCalledWith("light") +}) diff --git a/src/components/ColorTheme/index.js b/src/components/ColorTheme/index.js new file mode 100644 index 00000000..a048cf80 --- /dev/null +++ b/src/components/ColorTheme/index.js @@ -0,0 +1 @@ +export {default} from "./ColorTheme" diff --git a/src/components/Hamburger/Hamburger.js b/src/components/Hamburger/Hamburger.js index 4ed90975..5c81c44d 100644 --- a/src/components/Hamburger/Hamburger.js +++ b/src/components/Hamburger/Hamburger.js @@ -1,10 +1,10 @@ import {faBars} from "@fortawesome/free-solid-svg-icons" import {FontAwesomeIcon} from "@fortawesome/react-fontawesome" -import {AppContext} from "context/App" -import {useContext} from "react" +import {useApp} from "hooks" import styled from "styled-components" const HamburgerWrapper = styled(FontAwesomeIcon)` + color: var(--text); display: none; cursor: pointer; font-size: 1.5rem; @@ -15,8 +15,7 @@ const HamburgerWrapper = styled(FontAwesomeIcon)` ` const Hamburger = () => { - const appContext = useContext(AppContext) - const {setOpen} = appContext + const {setOpen} = useApp() const onClick = () => { setOpen(true) diff --git a/src/components/Hamburger/Hamburger.test.js b/src/components/Hamburger/Hamburger.test.js index 06c27968..c514a2cf 100644 --- a/src/components/Hamburger/Hamburger.test.js +++ b/src/components/Hamburger/Hamburger.test.js @@ -1,20 +1,17 @@ import {render, screen} from "@testing-library/react" import userEvent from "@testing-library/user-event" -import {AppContext} from "context/App" +import {useApp} from "hooks" +import {generateAppCtx} from "test-utils/generators" import Hamburger from "./Hamburger" -const mockAppCtx = { - open: false, - setOpen: jest.fn(), -} +const mockAppCtx = generateAppCtx() + +jest.mock("hooks") +useApp.mockReturnValue(mockAppCtx) test("opens mobile menu", () => { - render( - - - , - ) + render() userEvent.click(screen.getByLabelText("menu")) expect(mockAppCtx.setOpen).toHaveBeenCalledTimes(1) diff --git a/src/components/Header/Header.js b/src/components/Header/Header.js index f5f85719..766c76a2 100644 --- a/src/components/Header/Header.js +++ b/src/components/Header/Header.js @@ -1,7 +1,7 @@ +import ColorTheme from "components/ColorTheme" import Logo from "components/Logo" import MobileNavigation from "components/MobileNavigation" import Navigation from "components/Navigation" -import {AppProvider} from "context/App" import {Link} from "gatsby" import styled from "styled-components" @@ -17,6 +17,13 @@ const HeaderWrapper = styled.header` } ` +const Right = styled.div` + display: grid; + grid-auto-flow: column; + column-gap: 2rem; + align-items: center; +` + const Header = () => { return ( @@ -24,10 +31,11 @@ const Header = () => { - + - + + ) } diff --git a/src/components/Header/Header.test.js b/src/components/Header/Header.test.js index b1e15c17..ee4fe085 100644 --- a/src/components/Header/Header.test.js +++ b/src/components/Header/Header.test.js @@ -1,7 +1,14 @@ import {render, screen} from "@testing-library/react" +import {useApp} from "hooks" +import {generateAppCtx} from "test-utils/generators" import Header from "./Header" +const mockAppCtx = generateAppCtx() + +jest.mock("hooks") +useApp.mockReturnValue(mockAppCtx) + test("shows logo", () => { render(
) expect(screen.getByLabelText("bg")) diff --git a/src/components/Hero/Hero.js b/src/components/Hero/Hero.js index 2281ad7b..c2df9b88 100644 --- a/src/components/Hero/Hero.js +++ b/src/components/Hero/Hero.js @@ -22,9 +22,8 @@ const HeroImage = styled(Link)` .hero-image { border-radius: 100%; box-sizing: border-box; - border: 7px solid var(--black); - background-color: var(--black); - transition: all 300ms !important; + border: 7px solid var(--text); + background-color: var(--text); :hover { transform: rotate(-2deg); diff --git a/src/components/LatestVideos/LatestVideos.js b/src/components/LatestVideos/LatestVideos.js index b0cd71a0..4f18d97f 100644 --- a/src/components/LatestVideos/LatestVideos.js +++ b/src/components/LatestVideos/LatestVideos.js @@ -22,10 +22,9 @@ const Thumbnail = styled.div` .thumbnail { box-sizing: border-box; border-radius: 0.3rem; - border: 3px solid var(--black); - background-color: var(--black); - box-shadow: 3px 3px 0 var(--black); - transition: all 300ms !important; + border: 3px solid var(--text); + background-color: var(--text); + box-shadow: 3px 3px 0 var(--text); } .thumbnail:hover { diff --git a/src/components/Layout/Layout.js b/src/components/Layout/Layout.js index 350e8881..d369e62b 100644 --- a/src/components/Layout/Layout.js +++ b/src/components/Layout/Layout.js @@ -1,5 +1,6 @@ import Footer from "components/Footer" import Header from "components/Header" +import {AppProvider} from "context" import PropTypes from "prop-types" import styled from "styled-components" import GlobalStyles from "styles/GlobalStyles" @@ -24,7 +25,7 @@ const Content = styled.main` const Layout = ({children}) => { return ( - <> + @@ -32,7 +33,7 @@ const Layout = ({children}) => { {children}