Commit 160fb865 authored by tom's avatar tom

tooltip when nav bar is collapsed

parent d1d24dac
import { Tooltip as TooltipComponent } from '@chakra-ui/react'; import { Tooltip as TooltipComponent } from '@chakra-ui/react';
import type { ComponentStyleConfig } from '@chakra-ui/theme'; import type { ComponentStyleConfig } from '@chakra-ui/theme';
import type { SystemStyleFunction } from '@chakra-ui/theme-tools';
import { mode } from '@chakra-ui/theme-tools';
const variantNav: SystemStyleFunction = (props) => {
return {
bg: mode('blue.50', 'gray.800')(props),
color: 'blue.400',
padding: '15px 12px',
minWidth: '120px',
borderRadius: 'base',
fontSize: '14px',
lineHeight: '20px',
textAlign: 'center',
boxShadow: 'none',
fontWeight: '500',
};
};
const variants = {
nav: variantNav,
};
const Tooltip: ComponentStyleConfig = { const Tooltip: ComponentStyleConfig = {
variants,
baseStyle: { baseStyle: {
maxWidth: 'unset', maxWidth: 'unset',
}, },
......
import { Link, Icon, Text, HStack } from '@chakra-ui/react'; import { Link, Icon, Text, HStack, Tooltip } from '@chakra-ui/react';
import NextLink from 'next/link'; import NextLink from 'next/link';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import React from 'react'; import React from 'react';
...@@ -22,6 +22,15 @@ const NavLink = ({ text, pathname, icon, isCollapsed }: Props) => { ...@@ -22,6 +22,15 @@ const NavLink = ({ text, pathname, icon, isCollapsed }: Props) => {
return ( return (
<NextLink href={ pathname } passHref> <NextLink href={ pathname } passHref>
<Tooltip
label={ text }
hasArrow={ false }
isDisabled={ !isCollapsed }
placement="right"
variant="nav"
gutter={ 0 }
color={ isActive ? colors.text.active : colors.text.hover }
>
<Link <Link
as="li" as="li"
listStyleType="none" listStyleType="none"
...@@ -40,6 +49,7 @@ const NavLink = ({ text, pathname, icon, isCollapsed }: Props) => { ...@@ -40,6 +49,7 @@ const NavLink = ({ text, pathname, icon, isCollapsed }: Props) => {
{ !isCollapsed && <Text variant="inherit">{ text }</Text> } { !isCollapsed && <Text variant="inherit">{ text }</Text> }
</HStack> </HStack>
</Link> </Link>
</Tooltip>
</NextLink> </NextLink>
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment