add: toggle button for path

This commit is contained in:
h z
2025-01-16 09:52:04 +00:00
parent cfcf823e4c
commit 74326f60c3
2 changed files with 30 additions and 9 deletions

View File

@@ -8,6 +8,18 @@
margin-left: 1rem; margin-left: 1rem;
} }
.path-toggle {
background-color: #e4a4d8;
width: 1.5rem;
display: inline-flex;
align-items: center;
justify-content: center;
text-align: center;
border-radius: 1rem;
font-size: 1rem;
color: #ffffff;
}
.path-node > .has-text-weight-bold { .path-node > .has-text-weight-bold {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@@ -48,6 +60,7 @@
width: 100%; width: 100%;
} }
.move-forward { .move-forward {
background-color: #c0fff0 !important; background-color: #c0fff0 !important;
border-color: #c0fbc0 !important; border-color: #c0fbc0 !important;

View File

@@ -20,6 +20,11 @@ const PathNode = ({ path, isRoot = false }) => {
const movePath = useMovePath(); const movePath = useMovePath();
const moveMarkdown = useMoveMarkdown(); const moveMarkdown = useMoveMarkdown();
const expand = () => {
if(!isExpanded)
setIsExpanded(true);
};
const toggleExpand = () => { const toggleExpand = () => {
setIsExpanded(!isExpanded); setIsExpanded(!isExpanded);
}; };
@@ -69,6 +74,9 @@ const PathNode = ({ path, isRoot = false }) => {
return ( return (
<li> <li>
<div className="path-node-header field has-addons"> <div className="path-node-header field has-addons">
<span className="control has-text-weight-bold path-toggle" onClick={isRoot ? undefined : toggleExpand}>
{isExpanded ? "-" : "+"}
</span>
{isEditing ? ( {isEditing ? (
<div className="control has-icons-left"> <div className="control has-icons-left">
<input <input
@@ -81,7 +89,7 @@ const PathNode = ({ path, isRoot = false }) => {
) : ( ) : (
<span <span
className="path-name has-text-weight-bold control" className="path-name has-text-weight-bold control"
onClick={isRoot ? undefined : toggleExpand} onClick={isRoot ? undefined : expand}
> >
{ {
indexMarkdown ? ( indexMarkdown ? (