I'm looking for some refactoring assistance to group common button properties under one rule to reduce the amount of code for my CSS rules.
The logic basically says if "show-footer" is true then I display two buttons side-by-side. Otherwise, I display one button with 100% width. I want to try and group whatever base button properties under that first rule, but not sure how to clean this up.
Is there any way to abstract that logic out from the two custom elements and put them into that first LESS rule to make it seem less brittle?
LESS
> .editor-properties > .editor-btn-group > button {
display: none;
}
}
@{customElementNamespace}search-settings.show-save {
> .editor-properties > .editor-btn-group > .editor-save {
display: block;
width: 100%;
}
}
@{customElementNamespace}search-settings.save-cancel {
> .editor-properties > .editor-btn-group > button {
width: 49%;
display: inline-block;
}
}
HTML
<div class="editor-btn-group">
<button class="editor-cancel is-negative">
<span class="fa fa-times"></span>
<span>
Cancel
</span>
</button>
<button class="editor-save is-positive">
<span class="fa fa-floppy-o">
</span>
<span>
Save
</span>
</button>
</div>
JS
showSave: function() {
this.$el.toggleClass('show-save', this.options.showSave === true);
},
showCancel: function() {
this.$el.toggleClass('save-cancel', this.options.showFooter === true);
},