Merge branch 'develop' into chore-breadcrumbs

This commit is contained in:
Randall Morey authored and GitHub committed 2020-06-16 10:48:22 -04:00
commit 5e5fe7fdce
9 files changed
+229 -8

No files matched your search

@@ -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
* <Rose::LinkButton @submit={{true}} @style="primary">Save</Rose::LinkButton>
* <Rose::LinkButton @disabled={{true}} @style="secondary">Disabled</Rose::LinkButton>
*/
export default Component.extend({
layout,
tagName: '',
});
@@ -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';
<Meta title="Rose|LinkButton" component="LinkButton" />
# 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
<Rose::LinkButton @style="primary" @iconRight="chevron-right">
Content
</Rose::LinkButton>
```
<Preview>
<Story name="Advanced">{{
template: hbs`
<Rose::LinkButton
@style={{style}}
@iconLeft={{iconLeft}}
@iconRight={{iconRight}}
>
{{text}}
</Rose::LinkButton>
`,
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'
),
},
}}</Story>
</Preview>
Similar to `Rose::Button`, icon only link button is supported.
```html
<Rose::LinkButton @style="primary" @iconOnly="help-circle-outline" />
```
<Preview>
<Story name="Icon Only">{{
template: hbs`
<Rose::LinkButton @style={{style}} @iconOnly={{iconOnly}} />
`,
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'
),
},
}}</Story>
</Preview>
@@ -11,3 +11,4 @@
@import 'nav';
@import 'table';
@import 'message';
@import 'link-button';
@@ -0,0 +1,4 @@
// Link button uses rose-button styling
.rose-link-button {
text-decoration: none;
}
@@ -0,0 +1,34 @@
<LinkTo
...attributes
@route={{@route}}
@model={{@model}}
class="rose-link-button {{if @style (concat "rose-button-" @style)}} {{if @iconLeft "has-icon-left"}} {{if @iconRight "has-icon-right"}} {{if @iconOnly "has-icon-only"}}"
>
<span class="rose-button-wrapper">
{{#if @iconLeft}}
<Rose::Icon
@name={{@iconLeft}}
@size="medium"
/>
{{/if}}
<span class="rose-button-body">
{{yield}}
</span>
{{#if @iconOnly}}
<Rose::Icon
@name={{@iconOnly}}
@size="medium"
/>
{{/if}}
{{#if @iconRight}}
<Rose::Icon
@name={{@iconRight}}
@size="medium"
/>
{{/if}}
</span>
</LinkTo>
@@ -0,0 +1 @@
export { default } from 'rose/components/rose/link-button';
@@ -1,8 +1,9 @@
<Rose::Layout::Centered>
<Rose::Message @title="Welcome to Namespaces" as |message|>
<message.description>
Namespaces allow you to create distinct areas with their own separate policies, mounts, tokens, and identity entities.
</message.description>
<message.link @route="index">Add a namespace</message.link>
</Rose::Message>
</Rose::Layout::Centered>
<Rose::LinkButton @style="primary">Primary</Rose::LinkButton>
<Rose::LinkButton @style="secondary">Secondary</Rose::LinkButton>
<Rose::LinkButton @style="warning">Warning</Rose::LinkButton>
<Rose::LinkButton @style="ghost">Ghost</Rose::LinkButton>
<br />
<Rose::LinkButton @style="primary" @iconLeft="help-circle-outline">Left Icon</Rose::LinkButton>
<Rose::LinkButton @style="primary" @iconRight="help-circle-outline">Right Icon</Rose::LinkButton>
<Rose::LinkButton @style="primary" @iconOnly="help-circle-outline" />
@@ -284,5 +284,14 @@
</message.description>
<message.link @route="index">Add a namespace</message.link>
</Rose::Message>
<Rose::Layout::Centered>
<Rose::Message @title="Welcome to Namespaces" as |message|>
<message.description>
Namespaces allow you to create distinct areas with their own separate policies, mounts, tokens, and identity entities.
</message.description>
<message.link @route="index">Add a namespace</message.link>
</Rose::Message>
</Rose::Layout::Centered>
</layout.body>
</Rose::Layout::Global>
@@ -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`<Rose::LinkButton />`);
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`<Rose::LinkButton id="link-button"/>`);
assert.ok(find('#link-button'));
});
test('it renders with content', async function (assert) {
await render(hbs`<Rose::LinkButton>Link button content</Rose::LinkButton>`);
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`<Rose::LinkButton @style={{this.style}}/>`);
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`<Rose::LinkButton @iconLeft="chevron-left" />`);
assert.ok(find('.rose-icon'));
assert.ok(find('.has-icon-left'));
});
test('it supports left icon with @iconRight', async function (assert) {
await render(hbs`<Rose::LinkButton @iconRight="chevron-right" />`);
assert.ok(find('.rose-icon'));
assert.ok(find('.has-icon-right'));
});
test('it supports only icon with @iconOnly', async function (assert) {
await render(hbs`<Rose::LinkButton @iconOnly="help-circle-outline" />`);
assert.ok(find('.rose-icon'));
assert.ok(find('.has-icon-only'));
});
});