From 0c93972aa9996f6ce7fd5ed154df2e847459f27d Mon Sep 17 00:00:00 2001 From: checktheroads Date: Sat, 28 Mar 2020 17:14:59 -0700 Subject: [PATCH] ui cleanup --- hyperglass/ui/components/Header.js | 17 ++++++++++++++--- hyperglass/ui/components/Title.js | 21 ++++++++++++--------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/hyperglass/ui/components/Header.js b/hyperglass/ui/components/Header.js index 64215c3..47f6f18 100644 --- a/hyperglass/ui/components/Header.js +++ b/hyperglass/ui/components/Header.js @@ -31,6 +31,10 @@ const icon = { light: "moon", dark: "sun" }; const bg = { light: "white", dark: "black" }; const colorSwitch = { dark: "Switch to light mode", light: "Switch to dark mode" }; const headerTransition = { type: "spring", ease: "anticipate", damping: 15, stiffness: 100 }; +const titleJustify = { + true: ["flex-end", "flex-end", "center", "center"], + false: ["flex-start", "flex-start", "center", "center"] +}; export default ({ height, isSubmitting, handleFormReset, ...props }) => { const { colorMode, toggleColorMode } = useColorMode(); @@ -44,6 +48,7 @@ export default ({ height, isSubmitting, handleFormReset, ...props }) => { exit={{ opacity: 0, x: -50 }} alignItems="center" mb={[null, "auto"]} + ml={isSubmitting ? 2 : null} > @@ -58,7 +63,7 @@ export default ({ height, isSubmitting, handleFormReset, ...props }) => { initial={{ scale: 0.5 }} animate={isSubmitting ? "small" : "fullSize"} variants={titleVariants[mediaSize]} - justifyContent="center" + justifyContent={titleJustify[isSubmitting]} mb={[null, isSubmitting ? "auto" : null]} mt={[null, isSubmitting ? null : "auto"]} maxW="100%" @@ -75,12 +80,12 @@ export default ({ height, isSubmitting, handleFormReset, ...props }) => { initial={{ opacity: 0 }} animate={{ opacity: 1 }} mb={[null, "auto"]} + mr={isSubmitting ? null : 2} > { height={height} {...props} > - + {layout[isSubmitting][mediaSize]} diff --git a/hyperglass/ui/components/Title.js b/hyperglass/ui/components/Title.js index 9a19fca..29adef1 100644 --- a/hyperglass/ui/components/Title.js +++ b/hyperglass/ui/components/Title.js @@ -21,9 +21,9 @@ const TitleOnly = ({ text, showSubtitle }) => ( ); -const SubtitleOnly = React.forwardRef(({ text, size = "md", ...props }, ref) => ( +const SubtitleOnly = React.forwardRef(({ text, mediaSize, size = "md", ...props }, ref) => ( - + {text} @@ -35,9 +35,17 @@ const textAlignment = { false: ["right", "center"], true: ["left", "center"] }; const TextOnly = ({ text, mediaSize, showSubtitle, ...props }) => ( - + + + - {showSubtitle && } + {showSubtitle && ( + + )} ); @@ -75,10 +83,6 @@ const widthMap = { all: ["90%", "90%", "25%", "25%"] }; -const btnJustify = { - true: ["flex-end", "center"], - false: ["flex-start", "center"] -}; export default React.forwardRef(({ onClick, isSubmitting, ...props }, ref) => { const { web } = useConfig(); const { mediaSize } = useMedia(); @@ -92,7 +96,6 @@ export default React.forwardRef(({ onClick, isSubmitting, ...props }, ref) => { flexWrap="wrap" _focus={{ boxShadow: "none" }} _hover={{ textDecoration: "none" }} - justifyContent={btnJustify[isSubmitting]} px={0} maxW={widthMap[titleMode]} {...props}