diff --git a/addons/rose/addon/components/rose/link-button.js b/addons/rose/addon/components/rose/link-button.js index 32e084f7e..3219bcbff 100644 --- a/addons/rose/addon/components/rose/link-button.js +++ b/addons/rose/addon/components/rose/link-button.js @@ -3,6 +3,9 @@ import layout from '../../templates/components/rose/link-button'; /** * An achor element based on `rose-button` component styles + * An empty model cannot be passed in to `link-to` component when a route + * is defined. Thus, `link-button` body content is separated to avoid + * duplication when checked for model existence. * * @example * Save diff --git a/addons/rose/addon/components/rose/link-button/body.js b/addons/rose/addon/components/rose/link-button/body.js new file mode 100644 index 000000000..7934097df --- /dev/null +++ b/addons/rose/addon/components/rose/link-button/body.js @@ -0,0 +1,7 @@ +import Component from '@ember/component'; +import layout from '../../../templates/components/rose/link-button/body'; + +export default Component.extend({ + layout, + tagName: '', +}); diff --git a/addons/rose/addon/templates/components/rose/link-button.hbs b/addons/rose/addon/templates/components/rose/link-button.hbs index 9a992f149..f7d7e94c3 100644 --- a/addons/rose/addon/templates/components/rose/link-button.hbs +++ b/addons/rose/addon/templates/components/rose/link-button.hbs @@ -1,33 +1,22 @@ - - - - {{#if @iconLeft}} - - {{/if}} - - +{{#if @model}} + + {{yield}} - - - {{#if @iconOnly}} - - {{/if}} - - {{#if @iconRight}} - - {{/if}} - - + + +{{else}} + + + {{yield}} + + +{{/if}} diff --git a/addons/rose/addon/templates/components/rose/link-button/body.hbs b/addons/rose/addon/templates/components/rose/link-button/body.hbs new file mode 100644 index 000000000..20ea6c6a5 --- /dev/null +++ b/addons/rose/addon/templates/components/rose/link-button/body.hbs @@ -0,0 +1,26 @@ + + {{#if @iconLeft}} + + {{/if}} + + + {{yield}} + + + {{#if @iconOnly}} + + {{/if}} + + {{#if @iconRight}} + + {{/if}} + diff --git a/addons/rose/app/components/rose/link-button/body.js b/addons/rose/app/components/rose/link-button/body.js new file mode 100644 index 000000000..b3c9ee39f --- /dev/null +++ b/addons/rose/app/components/rose/link-button/body.js @@ -0,0 +1 @@ +export { default } from 'rose/components/rose/link-button/body'; diff --git a/addons/rose/tests/integration/components/rose/link-button/body-test.js b/addons/rose/tests/integration/components/rose/link-button/body-test.js new file mode 100644 index 000000000..2ff8aecaa --- /dev/null +++ b/addons/rose/tests/integration/components/rose/link-button/body-test.js @@ -0,0 +1,40 @@ +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/link-button/body', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + await render(hbs``); + assert.ok(find('.rose-button-wrapper')); + }); + + test('it renders with content', async function (assert) { + await render(hbs` + Body content + `); + assert.equal( + find('.rose-button-wrapper').textContent.trim(), + 'Body content' + ); + }); + + test('it supports @iconLeft', async function (assert) { + await render(hbs``); + assert.ok(find('.rose-icon')); + }); + + test('it supports @iconRight', async function (assert) { + await render(hbs``); + assert.ok(find('.rose-icon')); + }); + + test('it supports @iconOnly', async function (assert) { + await render( + hbs`` + ); + assert.ok(find('.rose-icon')); + }); +});