diff --git a/src/app/App.js b/src/app/App.js index 4d6998b..bbcdfd0 100644 --- a/src/app/App.js +++ b/src/app/App.js @@ -1,7 +1,7 @@ import React from "react"; import { ApolloProvider } from "@apollo/client"; import { CSSReset, ChakraProvider } from "@chakra-ui/core"; -import theme from "@chakra-ui/theme"; +import defaultTheme from "@chakra-ui/theme"; import { BrowserRouter as Router, Switch, Route } from "react-router-dom"; import loadable from "@loadable/component"; @@ -10,6 +10,19 @@ import apolloClient from "./apolloClient"; const WardrobePage = loadable(() => import("./WardrobePage")); const HomePage = loadable(() => import("./HomePage")); +const theme = { + ...defaultTheme, + styles: { + ...defaultTheme.styles, + global: ({ colorMode, ...rest }) => ({ + ...defaultTheme.styles.global({ colorMode, ...rest }), + color: colorMode === "light" ? "green.800" : "green.50", + }), + }, +}; + +console.log(defaultTheme.styles.global, defaultTheme.styles); + /** * App is the entry point of our application. There's not a ton of exciting * stuff happening here, mostly just setting up some globals and theming! diff --git a/src/app/HomePage.js b/src/app/HomePage.js index dd14065..cb4eb7c 100644 --- a/src/app/HomePage.js +++ b/src/app/HomePage.js @@ -1,7 +1,18 @@ import React from "react"; import { css } from "emotion"; import gql from "graphql-tag"; -import { Box, Button, Flex, Input, useTheme, useToast } from "@chakra-ui/core"; +import { + Box, + Button, + Flex, + IconButton, + Input, + useColorMode, + useColorModeValue, + useTheme, + useToast, +} from "@chakra-ui/core"; +import { MoonIcon, SunIcon } from "@chakra-ui/icons"; import { useHistory, useLocation } from "react-router-dom"; import { useLazyQuery } from "@apollo/client"; @@ -19,13 +30,8 @@ function HomePage() { const [previewState, setPreviewState] = React.useState(null); return ( - + + @@ -121,8 +130,8 @@ function StartOutfitForm({ onChange }) { type="submit" colorScheme="green" disabled={!isValid} - backgroundColor="green.600" // for AA contrast - _hover={{ backgroundColor: "green.700" }} + backgroundColor={buttonBgColor} + _hover={{ backgroundColor: buttonBgColorHover }} > Start @@ -192,6 +201,11 @@ function SubmitPetForm() { import("./WardrobePage"); }; + const inputBorderColor = useColorModeValue("green.600", "green.500"); + const inputBorderColorHover = useColorModeValue("green.400", "green.300"); + const buttonBgColor = useColorModeValue("green.600", "green.300"); + const buttonBgColorHover = useColorModeValue("green.700", "green.200"); + return (
@@ -201,8 +215,8 @@ function SubmitPetForm() { isDisabled={loading} placeholder="Enter a pet's name" aria-label="Enter a pet's name" - borderColor="green.600" - _hover={{ borderColor: "green.400" }} + borderColor={inputBorderColor} + _hover={{ borderColor: inputBorderColorHover }} boxShadow="md" width="14em" className={css` @@ -217,8 +231,8 @@ function SubmitPetForm() { colorScheme="green" isDisabled={!petName} isLoading={loading} - backgroundColor="green.600" // for AA contrast - _hover={{ backgroundColor: "green.700" }} + backgroundColor={buttonBgColor} // for AA contrast + _hover={{ backgroundColor: buttonBgColorHover }} > Start @@ -227,6 +241,21 @@ function SubmitPetForm() { ); } +function ColorModeToggleButton() { + const { colorMode, toggleColorMode } = useColorMode(); + + return ( + : } + onClick={toggleColorMode} + variant="ghost" + position="absolute" + bottom="3" + right="3" + /> + ); +} + /** * useSupportSetup helps our support staff get set up with special access. * If you provide ?supportSecret=... in the URL, we'll save it in a cookie and diff --git a/src/app/WardrobePage/Item.js b/src/app/WardrobePage/Item.js index 1940be2..3e8a08c 100644 --- a/src/app/WardrobePage/Item.js +++ b/src/app/WardrobePage/Item.js @@ -7,6 +7,7 @@ import { Image, Skeleton, Tooltip, + useColorModeValue, useTheme, } from "@chakra-ui/core"; import { EditIcon, DeleteIcon, InfoIcon } from "@chakra-ui/icons"; @@ -120,6 +121,21 @@ function ItemSkeleton() { function ItemContainer({ children }) { const theme = useTheme(); + const focusBackgroundColor = useColorModeValue( + theme.colors.gray["100"], + theme.colors.gray["700"] + ); + + const activeBorderColor = useColorModeValue( + theme.colors.green["400"], + theme.colors.green["500"] + ); + + const focusCheckedBorderColor = useColorModeValue( + theme.colors.green["800"], + theme.colors.green["300"] + ); + return ( @@ -111,8 +114,7 @@ function SearchToolbar({ onChange(e.target.value)} diff --git a/src/app/WardrobePage/ItemsPanel.js b/src/app/WardrobePage/ItemsPanel.js index a229292..118ab18 100644 --- a/src/app/WardrobePage/ItemsPanel.js +++ b/src/app/WardrobePage/ItemsPanel.js @@ -33,7 +33,7 @@ function ItemsPanel({ outfitState, loading, dispatchToOutfit }) { const { zonesAndItems } = outfitState; return ( - + } variant="link" - color="green.600" aria-label="Edit outfit name" title="Edit outfit name" /> diff --git a/src/app/WardrobePage/OutfitControls.js b/src/app/WardrobePage/OutfitControls.js index 6278abc..48c395b 100644 --- a/src/app/WardrobePage/OutfitControls.js +++ b/src/app/WardrobePage/OutfitControls.js @@ -2,6 +2,7 @@ import React from "react"; import { css, cx } from "emotion"; import { Box, + DarkMode, Flex, IconButton, Stack, @@ -155,13 +156,14 @@ function OutfitControls({ outfitState, dispatchToOutfit }) { */} - + + + { // This will catch any Escape presses when the user's focus is inside // the SearchPanel. @@ -125,7 +124,7 @@ function SearchResults({ ); } else if (error) { return ( - + We hit an error trying to load your search results{" "} 😓 @@ -135,7 +134,7 @@ function SearchResults({ ); } else if (items.length === 0) { return ( - + We couldn't find any matching items{" "} 🤔 diff --git a/src/app/WardrobePage/support/ItemLayerSupportModal.js b/src/app/WardrobePage/support/ItemLayerSupportModal.js index c08fea1..bc0147b 100644 --- a/src/app/WardrobePage/support/ItemLayerSupportModal.js +++ b/src/app/WardrobePage/support/ItemLayerSupportModal.js @@ -122,7 +122,7 @@ function ItemLayerSupportModal({ return ( - + Layer {itemLayer.id}: {item.name} diff --git a/src/app/WardrobePage/support/ItemLayerSupportUploadModal.js b/src/app/WardrobePage/support/ItemLayerSupportUploadModal.js index edbe588..9be102f 100644 --- a/src/app/WardrobePage/support/ItemLayerSupportUploadModal.js +++ b/src/app/WardrobePage/support/ItemLayerSupportUploadModal.js @@ -144,7 +144,7 @@ function ItemLayerSupportUploadModal({ item, itemLayer, isOpen, onClose }) { onClose={onClose} > - + Upload PNG for {item.name} diff --git a/src/app/WardrobePage/support/ItemSupportDrawer.js b/src/app/WardrobePage/support/ItemSupportDrawer.js index 9077a9e..f57bbba 100644 --- a/src/app/WardrobePage/support/ItemSupportDrawer.js +++ b/src/app/WardrobePage/support/ItemSupportDrawer.js @@ -21,6 +21,7 @@ import { Spinner, Stack, useBreakpointValue, + useColorModeValue, useDisclosure, } from "@chakra-ui/core"; import { CheckCircleIcon, EditIcon, ExternalLinkIcon } from "@chakra-ui/icons"; @@ -66,13 +67,13 @@ function ItemSupportDrawer({ item, isOpen, onClose }) { overflow="auto" > - + {item.name} Support - + @@ -156,6 +157,8 @@ function ItemSupportSpecialColorFields({ item }) { colorsData?.allColors?.filter((c) => !c.isStandard) || []; nonStandardColors.sort((a, b) => a.name.localeCompare(b.name)); + const linkColor = useColorModeValue("green.500", "green.300"); + return ( item page diff --git a/src/app/components/HangerSpinner.js b/src/app/components/HangerSpinner.js index f0f5294..0033ab5 100644 --- a/src/app/components/HangerSpinner.js +++ b/src/app/components/HangerSpinner.js @@ -82,7 +82,7 @@ function HangerSpinner(props) { } `} > - + ); diff --git a/src/app/components/OutfitPreview.js b/src/app/components/OutfitPreview.js index e80dd79..53e45df 100644 --- a/src/app/components/OutfitPreview.js +++ b/src/app/components/OutfitPreview.js @@ -176,7 +176,7 @@ export function OutfitLayers({ /> - + diff --git a/src/app/components/SpeciesColorPicker.js b/src/app/components/SpeciesColorPicker.js index d3f6351..2f56ad4 100644 --- a/src/app/components/SpeciesColorPicker.js +++ b/src/app/components/SpeciesColorPicker.js @@ -1,7 +1,7 @@ import React from "react"; import gql from "graphql-tag"; import { useQuery } from "@apollo/client"; -import { Box, Flex, Select, Text } from "@chakra-ui/core"; +import { Box, Flex, Select, Text, useColorModeValue } from "@chakra-ui/core"; import { Delay, useFetch } from "../util"; @@ -55,9 +55,10 @@ function SpeciesColorPicker({ const allSpecies = (meta && [...meta.allSpecies]) || []; allSpecies.sort((a, b) => a.name.localeCompare(b.name)); - const backgroundColor = dark ? "gray.600" : "white"; - const borderColor = dark ? "transparent" : "green.600"; - const textColor = dark ? "gray.50" : "inherit"; + const backgroundColor = useColorModeValue("white", "gray.600"); + const borderColor = useColorModeValue("green.600", "transparent"); + const textColor = useColorModeValue("inherit", "green.50"); + const SpeciesColorSelect = ({ isDisabled, isLoading, ...props }) => { const loadingProps = isLoading ? { diff --git a/src/app/util.js b/src/app/util.js index ed942ad..99e5ae5 100644 --- a/src/app/util.js +++ b/src/app/util.js @@ -34,9 +34,9 @@ export function Delay({ children, ms = 300 }) { export function Heading1({ children, ...props }) { return ( {children} @@ -52,7 +52,6 @@ export function Heading2({ children, ...props }) { return (