Skip to content

Commit

Permalink
Merge pull request naturalcrit#2656 from naturalcrit/SubSnippets
Browse files Browse the repository at this point in the history
Add a side menu for sub-snippets
  • Loading branch information
calculuschild committed Feb 2, 2023
2 parents 85b3741 + 5e38ff6 commit 9b06380
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
17 changes: 12 additions & 5 deletions client/homebrew/editor/snippetbar/snippetbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,22 @@ const SnippetGroup = createClass({
onSnippetClick : function(){},
};
},
handleSnippetClick : function(snippet){
handleSnippetClick : function(e, snippet){
e.stopPropagation();
this.props.onSnippetClick(execute(snippet.gen, this.props.brew));
},
renderSnippets : function(){
return _.map(this.props.snippets, (snippet)=>{
return <div className='snippet' key={snippet.name} onClick={()=>this.handleSnippetClick(snippet)}>
renderSnippets : function(snippets){
return _.map(snippets, (snippet)=>{
return <div className='snippet' key={snippet.name} onClick={(e)=>this.handleSnippetClick(e, snippet)}>
<i className={snippet.icon} />
{snippet.name}
{snippet.subsnippets && <>
<i className='fas fa-caret-right'></i>
<div className='dropdown side'>
{this.renderSnippets(snippet.subsnippets)}
</div></>}
</div>;

});
},

Expand All @@ -182,7 +189,7 @@ const SnippetGroup = createClass({
<span className='groupName'>{this.props.groupName}</span>
</div>
<div className='dropdown'>
{this.renderSnippets()}
{this.renderSnippets(this.props.snippets)}
</div>
</div>;
},
Expand Down
16 changes: 15 additions & 1 deletion client/homebrew/editor/snippetbar/snippetbar.less
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
.snippetGroup{
border-right : 1px solid black;
&:hover{
.dropdown{
&>.dropdown{
visibility : visible;
}
}
Expand All @@ -97,15 +97,29 @@
background-color : #ddd;
.snippet{
.animate(background-color);
width : max-content;
padding : 5px;
cursor : pointer;
font-size : 10px;
i{
margin-right : 8px;
font-size : 1.2em;
&~i{
margin-right: 0;
margin-left: 8px;
}
}
&:hover{
background-color : #999;
&>.dropdown{
visibility : visible;
&.side {
left: 100%;
top: 0%;
margin-left:0;
box-shadow: -1px 1px 2px 0px #999;
}
}
}
}
}
Expand Down

0 comments on commit 9b06380

Please sign in to comment.