fix: nicer hierarchy
This commit is contained in:
parent
24ebaecc07
commit
bfc4a3d780
|
@ -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>
|
||||||
);
|
);
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user