Skip to content
Snippets Groups Projects
Commit 678b3390 authored by Alf Eaton's avatar Alf Eaton
Browse files

Fix menu

parent 910ed7ab
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ import classnames from 'classnames'
import classes from './Menu.local.scss'
// TODO: match the width of the container to the width of the widest option?
// TODO: use a <select> element instead of divs?
class Menu extends React.Component {
constructor (props) {
......@@ -36,14 +37,18 @@ class Menu extends React.Component {
}
render () {
const { options, placeholder = 'Choose in the list' } = this.props
const { label, options, placeholder = 'Choose in the list' } = this.props
const { open, selected } = this.state
return (
<div className={classnames(classes.root, {
[classes.open]: open
})}>
<div>
<div className={classes.openerContainer}>
{label && (
<span className={classes.label}>{label}</span>
)}
<button
type="button"
className={classes.opener}
......@@ -57,9 +62,9 @@ class Menu extends React.Component {
</button>
</div>
<div className={classes.menuContainer}>
<div className={classes.optionsContainer}>
{open && (
<div className={classes.menu}>
<div className={classes.options}>
{options.map(option => (
<div
key={option.value}
......
.root {
display: flex;
align-items: center;
}
.root button {
font-family: var(--font-author);
}
.menuContainer {
.openerContainer {
display: flex;
align-items: center;
}
.optionsContainer {
position: relative;
}
......@@ -44,7 +54,7 @@
transform: scaleX(2.2) scaleY(-1.2);
}
.menu {
.options {
position: absolute;
top: 0;
left: 0;
......
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