Skip to content

Commit

Permalink
fix: button can now use @isfull arg on all sizes (#45)
Browse files Browse the repository at this point in the history
* fix: button can now use @isfull arg on all sizes

* fix: denali button tests

* fix: use existing class name getter setup
  • Loading branch information
kevinhinterlong authored Oct 6, 2020
1 parent 4eebe67 commit a20c37a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion addon/components/denali-button-enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
*/

export const STYLES = ['solid', 'outline', 'ghost', 'text', 'danger'];
export const SIZES = ['default', 'small', 'medium', 'large', 'full'];
export const SIZES = ['default', 'small', 'medium', 'large'];
export const TYPES = ['button', 'submit', 'reset'];
2 changes: 1 addition & 1 deletion addon/components/denali-button.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{! Copyright 2020, Verizon Media. Licensed under the terms of the MIT license. See accompanying LICENSE.md file for terms. }}
<button
class="button {{this.isActiveClass}} {{this.styleClass}} {{this.sizeClass}} {{this.isInverseClass}} {{this.hasIconClass}} {{this.hasLoaderClass}}"
class="button {{this.isActiveClass}} {{this.styleClass}} {{this.sizeClass}} {{this.isInverseClass}} {{this.hasIconClass}} {{this.hasLoaderClass}} {{this.isFullClass}}"
type={{this.type}}
...attributes
>
Expand Down
7 changes: 7 additions & 0 deletions addon/components/denali-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export default class DenaliButtonComponent extends Component {
@arg(oneOf(SIZES))
size;

@arg(boolean)
isFull = false;

@arg(boolean)
isInverse = false;

Expand All @@ -37,6 +40,10 @@ export default class DenaliButtonComponent extends Component {
return this.isActive ? 'is-active' : undefined;
}

get isFullClass() {
return this.isFull ? 'is-full' : undefined;
}

get styleClass() {
return `is-${this.style}`;
}
Expand Down
2 changes: 2 additions & 0 deletions stories/button.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const Playground = () => ({
@isActive={{isActive}}
@isInverse={{isInverse}}
@size={{size}}
@isFull={{isFull}}
@style={{style}}
@type={{type}}
disabled={{disabled}}
Expand All @@ -39,6 +40,7 @@ export const Playground = () => ({
isInverse: boolean('isInverse', false, argument),
onClick: action('onClick'),
size: select('size', SIZES, SIZES[0], argument),
isFull: boolean('isFull', false, argument),
style: select('style', STYLES, STYLES[0], argument),
type: select('type', TYPES, TYPES[0], argument),
class: text('class', '', attribute),
Expand Down
29 changes: 27 additions & 2 deletions tests/integration/components/denali-button-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,34 @@ module('Integration | Component | denali-button', function (hooks) {

this.set('size', 'large');
assert.dom('.button').hasClass('is-large', 'DenaliButton has a large size when `@size` arg is set to large');
});

test('it supports isFull', async function (assert) {
await render(hbs`
<DenaliButton @size={{this.size}} @isFull={{this.isFull}}>
Inner Content
</DenaliButton>
`);

assert.dom('.button').exists('DenaliButton can render without a size set');
assert
.dom('.button')
.doesNotHaveClass('is-full', 'DenaliButton does not have a full size when `@isFull` arg is undefined');

this.set('size', 'full');
assert.dom('.button').hasClass('is-full', 'DenaliButton has a full size when `@size` arg is set to full');
this.set('isFull', true);
assert.dom('.button').hasClass('is-full', 'DenaliButton has a full size when `@isFull` arg is set to true');

this.set('size', 'small');
assert.dom('.button').hasClass('is-small', 'DenaliButton has a small size when `@size` arg is set to small');
assert
.dom('.button')
.hasClass('is-full', 'DenaliButton has a full size when `@isFull` arg is set to true and size is set to small');

this.set('isFull', false);
assert.dom('.button').hasClass('is-small', 'DenaliButton has a small size when `@size` arg is set to small');
assert
.dom('.button')
.doesNotHaveClass('is-full', 'DenaliButton does not have a full size when `@isFull` arg is set to false');
});

test('it supports icons', async function (assert) {
Expand Down

0 comments on commit a20c37a

Please sign in to comment.