1
0
mirror of https://github.com/kremalicious/umami.git synced 2024-12-22 09:13:37 +01:00
umami/components/layout/MenuLayout.js

40 lines
922 B
JavaScript
Raw Normal View History

2020-08-10 00:13:38 +02:00
import React from 'react';
import { useRouter } from 'next/router';
2020-08-09 08:48:43 +02:00
import classNames from 'classnames';
import NavMenu from 'components/common/NavMenu';
2020-08-09 08:48:43 +02:00
import styles from './MenuLayout.module.css';
2020-08-09 12:04:48 +02:00
export default function MenuLayout({
menu,
selectedOption,
className,
menuClassName,
contentClassName,
children,
replace = false,
2020-08-09 12:04:48 +02:00
}) {
const router = useRouter();
function handleSelect(url) {
if (replace) {
router.replace(url);
} else {
router.push(url);
}
}
2020-08-09 08:48:43 +02:00
return (
2020-08-18 01:46:13 +02:00
<div className={classNames(styles.container, className, 'row')}>
<NavMenu
2020-08-10 00:13:38 +02:00
options={menu}
selectedOption={selectedOption}
className={classNames(styles.menu, menuClassName, 'col-12 col-lg-2')}
onSelect={handleSelect}
2020-08-10 00:13:38 +02:00
/>
<div className={classNames(styles.content, contentClassName, 'col-12 col-lg-10')}>
2020-08-18 01:46:13 +02:00
{children}
</div>
2020-08-09 08:48:43 +02:00
</div>
);
}