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 { const {
children = [], children = [],
label, label,
onClick = () => {},
onPointerDown = () => {}, onPointerDown = () => {},
} = branch; } = branch;
const onClick = (event) => {
if (branch.onClick) {
window.document.activeElement.blur();
branch.onClick(event);
}
};
return ( return (
<li> <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)} {children.length > 0 && renderTree(children)}
</li> </li>
); );

View File

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