Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snippet bar wrapping #3635

Merged
merged 10 commits into from
Oct 20, 2024
1 change: 1 addition & 0 deletions client/homebrew/editor/editor.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.editor {
position : relative;
width : 100%;
container: editor / inline-size;

.codeEditor {
height : 100%;
Expand Down
62 changes: 34 additions & 28 deletions client/homebrew/editor/snippetbar/snippetbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,23 @@ const Snippetbar = createClass({
renderSnippetGroups : function(){
const snippets = this.state.snippets.filter((snippetGroup)=>snippetGroup.view === this.props.view);

return _.map(snippets, (snippetGroup)=>{
return <SnippetGroup
brew={this.props.brew}
groupName={snippetGroup.groupName}
icon={snippetGroup.icon}
snippets={snippetGroup.snippets}
key={snippetGroup.groupName}
onSnippetClick={this.handleSnippetClick}
cursorPos={this.props.cursorPos}
/>;
});
return <div className="snippets">
{_.map(snippets, (snippetGroup)=>{
return <SnippetGroup
brew={this.props.brew}
groupName={snippetGroup.groupName}
icon={snippetGroup.icon}
snippets={snippetGroup.snippets}
key={snippetGroup.groupName}
onSnippetClick={this.handleSnippetClick}
cursorPos={this.props.cursorPos}
/>;
})
}
</div>
},


renderEditorButtons : function(){
if(!this.props.showEditButtons) return;

Expand All @@ -158,14 +162,18 @@ const Snippetbar = createClass({
}

return <div className='editors'>
<div className={`editorTool undo ${this.props.historySize.undo ? 'active' : ''}`}
onClick={this.props.undo} >
<i className='fas fa-undo' />
<div className={cx('text', { selected: this.props.view === 'text' })}
onClick={()=>this.props.onViewChange('text')}>
<i className='fa fa-beer' />
</div>
<div className={`editorTool redo ${this.props.historySize.redo ? 'active' : ''}`}
onClick={this.props.redo} >
<i className='fas fa-redo' />
<div className={cx('style', { selected: this.props.view === 'style' })}
onClick={()=>this.props.onViewChange('style')}>
<i className='fa fa-paint-brush' />
</div>
<div className={cx('meta', { selected: this.props.view === 'meta' })}
onClick={()=>this.props.onViewChange('meta')}>
<i className='fas fa-info-circle' />
</div>
<div className='divider'></div>
{foldButtons}
<div className={`editorTool editorTheme ${this.state.themeSelector ? 'active' : ''}`}
Expand All @@ -175,25 +183,23 @@ const Snippetbar = createClass({
</div>

<div className='divider'></div>
<div className={cx('text', { selected: this.props.view === 'text' })}
onClick={()=>this.props.onViewChange('text')}>
<i className='fa fa-beer' />
</div>
<div className={cx('style', { selected: this.props.view === 'style' })}
onClick={()=>this.props.onViewChange('style')}>
<i className='fa fa-paint-brush' />
<div className={`editorTool undo ${this.props.historySize.undo ? 'active' : ''}`}
onClick={this.props.undo} >
<i className='fas fa-undo' />
</div>
<div className={cx('meta', { selected: this.props.view === 'meta' })}
onClick={()=>this.props.onViewChange('meta')}>
<i className='fas fa-info-circle' />
<div className={`editorTool redo ${this.props.historySize.redo ? 'active' : ''}`}
onClick={this.props.redo} >
<i className='fas fa-redo' />
</div>

</div>;
},

render : function(){
return <div className='snippetBar'>
{this.renderSnippetGroups()}
{this.renderEditorButtons()}
{this.renderSnippetGroups()}

</div>;
}
});
Expand Down
29 changes: 24 additions & 5 deletions client/homebrew/editor/snippetbar/snippetbar.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@
@import (less) '././././themes/fonts/5e/fonts.less';

.snippetBar {
@menuHeight : 25px;
@menuHeight : 25px;
position : relative;
min-width : 331px;
height : @menuHeight;
color : black;
background-color : #DDDDDD;
display: flex;

.editors {
.snippets {
position : absolute;
top : 0px;
right : 0px;
}

.editors {
display : flex;
justify-content : space-between;
height : @menuHeight;

& > div {
width : @menuHeight;
height : @menuHeight;
Expand Down Expand Up @@ -105,7 +111,7 @@
.tooltipLeft('Edit Brew Properties');
}
.snippetGroup {
border-right : 1px solid currentColor;
border-left : 1px solid currentColor;
&:hover {
& > .dropdown { visibility : visible; }
}
Expand All @@ -127,11 +133,11 @@
cursor : pointer;
.animate(background-color);
i {
min-width : 25px;
height : 1.2em;
margin-right : 8px;
font-size : 1.2em;
min-width: 25px;
text-align: center;
text-align : center;
& ~ i {
margin-right : 0;
margin-left : 5px;
Expand Down Expand Up @@ -189,4 +195,17 @@
}
}
}
}

@container editor (width < 538px) {

.snippetBar {
display : flex;
flex-wrap : wrap;
height : 50px;

.snippets {
position : static;
}
}
}