react-feather#Menu TypeScript Examples
The following examples show how to use
react-feather#Menu.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SideBar.tsx From ke with MIT License | 6 votes |
SideBar: FC<SidebarProps> = ({ header, children, breadcrumbsRules }) => {
const { isOpen, onOpen, onClose } = useDisclosure()
goToResourceEvent.watch(onClose)
return (
<>
<Row>
<Col xs={12}>
<SidebarButtonContainer>
<Button colorScheme="brand" m={2} width={20} onClick={onOpen}>
<Menu size="1em" />
</Button>
<BreadCrumbContainer>{breadcrumbsRules && <Breadcrumbs rules={breadcrumbsRules} />}</BreadCrumbContainer>
</SidebarButtonContainer>
</Col>
</Row>
<Drawer isOpen={isOpen} placement="left" onClose={onClose}>
<DrawerOverlay />
<DrawerContent>
<DrawerCloseButton />
<DrawerHeader>{header}</DrawerHeader>
<DrawerBody>
<Flex flexDirection="column">{children}</Flex>
</DrawerBody>
</DrawerContent>
</Drawer>
</>
)
}
Example #2
Source File: SideBar.test.tsx From ke with MIT License | 6 votes |
test('Side bar component properly rendered', () => {
const component = shallow(
<SideBar header="Test">
<h1>Test</h1>
<h1>Test2</h1>
</SideBar>
)
expect(component.find(Menu).length).toEqual(1)
expect(component.find(Drawer).length).toEqual(1)
expect(component.find(DrawerContent).length).toEqual(1)
expect(component.find('h1').length).toEqual(2)
})
Example #3
Source File: navbar.tsx From another-portfolio with MIT License | 5 votes |
Navbar = (): JSX.Element => {
const { logo }: PersonalDetails = useContext(PersonalDetailsContext);
const [showMobileNav, setShowMobileNav] = useState(false);
const [isScreenScrolled, setisScreenScrolled] = useState(false);
const addShadowtoNav = () => {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
window.scrollY >= 100 ? setisScreenScrolled(true) : setisScreenScrolled(false);
};
useEffect(() => {
window.addEventListener('scroll', addShadowtoNav);
return () => {
window.removeEventListener('scroll', addShadowtoNav);
};
}, []);
return (
<div
className={` mx-auto bg-blue w-full fixed z-30
${isScreenScrolled && 'shadow-2xl'}
`}>
<nav className="block md:flex justify-between items-center p-2 px-8">
<div className="flex justify-between">
<div>
<Link href="/">
<img
src={logo}
alt="logo"
className={`${
isScreenScrolled ? 'w-1/5 md:w-3/12' : 'w-16 md:w-2/5'
} pl-30 my-2 transition-all transform hover:scale-75 cursor-pointer`}
/>
</Link>
</div>
<div className="flex md:hidden">
<button
type="button"
className="text-white focus:outline-none"
onClick={() => setShowMobileNav(!showMobileNav)}>
<Menu size={18} />
</button>
</div>
</div>
<div className={showMobileNav ? 'block pt-3 transition-all' : 'hidden md:block'}>
<ul className="md:flex md:flex-row border-pink border-2 md:border-none">
{navlinks.map((item) => {
return <NavItem title={item.title} href={item.href} key={item.href} />;
})}
</ul>
</div>
</nav>
</div>
);
}