From 466d98a228698832e1124da51b95d5e55d7b9a0a Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Mon, 15 Jun 2020 16:54:26 -0400 Subject: [PATCH 1/5] =?UTF-8?q?chore:=20=F0=9F=A4=96=20Add=20link-button?= =?UTF-8?q?=20rose=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Link-button rose component mimics button rose component, with the exception of being an anchor element instead of a button. --- .../rose/addon/components/rose/link-button.js | 14 +++ .../components/rose/link-button.stories.mdx | 103 ++++++++++++++++++ .../addon/styles/rose/components/_index.scss | 1 + .../styles/rose/components/_link-button.scss | 40 +++++++ .../templates/components/rose/link-button.hbs | 35 ++++++ .../rose/app/components/rose/link-button.js | 1 + .../rose/tests/dummy/app/templates/index.hbs | 21 ++-- .../tests/dummy/app/templates/playground.hbs | 9 ++ .../components/rose/link-button-test.js | 58 ++++++++++ 9 files changed, 274 insertions(+), 8 deletions(-) create mode 100644 addons/rose/addon/components/rose/link-button.js create mode 100644 addons/rose/addon/components/rose/link-button.stories.mdx create mode 100644 addons/rose/addon/styles/rose/components/_link-button.scss create mode 100644 addons/rose/addon/templates/components/rose/link-button.hbs create mode 100644 addons/rose/app/components/rose/link-button.js create mode 100644 addons/rose/tests/integration/components/rose/link-button-test.js 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..b29afbcd0 --- /dev/null +++ b/addons/rose/addon/components/rose/link-button.stories.mdx @@ -0,0 +1,103 @@ +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. + +```html + + Content + +``` + + + {{ + template: hbs` + + {{text}} + + `, + context: { + text: text('text', 'Content'), + disabled: boolean('disabled', false), + 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..fe9a6aa54 --- /dev/null +++ b/addons/rose/addon/styles/rose/components/_link-button.scss @@ -0,0 +1,40 @@ +// Link button uses rose-button styling +.rose-link-button { + text-decoration: none; + + // Modify link disabled state to match button disabled state + &.disabled { + cursor: not-allowed; + opacity: var(--opacity-1); + box-shadow: none; + + &:hover { + opacity: var(--opacity-1); + box-shadow: none; + } + + &.rose-button-primary:hover { + color: var(--white); + background-color: var(--info); + border-color: var(--info-starker-2); + } + + &.rose-button-secondary:hover { + color: var(--ui-gray-starker-3); + border-color: var(--ui-gray-subtler-2); + background-color: var(--ui-gray-subtler-5); + } + + &.rose-button-warning:hover { + color: var(--failure); + border-color: var(--failure); + background-color: var(--subtle); + text-shadow: none; + } + + &.rose-button-ghost:hover { + color: var(--info); + border-color: var(--subtle); + } + } +} 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..e3bcb61e5 --- /dev/null +++ b/addons/rose/addon/templates/components/rose/link-button.hbs @@ -0,0 +1,35 @@ + + + + {{#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..6dc4bbe0a --- /dev/null +++ b/addons/rose/app/components/rose/link-button.js @@ -0,0 +1 @@ +export { default } from 'rose/components/rose/link-button'; \ No newline at end of file diff --git a/addons/rose/tests/dummy/app/templates/index.hbs b/addons/rose/tests/dummy/app/templates/index.hbs index dde1dea20..c12b92974 100644 --- a/addons/rose/tests/dummy/app/templates/index.hbs +++ b/addons/rose/tests/dummy/app/templates/index.hbs @@ -1,8 +1,13 @@ - - - - Namespaces allow you to create distinct areas with their own separate policies, mounts, tokens, and identity entities. - - Add a namespace - - +Primary +Secondary +Warning +Ghost +
+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..6ef4f71ba --- /dev/null +++ b/addons/rose/tests/integration/components/rose/link-button-test.js @@ -0,0 +1,58 @@ +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('.disabled')); + 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 disabled when @disabled={{true}}', async function(assert) { + await render(hbs``); + assert.ok(find('.disabled')); + }); + + 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')); + }); +}); From a0ad9df5edbcfd077b17c71bfa668b632906b8d3 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Mon, 15 Jun 2020 17:03:46 -0400 Subject: [PATCH 2/5] =?UTF-8?q?chore:=20=F0=9F=A4=96=20Add=20accessibility?= =?UTF-8?q?=20role=20to=20link=20button=20rose=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/rose/addon/templates/components/rose/link-button.hbs | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/rose/addon/templates/components/rose/link-button.hbs b/addons/rose/addon/templates/components/rose/link-button.hbs index e3bcb61e5..507202f64 100644 --- a/addons/rose/addon/templates/components/rose/link-button.hbs +++ b/addons/rose/addon/templates/components/rose/link-button.hbs @@ -1,5 +1,6 @@ Date: Tue, 16 Jun 2020 10:27:59 -0400 Subject: [PATCH 3/5] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Remove=20disable?= =?UTF-8?q?d=20property=20on=20rose=20link=20button?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/rose/link-button.stories.mdx | 3 +-- .../templates/components/rose/link-button.hbs | 1 - .../rose/app/components/rose/link-button.js | 2 +- .../rose/tests/dummy/app/templates/index.hbs | 6 +---- .../components/rose/link-button-test.js | 27 +++++++++---------- 5 files changed, 15 insertions(+), 24 deletions(-) diff --git a/addons/rose/addon/components/rose/link-button.stories.mdx b/addons/rose/addon/components/rose/link-button.stories.mdx index b29afbcd0..cb6b13001 100644 --- a/addons/rose/addon/components/rose/link-button.stories.mdx +++ b/addons/rose/addon/components/rose/link-button.stories.mdx @@ -9,6 +9,7 @@ import { text, boolean, select } from '@storybook/addon-knobs'; 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 @@ -20,7 +21,6 @@ Styles supported: primary, secondary, warning, and ghost. {{ template: hbs` diff --git a/addons/rose/app/components/rose/link-button.js b/addons/rose/app/components/rose/link-button.js index 6dc4bbe0a..d3537e621 100644 --- a/addons/rose/app/components/rose/link-button.js +++ b/addons/rose/app/components/rose/link-button.js @@ -1 +1 @@ -export { default } from 'rose/components/rose/link-button'; \ No newline at end of file +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 c12b92974..8df466fc3 100644 --- a/addons/rose/tests/dummy/app/templates/index.hbs +++ b/addons/rose/tests/dummy/app/templates/index.hbs @@ -3,11 +3,7 @@ Warning Ghost
-Primary -Secondary -Warning -Ghost -
+ Left Icon Right Icon diff --git a/addons/rose/tests/integration/components/rose/link-button-test.js b/addons/rose/tests/integration/components/rose/link-button-test.js index 6ef4f71ba..d7d3c8497 100644 --- a/addons/rose/tests/integration/components/rose/link-button-test.js +++ b/addons/rose/tests/integration/components/rose/link-button-test.js @@ -3,33 +3,30 @@ 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) { +module('Integration | Component | rose/link-button', function (hooks) { setupRenderingTest(hooks); - test('it renders', async function(assert) { + test('it renders', async function (assert) { await render(hbs``); assert.ok(find('a')); - assert.notOk(find('.disabled')); assert.notOk(find('.rose-button')); assert.ok(find('.rose-link-button')); }); - test('it renders with attributes', async function(assert) { + test('it renders with attributes', async function (assert) { await render(hbs``); assert.ok(find('#link-button')); }); - test('it renders with content', async function(assert) { + 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'); + assert.ok( + find('.rose-link-button').textContent.trim(), + 'Link button content' + ); }); - test('it renders disabled when @disabled={{true}}', async function(assert) { - await render(hbs``); - assert.ok(find('.disabled')); - }); - - test('it renders with rose button styles', async function(assert) { + test('it renders with rose button styles', async function (assert) { this.set('style', 'primary'); await render(hbs``); assert.ok(find(`.rose-button-primary`)); @@ -38,19 +35,19 @@ module('Integration | Component | rose/link-button', function(hooks) { assert.ok(find(`.rose-button-sample`)); }); - test('it supports left icon with @iconLeft', async function(assert) { + 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) { + 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) { + test('it supports only icon with @iconOnly', async function (assert) { await render(hbs``); assert.ok(find('.rose-icon')); assert.ok(find('.has-icon-only')); From 85b6702353811c3fe0022c9d1188ff49f1685898 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Tue, 16 Jun 2020 10:29:59 -0400 Subject: [PATCH 4/5] =?UTF-8?q?style:=20=F0=9F=92=84=20Remove=20disabled?= =?UTF-8?q?=20styles=20for=20rose=20link=20button?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../styles/rose/components/_link-button.scss | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/addons/rose/addon/styles/rose/components/_link-button.scss b/addons/rose/addon/styles/rose/components/_link-button.scss index fe9a6aa54..727549106 100644 --- a/addons/rose/addon/styles/rose/components/_link-button.scss +++ b/addons/rose/addon/styles/rose/components/_link-button.scss @@ -1,40 +1,4 @@ // Link button uses rose-button styling .rose-link-button { text-decoration: none; - - // Modify link disabled state to match button disabled state - &.disabled { - cursor: not-allowed; - opacity: var(--opacity-1); - box-shadow: none; - - &:hover { - opacity: var(--opacity-1); - box-shadow: none; - } - - &.rose-button-primary:hover { - color: var(--white); - background-color: var(--info); - border-color: var(--info-starker-2); - } - - &.rose-button-secondary:hover { - color: var(--ui-gray-starker-3); - border-color: var(--ui-gray-subtler-2); - background-color: var(--ui-gray-subtler-5); - } - - &.rose-button-warning:hover { - color: var(--failure); - border-color: var(--failure); - background-color: var(--subtle); - text-shadow: none; - } - - &.rose-button-ghost:hover { - color: var(--info); - border-color: var(--subtle); - } - } } From 9becc2848f0349154167ae00befa70863811c75e Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Tue, 16 Jun 2020 10:39:06 -0400 Subject: [PATCH 5/5] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Remove=20aria=20?= =?UTF-8?q?role=20definition=20on=20rose=20link=20button?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/rose/addon/templates/components/rose/link-button.hbs | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/rose/addon/templates/components/rose/link-button.hbs b/addons/rose/addon/templates/components/rose/link-button.hbs index 62aed5149..9db7c752c 100644 --- a/addons/rose/addon/templates/components/rose/link-button.hbs +++ b/addons/rose/addon/templates/components/rose/link-button.hbs @@ -1,6 +1,5 @@