Skip to content

Commit

Permalink
md-button class bindings (#365)
Browse files Browse the repository at this point in the history
* Added fab and mini classname bindings to paper-button, defined  defaults for them and iconButton, raised properties

* style fix

* Added tests for paper-button to ensure that md-mini and md-fab classes when their respective properties are defined

* added fab and mini to docs

* Update md-button-test to check that when mini=true both md-fab and md-mini classes are present

* updated paper-button so that when mini=true it will set md-fab and md-mini

* updated dummy app to reflect mini=true changes to the paper-button
  • Loading branch information
Andy BeeSee authored and miguelcobain committed May 5, 2016
1 parent 70ed988 commit c959dcc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
8 changes: 7 additions & 1 deletion addon/components/paper-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ export default BaseFocusable.extend(RippleMixin, ProxiableMixin, ColorMixin, {
type: 'button',
tagName: 'button',
classNames: ['paper-button', 'md-default-theme', 'md-button'],
raised: false,
iconButton: false,
fab: computed.reads('mini'), // circular button
mini: false,
classNameBindings: [
'raised:md-raised',
'iconButton:md-icon-button'
'iconButton:md-icon-button',
'fab:md-fab',
'mini:md-mini'
],

// Ripple Overrides
Expand Down
4 changes: 4 additions & 0 deletions tests/dummy/app/templates/button.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
{{#paper-button raised=true primary=true onClick=(action "targetButton") bubbles=false}}Button no bubble{{/paper-button}}
</p>
<p>
{{#paper-button raised=true fab=true}}Fab{{/paper-button}}
{{#paper-button raised=true mini=true}}Mini{{/paper-button}}
{{#paper-button iconButton=true}}{{paper-icon "accessibility"}}{{/paper-button}}
</p>
{{/custom-button}}
Expand All @@ -53,6 +55,8 @@
\{{#paper-button raised=true primary=true onClick=(action "targetButton") bubbles=false}}Button no bubble\{{/paper-button}}
&lt;/p&gt;
&lt;p&gt;
\{{#paper-button raised=true fab=true}}Fab\{{/paper-button}}
\{{#paper-button raised=true mini=true}}Mini\{{/paper-button}}
\{{#paper-button iconButton=true}}\{{paper-icon "more-vert"}}\{{/paper-button}}
&lt;/p&gt;
&lt;p&gt;
Expand Down
18 changes: 18 additions & 0 deletions tests/integration/components/paper-button-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,21 @@ test('uses md-icon-button class when iconButton=true', function(assert) {
`);
assert.ok(this.$('.md-button').hasClass('md-icon-button'));
});

test('uses md-fab class when fab=true', function(assert) {
this.render(hbs`
{{#paper-button fab=true}}
A label
{{/paper-button}}
`);
assert.ok(this.$('.md-button').hasClass('md-fab'));
});

test('uses md-mini and md-fab class when mini=true', function(assert) {
this.render(hbs`
{{#paper-button mini=true}}
A label
{{/paper-button}}
`);
assert.ok(this.$('.md-button').is('.md-fab', '.md-mini'));
});

0 comments on commit c959dcc

Please sign in to comment.