From 7cb445d9e751e10f61a6db25bfd3ab78f610af71 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 29 Dec 2020 02:07:42 -0700 Subject: [PATCH] improve footer layout [skip ci] --- hyperglass/ui/components/Footer/button.tsx | 14 +++-- hyperglass/ui/components/Footer/footer.tsx | 34 ++++++------ .../ui/components/buttons/colorMode.tsx | 51 +++++++++--------- hyperglass/ui/components/help/modal.tsx | 52 +++++++++---------- hyperglass/ui/components/help/types.ts | 3 +- hyperglass/ui/components/layout/frame.tsx | 17 ++++-- .../ui/components/layout/resetButton.tsx | 39 ++++++++++++++ hyperglass/ui/components/layout/types.ts | 5 ++ 8 files changed, 138 insertions(+), 77 deletions(-) create mode 100644 hyperglass/ui/components/layout/resetButton.tsx diff --git a/hyperglass/ui/components/Footer/button.tsx b/hyperglass/ui/components/Footer/button.tsx index 42b0948..fecd07d 100644 --- a/hyperglass/ui/components/Footer/button.tsx +++ b/hyperglass/ui/components/Footer/button.tsx @@ -1,24 +1,32 @@ import { Button, Menu, MenuButton, MenuList } from '@chakra-ui/react'; import { Markdown } from '~/components'; +import { useColorValue, useBreakpointValue } from '~/context'; +import { useOpposingColor } from '~/hooks'; import type { TFooterButton } from './types'; export const FooterButton = (props: TFooterButton) => { const { content, title, side, ...rest } = props; - const placement = side === 'left' ? 'top-end' : side === 'right' ? 'top-start' : undefined; + const placement = side === 'left' ? 'top' : side === 'right' ? 'top-start' : undefined; + const bg = useColorValue('white', 'gray.900'); + const color = useOpposingColor(bg); + const size = useBreakpointValue({ base: 'xs', lg: 'sm' }); return ( {title} diff --git a/hyperglass/ui/components/Footer/footer.tsx b/hyperglass/ui/components/Footer/footer.tsx index b998963..e9529dd 100644 --- a/hyperglass/ui/components/Footer/footer.tsx +++ b/hyperglass/ui/components/Footer/footer.tsx @@ -1,7 +1,7 @@ import dynamic from 'next/dynamic'; -import { Button, Flex, Link } from '@chakra-ui/react'; -import { If } from '~/components'; -import { useConfig, useColorValue } from '~/context'; +import { Button, Flex, Link, HStack, useToken } from '@chakra-ui/react'; +import { If, ColorModeToggle } from '~/components'; +import { useConfig, useMobile, useColorValue, useBreakpointValue } from '~/context'; import { useStrf } from '~/hooks'; import { FooterButton } from './button'; @@ -16,41 +16,45 @@ export const Footer = () => { const extUrl = useStrf(web.external_link.url, { primary_asn }) ?? '/'; + const size = useBreakpointValue({ base: useToken('sizes', 4), lg: useToken('sizes', 6) }); + const btnSize = useBreakpointValue({ base: 'xs', lg: 'sm' }); + + const isMobile = useMobile(); + return ( - + spacing={{ base: 8, lg: 6 }} + justifyContent={{ base: 'center', lg: 'space-between' }}> - - - } /> - - + {!isMobile && } + + } /> + + + ); }; diff --git a/hyperglass/ui/components/buttons/colorMode.tsx b/hyperglass/ui/components/buttons/colorMode.tsx index 8f1c584..3626ee0 100644 --- a/hyperglass/ui/components/buttons/colorMode.tsx +++ b/hyperglass/ui/components/buttons/colorMode.tsx @@ -1,44 +1,43 @@ import { forwardRef } from 'react'; import dynamic from 'next/dynamic'; -import { Button, Icon } from '@chakra-ui/react'; +import { Button, Icon, Tooltip } from '@chakra-ui/react'; import { If } from '~/components'; -import { useColorMode, useColorValue } from '~/context'; +import { useColorMode, useColorValue, useBreakpointValue } from '~/context'; +import { useOpposingColor } from '~/hooks'; import type { TColorModeToggle } from './types'; const Sun = dynamic(() => import('@meronex/icons/hi').then(i => i.HiSun)); const Moon = dynamic(() => import('@meronex/icons/hi').then(i => i.HiMoon)); -const outlineColor = { dark: 'primary.300', light: 'primary.600' }; - export const ColorModeToggle = forwardRef((props, ref) => { const { size = '1.5rem', ...rest } = props; const { colorMode, toggleColorMode } = useColorMode(); + const bg = useColorValue('primary.500', 'yellow.300'); + const color = useOpposingColor(bg); const label = useColorValue('Switch to dark mode', 'Switch to light mode'); + const btnSize = useBreakpointValue({ base: 'xs', lg: 'sm' }); return ( - + + + ); }); diff --git a/hyperglass/ui/components/help/modal.tsx b/hyperglass/ui/components/help/modal.tsx index 393e5b9..a0c9c04 100644 --- a/hyperglass/ui/components/help/modal.tsx +++ b/hyperglass/ui/components/help/modal.tsx @@ -1,50 +1,48 @@ import dynamic from 'next/dynamic'; import { - IconButton, Modal, + ScaleFade, + ModalBody, + IconButton, + ModalHeader, ModalOverlay, ModalContent, - ModalHeader, - ModalBody, - ModalCloseButton, useDisclosure, + ModalCloseButton, } from '@chakra-ui/react'; -import { motion, AnimatePresence } from 'framer-motion'; import { Markdown } from '~/components'; import { useColorValue } from '~/context'; +import { isQueryContent } from '~/types'; import type { THelpModal } from './types'; const Info = dynamic(() => import('@meronex/icons/fi').then(i => i.FiInfo)); export const HelpModal = (props: THelpModal) => { - const { item, name, ...rest } = props; + const { visible, item, name, ...rest } = props; const { isOpen, onOpen, onClose } = useDisclosure(); const bg = useColorValue('whiteFaded.50', 'blackFaded.800'); const color = useColorValue('black', 'white'); + if (!isQueryContent(item)) { + return null; + } return ( <> - - - } - onClick={onOpen} - colorScheme="blue" - aria-label={`${name}_help`} - /> - - - + + } + onClick={onOpen} + colorScheme="blue" + aria-label={`${name}_help`} + /> + + {item.params.title} diff --git a/hyperglass/ui/components/help/types.ts b/hyperglass/ui/components/help/types.ts index 181604a..2a47dfc 100644 --- a/hyperglass/ui/components/help/types.ts +++ b/hyperglass/ui/components/help/types.ts @@ -2,6 +2,7 @@ import type { ModalContentProps } from '@chakra-ui/react'; import type { TQueryContent, TQueryFields } from '~/types'; export interface THelpModal extends ModalContentProps { - item: TQueryContent; + item: TQueryContent | null; name: TQueryFields; + visible: boolean; } diff --git a/hyperglass/ui/components/layout/frame.tsx b/hyperglass/ui/components/layout/frame.tsx index 8252d5a..e08abdf 100644 --- a/hyperglass/ui/components/layout/frame.tsx +++ b/hyperglass/ui/components/layout/frame.tsx @@ -1,8 +1,9 @@ import { useRef } from 'react'; import { Flex } from '@chakra-ui/react'; -import { useConfig, useColorValue } from '~/context'; import { If, Debugger, Greeting, Footer, Header } from '~/components'; +import { useConfig, useColorValue } from '~/context'; import { useLGState } from '~/hooks'; +import { ResetButton } from './resetButton'; import type { TFrame } from './types'; @@ -23,10 +24,15 @@ export const Frame = (props: TFrame) => { return ( <> - - -
- + +
{ + diff --git a/hyperglass/ui/components/layout/resetButton.tsx b/hyperglass/ui/components/layout/resetButton.tsx new file mode 100644 index 0000000..59ebfe7 --- /dev/null +++ b/hyperglass/ui/components/layout/resetButton.tsx @@ -0,0 +1,39 @@ +import dynamic from 'next/dynamic'; +import { Box, Flex, Icon, IconButton, Slide } from '@chakra-ui/react'; +import { useColorValue } from '~/context'; +import { useLGState, useOpposingColor } from '~/hooks'; + +import type { TResetButton } from './types'; + +const LeftArrow = dynamic(() => import('@meronex/icons/fa').then(i => i.FaAngleLeft)); + +export const ResetButton = (props: TResetButton) => { + const { developerMode, resetForm, ...rest } = props; + const { isSubmitting } = useLGState(); + const bg = useColorValue('primary.500', 'primary.300'); + const color = useOpposingColor(bg); + return ( + + + + } + /> + + + + ); +}; diff --git a/hyperglass/ui/components/layout/types.ts b/hyperglass/ui/components/layout/types.ts index 275c7a9..bf3ee75 100644 --- a/hyperglass/ui/components/layout/types.ts +++ b/hyperglass/ui/components/layout/types.ts @@ -1,3 +1,8 @@ import type { FlexProps } from '@chakra-ui/react'; export interface TFrame extends FlexProps {} + +export interface TResetButton extends FlexProps { + developerMode: boolean; + resetForm(): void; +}