oops, fix bug in Chakra globals

ahh, right, I was overriding their html/body styles! stop doing that 😅
This commit is contained in:
Emi Matchu 2020-09-07 21:11:10 -07:00
parent 901a6b14f0
commit 75ffd813e9

View file

@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import { ApolloProvider } from "@apollo/client"; import { ApolloProvider } from "@apollo/client";
import { Auth0Provider } from "@auth0/auth0-react"; import { Auth0Provider } from "@auth0/auth0-react";
import { CSSReset, ChakraProvider, useColorMode } from "@chakra-ui/core"; import { CSSReset, ChakraProvider } from "@chakra-ui/core";
import defaultTheme from "@chakra-ui/theme"; import defaultTheme from "@chakra-ui/theme";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom"; import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import loadable from "@loadable/component"; import loadable from "@loadable/component";
@ -19,20 +19,24 @@ const theme = {
...defaultTheme, ...defaultTheme,
styles: { styles: {
...defaultTheme.styles, ...defaultTheme.styles,
global: ({ colorMode, ...rest }) => ({ global: ({ colorMode, ...rest }) => {
...defaultTheme.styles.global({ colorMode, ...rest }), const defaultGlobals = defaultTheme.styles.global({ colorMode, ...rest });
return {
...defaultGlobals,
html: { html: {
...defaultGlobals.html,
// HACK: Chakra sets body as the relative position element, which is // HACK: Chakra sets body as the relative position element, which is
// fine, except its `min-height: 100%` doesn't actually work // fine, except its `min-height: 100%` doesn't actually work
// unless paired with height on the root element too! // unless paired with height on the root element too!
height: "100%", height: "100%",
}, },
body: { body: {
background: colorMode === "light" ? "white" : "gray.800", ...defaultGlobals.body,
color: colorMode === "light" ? "green.800" : "green.50", color: colorMode === "light" ? "green.800" : "green.50",
transition: "all 0.25s", transition: "all 0.25s",
}, },
}), };
},
}, },
}; };