diff --git a/addons/rose/addon/components/rose/link-button.js b/addons/rose/addon/components/rose/link-button.js new file mode 100644 index 000000000..32e084f7e --- /dev/null +++ b/addons/rose/addon/components/rose/link-button.js @@ -0,0 +1,14 @@ +import Component from '@ember/component'; +import layout from '../../templates/components/rose/link-button'; + +/** + * An achor element based on `rose-button` component styles + * + * @example + * Save + * Disabled + */ +export default Component.extend({ + layout, + tagName: '', +}); diff --git a/addons/rose/addon/components/rose/link-button.stories.mdx b/addons/rose/addon/components/rose/link-button.stories.mdx new file mode 100644 index 000000000..cb6b13001 --- /dev/null +++ b/addons/rose/addon/components/rose/link-button.stories.mdx @@ -0,0 +1,102 @@ +import { Meta, Story, Preview } from '@storybook/addon-docs/blocks'; +import { hbs } from 'ember-cli-htmlbars'; +import { action } from '@storybook/addon-actions'; +import { text, boolean, select } from '@storybook/addon-knobs'; + + + +# LinkButton + +An achor element component styled to mimic `Rose::Button` component. +Styles supported: primary, secondary, warning, and ghost. +Disabling link button is not supported as it is an action on form components only. + +```html + + Content + +``` + + + {{ + template: hbs` + + {{text}} + + `, + context: { + text: text('text', 'Content'), + style: select( + 'style', + { + primary: 'primary', + secondary: 'secondary', + warning: 'warning', + ghost: 'ghost', + 'inline-link-action': 'inline-link-action', + }, + 'primary' + ), + iconLeft: select( + 'iconLeft', + { + 'check-circle-outline': 'check-circle-outline', + 'copy-action': 'copy-action', + 'unfold-more': 'unfold-more', + }, + 'copy-action' + ), + iconRight: select( + 'iconRight', + { + 'check-circle-outline': 'check-circle-outline', + 'chevron-right': 'chevron-right', + 'copy-action': 'copy-action', + 'search': 'search', + }, + 'chevron-right' + ), + }, + }} + + +Similar to `Rose::Button`, icon only link button is supported. + +```html + +``` + + + {{ + template: hbs` + + `, + context: { + style: select( + 'style', + { + primary: 'primary', + secondary: 'secondary', + warning: 'warning', + ghost: 'ghost', + 'inline-link-action': 'inline-link-action', + }, + 'primary' + ), + iconOnly: select( + 'iconOnly', + { + 'check-circle-outline': 'check-circle-outline', + 'help-circle-outline': 'help-circle-outline', + 'plus-circle-fill': 'plus-circle-fill', + 'user-square-outline': 'user-square-outline', + }, + 'help-circle-outline' + ), + }, + }} + diff --git a/addons/rose/addon/styles/rose/components/_index.scss b/addons/rose/addon/styles/rose/components/_index.scss index 948a7b735..66b1f3043 100644 --- a/addons/rose/addon/styles/rose/components/_index.scss +++ b/addons/rose/addon/styles/rose/components/_index.scss @@ -11,3 +11,4 @@ @import 'nav'; @import 'table'; @import 'message'; +@import 'link-button'; diff --git a/addons/rose/addon/styles/rose/components/_link-button.scss b/addons/rose/addon/styles/rose/components/_link-button.scss new file mode 100644 index 000000000..727549106 --- /dev/null +++ b/addons/rose/addon/styles/rose/components/_link-button.scss @@ -0,0 +1,4 @@ +// Link button uses rose-button styling +.rose-link-button { + text-decoration: none; +} diff --git a/addons/rose/addon/templates/components/rose/link-button.hbs b/addons/rose/addon/templates/components/rose/link-button.hbs new file mode 100644 index 000000000..9db7c752c --- /dev/null +++ b/addons/rose/addon/templates/components/rose/link-button.hbs @@ -0,0 +1,34 @@ + + + + {{#if @iconLeft}} + + {{/if}} + + + {{yield}} + + + {{#if @iconOnly}} + + {{/if}} + + {{#if @iconRight}} + + {{/if}} + + diff --git a/addons/rose/app/components/rose/link-button.js b/addons/rose/app/components/rose/link-button.js new file mode 100644 index 000000000..d3537e621 --- /dev/null +++ b/addons/rose/app/components/rose/link-button.js @@ -0,0 +1 @@ +export { default } from 'rose/components/rose/link-button'; diff --git a/addons/rose/tests/dummy/app/templates/index.hbs b/addons/rose/tests/dummy/app/templates/index.hbs index dde1dea20..8df466fc3 100644 --- a/addons/rose/tests/dummy/app/templates/index.hbs +++ b/addons/rose/tests/dummy/app/templates/index.hbs @@ -1,8 +1,9 @@ - - - - Namespaces allow you to create distinct areas with their own separate policies, mounts, tokens, and identity entities. - - Add a namespace - - +Primary +Secondary +Warning +Ghost +
+ +Left Icon +Right Icon + diff --git a/addons/rose/tests/dummy/app/templates/playground.hbs b/addons/rose/tests/dummy/app/templates/playground.hbs index 3d4559c6b..5f02a47ef 100644 --- a/addons/rose/tests/dummy/app/templates/playground.hbs +++ b/addons/rose/tests/dummy/app/templates/playground.hbs @@ -284,5 +284,14 @@ Add a namespace + + + + + Namespaces allow you to create distinct areas with their own separate policies, mounts, tokens, and identity entities. + + Add a namespace + + diff --git a/addons/rose/tests/integration/components/rose/link-button-test.js b/addons/rose/tests/integration/components/rose/link-button-test.js new file mode 100644 index 000000000..d7d3c8497 --- /dev/null +++ b/addons/rose/tests/integration/components/rose/link-button-test.js @@ -0,0 +1,55 @@ +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', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + await render(hbs``); + assert.ok(find('a')); + assert.notOk(find('.rose-button')); + assert.ok(find('.rose-link-button')); + }); + + test('it renders with attributes', async function (assert) { + await render(hbs``); + assert.ok(find('#link-button')); + }); + + test('it renders with content', async function (assert) { + await render(hbs`Link button content`); + assert.ok( + find('.rose-link-button').textContent.trim(), + 'Link button content' + ); + }); + + test('it renders with rose button styles', async function (assert) { + this.set('style', 'primary'); + await render(hbs``); + assert.ok(find(`.rose-button-primary`)); + + this.set('style', 'sample'); + assert.ok(find(`.rose-button-sample`)); + }); + + test('it supports left icon with @iconLeft', async function (assert) { + await render(hbs``); + assert.ok(find('.rose-icon')); + assert.ok(find('.has-icon-left')); + }); + + test('it supports left icon with @iconRight', async function (assert) { + await render(hbs``); + assert.ok(find('.rose-icon')); + assert.ok(find('.has-icon-right')); + }); + + test('it supports only icon with @iconOnly', async function (assert) { + await render(hbs``); + assert.ok(find('.rose-icon')); + assert.ok(find('.has-icon-only')); + }); +});