fix: nicer hierarchy

This commit is contained in:
cha0s 2020-07-02 02:58:25 -05:00
parent 24ebaecc07
commit bfc4a3d780
2 changed files with 24 additions and 4 deletions

View File

@ -13,12 +13,26 @@ const renderTree = (tree) => (
const {
children = [],
label,
onClick = () => {},
onPointerDown = () => {},
} = branch;
const onClick = (event) => {
if (branch.onClick) {
window.document.activeElement.blur();
branch.onClick(event);
}
};
return (
<li>
<button onClick={onClick} onPointerDown={onPointerDown} type="button">{label}</button>
<button
onClick={onClick}
onPointerDown={onPointerDown}
type="button"
>
{label}
{children.length > 0 && (
<span className="descend" />
)}
</button>
{children.length > 0 && renderTree(children)}
</li>
);

View File

@ -38,14 +38,22 @@ li button {
position: relative;
button {
align-items: center;
background-color: transparent;
border: none;
display: flex;
justify-content: space-between;
text-align: left;
&:focus {
box-shadow: none;
}
}
> ul li .descend::after {
color: #bbbbbb;
content: '>';
}
> ul {
display: none;
}
@ -75,7 +83,5 @@ li button {
> ul > li:hover ul, > ul ul > li:hover {
display: flex;
}
}