chore: 🤖 move loading-button component to core addon (#1083)
This commit is contained in:
1 parent
01e4ec0a07
commit
043dbc3736
7 files changed
+13
-58
No files matched your search
+3
-3
@@ -8,11 +8,11 @@
|
||||
}}
|
||||
class={{if
|
||||
this.isLoading
|
||||
'rose-loading-button is-loading'
|
||||
'rose-loading-button'
|
||||
'loading-button is-loading'
|
||||
'loading-button'
|
||||
}}
|
||||
@disabled={{this.isLoading}}
|
||||
{{on 'click' this.toggleRefresh}}
|
||||
>
|
||||
{{yield}}
|
||||
</Rose::Button>
|
||||
</Rose::Button>
|
||||
+2
-4
@@ -1,11 +1,9 @@
|
||||
import button from '../button/index';
|
||||
|
||||
import Component from '@glimmer/component';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { action } from '@ember/object';
|
||||
import { later } from '@ember/runloop';
|
||||
|
||||
|
||||
export default class LoadingButton extends button {
|
||||
export default class LoadingButton extends Component {
|
||||
// =actions
|
||||
@tracked isLoading = false;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'core/components/loading-button';
|
||||
+5
-5
@@ -3,18 +3,18 @@ import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render, find, click } from '@ember/test-helpers';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
|
||||
module('Integration | Component | rose/loading-button', function (hooks) {
|
||||
module('Integration | Component | loading-button', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
test('it renders', async function (assert) {
|
||||
await render(hbs`<Rose::LoadingButton/>`);
|
||||
assert.ok(find('.rose-loading-button'));
|
||||
await render(hbs`<LoadingButton />`);
|
||||
assert.ok(find('.loading-button'));
|
||||
});
|
||||
|
||||
test('it executes a function on refresh button click', async function (assert) {
|
||||
assert.expect(2);
|
||||
this.onClick = () => assert.ok(true, 'refresh was clicked');
|
||||
await render(hbs`<Rose::LoadingButton @onClick={{this.onClick}}/>`);
|
||||
assert.ok(find('.rose-loading-button'));
|
||||
await render(hbs`<LoadingButton @onClick={{this.onClick}}/>`);
|
||||
assert.ok(find('.loading-button'));
|
||||
await click('button');
|
||||
});
|
||||
});
|
||||
@@ -1,43 +0,0 @@
|
||||
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|LoadingButton" component="LoadingButton" />
|
||||
|
||||
# LoadingButton
|
||||
|
||||
A simple LoadingButton component with two states - loading and reloading that renders an HTML `<button>.`
|
||||
element built by extending the existing Rose|Button component.
|
||||
|
||||
```htmlbars
|
||||
<Rose::LoadingButton>
|
||||
loading button
|
||||
</Rose::LoadingButton>
|
||||
```
|
||||
|
||||
<Preview>
|
||||
<Story name="Advanced">{{
|
||||
template: hbs`
|
||||
<Rose::Button
|
||||
@style={{style}}
|
||||
@iconLeft={{iconLeft}}
|
||||
@iconRight={{iconRight}}
|
||||
@onClick={{fn onClick}}
|
||||
>
|
||||
{{text}}
|
||||
</Rose::Button>
|
||||
`,
|
||||
context: {
|
||||
text: text('text', 'Refresh'),
|
||||
onClick: action('clicked'),
|
||||
style: 'inline-link-action',
|
||||
iconLeft: select(
|
||||
'iconLeft',
|
||||
{
|
||||
'loading': 'flight-icons/svg/loading-16',
|
||||
'reload': 'flight-icons/svg/reload-16'
|
||||
}, 'flight-icons/svg/reload-16')
|
||||
},
|
||||
}}</Story>
|
||||
</Preview>
|
||||
@@ -1 +0,0 @@
|
||||
export { default } from 'rose/components/rose/loading-button';
|
||||
@@ -112,9 +112,9 @@
|
||||
>{{t 'actions.clear-all-filters'}}
|
||||
</Rose::Button>
|
||||
{{/if}}
|
||||
<Rose::LoadingButton @onClick={{route-action 'refreshSessions'}}>
|
||||
<LoadingButton @onClick={{route-action 'refreshSessions'}}>
|
||||
{{t 'actions.refresh'}}
|
||||
</Rose::LoadingButton>
|
||||
</LoadingButton>
|
||||
</Rose::Form>
|
||||
</Rose::Toolbar>
|
||||
{{/if}}
|
||||
|
||||
Reference in new issue
Block a user