Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #167 from ericcornelissen/update-options
Browse files Browse the repository at this point in the history
Add background, color, and class options
  • Loading branch information
UziTech authored Mar 12, 2020
2 parents aa80566 + d29b902 commit 3abc1fc
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 4 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ style: {
}
```

You can specify `color` and `background` directly as well.

```coffeescript
color: "red"
background: "green"
```

### Button hover

you can use CSS styles for button hover per button.
Expand All @@ -154,12 +161,12 @@ hover: {

### Button class

Using a comma separated list you can add your own class names to buttons.
Using an array you can add your own class names to buttons.
This is great if you want to take advantage of native styles like Font Awesome
or if you have your own styles you prefer to keep in a stylesheet.

```coffeescript
className: "fa-rotate-90, custom-class"
class: ["fa-rotate-90", "custom-class"]
```

### Multiple callback
Expand Down Expand Up @@ -305,7 +312,9 @@ This is same above.
type: "button"
icon: "sitemap"
iconset: "fa"
className: "fa-rotate-180"
class: "fa-rotate-180"
color: "red"
background: "green"
tooltip: "This is just an example it does nothing"
}
{
Expand Down Expand Up @@ -384,7 +393,9 @@ module.exports = [
type: "button"
icon: "sitemap"
iconset: "fa"
className: "fa-rotate-180"
class: "fa-rotate-180"
color: "red"
background: "green"
tooltip: "This is just an example it does nothing"
}
{
Expand Down
3 changes: 3 additions & 0 deletions lib/types/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export default function (toolBar, button) {
html: button.html,
tooltip: button.tooltip,
priority: button.priority || 45,
background: button.background,
color: button.color,
class: button.class,
callback: button.callback,
};

Expand Down
3 changes: 3 additions & 0 deletions lib/types/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export default function (toolBar, button) {
tooltip: button.tooltip,
priority: button.priority || 45,
data: button.file,
background: button.background,
color: button.color,
class: button.class,
callback: (file) => {
atom.workspace.open(file);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/types/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export default function (toolBar, button, getActiveItem) {
tooltip: button.tooltip,
priority: button.priority || 45,
data: button.callback,
background: button.background,
color: button.color,
class: button.class,
callback(data) {
return data.call(this, getActiveItem().item);
},
Expand Down
3 changes: 3 additions & 0 deletions lib/types/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export default function (toolBar, button) {
tooltip: button.tooltip,
priority: button.priority || 45,
data: button.url,
background: button.background,
color: button.color,
class: button.class,
callback(url) {
const urlReplace = new UrlReplace();
// eslint-disable-next-line no-param-reassign
Expand Down
51 changes: 51 additions & 0 deletions spec/flex-tool-bar-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,57 @@ describe('FlexToolBar', function () {
});
});

describe('styling options', function () {
beforeEach(function () {
spyOn(flexToolBar.toolBar, 'addButton');
this.obj = {
background: 'red',
color: 'purple',
class: 'my-awesome-class'
};
});
it('should allow background, color, and class options on button', function () {
flexToolBar.addButtons([{
type: 'button',
background: this.obj.background,
color: this.obj.color,
class: this.obj.class,
}]);

expect(flexToolBar.toolBar.addButton).toHaveBeenCalledWith(jasmine.objectContaining(this.obj));
});
it('should allow background, color, and class options on file', function () {
flexToolBar.addButtons([{
type: 'file',
background: this.obj.background,
color: this.obj.color,
class: this.obj.class,
}]);

expect(flexToolBar.toolBar.addButton).toHaveBeenCalledWith(jasmine.objectContaining(this.obj));
});
it('should allow background, color, and class options on function', function () {
flexToolBar.addButtons([{
type: 'function',
background: this.obj.background,
color: this.obj.color,
class: this.obj.class,
}]);

expect(flexToolBar.toolBar.addButton).toHaveBeenCalledWith(jasmine.objectContaining(this.obj));
});
it('should allow background, color, and class options on url', function () {
flexToolBar.addButtons([{
type: 'url',
background: this.obj.background,
color: this.obj.color,
class: this.obj.class,
}]);

expect(flexToolBar.toolBar.addButton).toHaveBeenCalledWith(jasmine.objectContaining(this.obj));
});
});

describe('observed events', function () {
it('should observe grammar change', async function () {
await atom.packages.activatePackage('language-javascript');
Expand Down

0 comments on commit 3abc1fc

Please sign in to comment.