diff --git a/addons/rose/addon/components/rose/button.js b/addons/rose/addon/components/rose/button.js new file mode 100644 index 000000000..3b11f0a24 --- /dev/null +++ b/addons/rose/addon/components/rose/button.js @@ -0,0 +1,13 @@ +import Component from '@ember/component'; +import layout from '../../templates/components/rose/button'; + +/** + * A simple HTML ` diff --git a/addons/rose/app/components/rose/button.js b/addons/rose/app/components/rose/button.js new file mode 100644 index 000000000..b10469216 --- /dev/null +++ b/addons/rose/app/components/rose/button.js @@ -0,0 +1 @@ +export { default } from 'rose/components/rose/button'; diff --git a/addons/rose/app/templates/index.hbs b/addons/rose/app/templates/index.hbs index 122889dbb..64fb78428 100644 --- a/addons/rose/app/templates/index.hbs +++ b/addons/rose/app/templates/index.hbs @@ -1 +1,11 @@ Dummy app index template + +Primary +
+Primary +
+ +Secondary +
+Secondary +
diff --git a/addons/rose/stories/button.stories.js b/addons/rose/stories/button.stories.js deleted file mode 100644 index b49f9c049..000000000 --- a/addons/rose/stories/button.stories.js +++ /dev/null @@ -1,19 +0,0 @@ -import { hbs } from 'ember-cli-htmlbars'; -import { action } from '@storybook/addon-actions'; -import { text /*withKnobs, boolean, select */ } from '@storybook/addon-knobs'; - -export default { - title: 'Button', -}; - -export const Normal = () => ({ - template: hbs` - - `, - context: { - text: text('text', 'Button Text'), - onClick: action('clicked'), - }, -}); diff --git a/addons/rose/stories/rose/button.stories.js b/addons/rose/stories/rose/button.stories.js new file mode 100644 index 000000000..c74e67b40 --- /dev/null +++ b/addons/rose/stories/rose/button.stories.js @@ -0,0 +1,36 @@ +import { hbs } from 'ember-cli-htmlbars'; +import { action } from '@storybook/addon-actions'; +import { text, boolean, select } from '@storybook/addon-knobs'; + +export default { + title: 'Rose::Button', +}; + +export const Normal = () => ({ + template: hbs` + + {{text}} + + `, + context: { + text: text('text', 'Button 🌈'), + submit: boolean('submit', false), + disabled: boolean('disabled', false), + style: select( + 'style', + { + primary: 'primary', + secondary: 'secondary', + warning: 'warning', + ghost: 'ghost', + }, + 'primary' + ), + onClick: action('clicked'), + }, +}); diff --git a/addons/rose/tests/integration/components/rose/button-test.js b/addons/rose/tests/integration/components/rose/button-test.js new file mode 100644 index 000000000..89ba514fb --- /dev/null +++ b/addons/rose/tests/integration/components/rose/button-test.js @@ -0,0 +1,35 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render, find } from '@ember/test-helpers'; +import hbs from 'htmlbars-inline-precompile'; + +module('Integration | Component | rose/button', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + await render(hbs`Button 🌈`); + assert.equal(this.element.textContent.trim(), 'Button 🌈'); + }); + + test('it is type="button" by default', async function (assert) { + await render(hbs`Button`); + assert.equal(await find('button').type, 'button'); + }); + + test('it is type="submit" when @submit={{true}}', async function (assert) { + await render(hbs``); + assert.equal(await find('button').type, 'submit'); + }); + + test('it is disabled when @disabled={{true}}', async function (assert) { + await render(hbs``); + assert.equal(await find('button').disabled, true); + }); + + test('it adds a style class', async function (assert) { + await render(hbs``); + assert.ok(await find('button.rose-button-primary')); + await render(hbs``); + assert.ok(await find('button.rose-button-secondary')); + }); +});