umami/components/Menu.js

25 lines
662 B
JavaScript
Raw Normal View History

2020-08-06 08:03:07 +02:00
import React from 'react';
import classNames from 'classnames';
import styles from './Menu.module.css';
export default function Menu({ options = [], className, align = 'left', onSelect = () => {} }) {
return (
<div
className={classNames(styles.menu, className, {
[styles.left]: align === 'left',
[styles.right]: align === 'right',
})}
>
{options.map(({ label, value, className: optionClassName }) => (
<div
key={value}
className={classNames(styles.option, optionClassName)}
onClick={e => onSelect(value, e)}
>
{label}
</div>
))}
</div>
);
}