Files
lucide/site/src/components/Layout.tsx
T
2ee208652f Add site categories (#876)
* bump package

* Add Logo

* remove console

* prettify it

* add favicons and fix issue

* Add categorie page

* add drag and drop

* Make drag and drop working

* Add drag options

* Add modal

* small styling fixes

* fix search

* Add code editor

* Add more styling

* Add more categories

* create context provider

* refactor eslint thing

* update chakra-ui

* improve, category bar

* Add sortly

* Add categories

* Try to fix new categories

* Fix Categories

* Add docs Menu Tree data

* Start with sectiontitles

* Create link list

* Add Docs menu to mobile

* Add some more pages and text

* Optimize text

* add license to the menu

* update packages

* Fix build

* Update title

* Remove ModifiedTooltip

* Fix assets

* add yarn to copy-assets command

* install deps

* update

* try something

* new categories page

* try something

* Add icons reorder

* add new icons page

* add category view button

* add categories

* Fix vercel build

* Add sidebar and costumize button

* fix merge conlfict

* Remove console.logs

* add sidebar

* Add icon overview

* Fix key render issue

* Fix types

* Fix category render

* Fix build

* update lockfile

* Added category icon and icon count in list. Moved scrollbar to the left to make it less intrusive

---------

Co-authored-by: Eric Fennis <eric.fennis@endurance.com>
Co-authored-by: Eric Fennis <eric@dreamteam.nl>
Co-authored-by: Karsa <karsa@karsa.org>
2023-04-09 16:49:11 +02:00

142 lines
3.9 KiB
TypeScript

import {
Box,
Divider,
Flex,
Link,
useColorMode,
useColorModeValue,
IconButton,
useBreakpointValue,
BoxProps,
} from '@chakra-ui/react';
import { useKeyBindings } from '../lib/key';
import { useRouter } from 'next/router';
import NextLink from 'next/link';
import { Moon, Sun, Menu, X } from 'lucide-react';
import { useMobileNavigationContext, useMobileNavigationValue } from './MobileNavigationProvider';
import Logo from './Logo';
import menuItems from '../static/menuItems';
interface LayoutProps extends BoxProps {
aside?: BoxProps['children'];
}
const Layout = ({ aside, children }: LayoutProps) => {
const router = useRouter();
const { toggleMobileMenu } = useMobileNavigationContext();
const { toggleColorMode } = useColorMode();
const currentColorMode = useColorModeValue('dark', 'light');
const ColorModeToggle = useColorModeValue(Moon, Sun);
const MobileMenuToggle = useMobileNavigationValue(Menu, X);
const showBaseNavigation = useBreakpointValue({ base: false, md: true });
const IconbuttonProps = {
size: 'md',
fontSize: 'lg',
variant: 'ghost',
color: 'current',
ml: '3',
};
function setQuery(query) {
router.push(
{
pathname: '/',
query: { query: query },
},
undefined,
{ shallow: true },
);
}
useKeyBindings({
Escape: {
fn: () => setQuery(''),
},
KeyT: {
fn: () => toggleColorMode(),
},
});
return (
<Box h="100vh">
<Flex w="full">
<Flex
alignItems="center"
justifyContent="space-between"
pt={4}
pb={4}
margin="0 auto"
w="full"
px={5}
>
<Flex justifyContent="center" alignItems="center">
<Logo />
</Flex>
<Flex justifyContent="center" alignItems="center">
{showBaseNavigation ? (
<>
{menuItems.map(menuItem => {
if (menuItem.isExternal) {
return (
<Link
href={menuItem.href}
isExternal
marginRight={6}
fontSize="lg"
key={menuItem.name}
>
{menuItem.name}
</Link>
);
}
return (
<NextLink href={menuItem.href} passHref key={menuItem.name}>
<Link marginRight={8} fontSize="lg">
{menuItem.name}
</Link>
</NextLink>
);
})}
</>
) : null}
<IconButton
aria-label={`Switch to ${currentColorMode} mode`}
onClick={toggleColorMode}
{...IconbuttonProps}
icon={<ColorModeToggle />}
/>
{!showBaseNavigation ? (
<IconButton
aria-label={`Open Mobile menu`}
onClick={toggleMobileMenu}
{...IconbuttonProps}
icon={<MobileMenuToggle />}
/>
) : null}
</Flex>
</Flex>
</Flex>
<Flex>
{aside ? (
<Box as="aside" marginRight={{ base: 0, lg: -240 }}>
{aside}
</Box>
) : null}
<Flex margin="0 auto" direction="column" width="100%">
{children}
<Divider mb={6} mt={12} />
<p style={{ alignSelf: 'center' }}>
<a href="https://vercel.com?utm_source=lucide&utm_campaign=oss">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src="/vercel.svg" alt="Powered by Vercel" width="200" />
</a>
</p>
<br />
</Flex>
</Flex>
</Box>
);
};
export default Layout;