Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
🎨 animated retry icon
Browse files Browse the repository at this point in the history
refs TryGhost/Ghost#7515
- add a `retry` icon that better matches button text dimensions
- add a spin animation for the retry icon
- use the new retry icon in the default `gh-task-button` template
- add a "restart animation" method to `gh-task-button` so that repeated clicks on a button appear to register the action when local validation means that there's no transition from failed->running->failed
  • Loading branch information
kevinansfield committed Apr 14, 2017
1 parent 9ab7d10 commit 5c76346
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 8 deletions.
15 changes: 15 additions & 0 deletions app/components/gh-task-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import observer from 'ember-metal/observer';
import computed, {reads} from 'ember-computed';
import {isBlank} from 'ember-utils';
import {invokeAction} from 'ember-invoke-action';
import {task, timeout} from 'ember-concurrency';

/**
* Task Button works exactly like Spin button, but with one major difference:
Expand Down Expand Up @@ -87,6 +88,8 @@ const GhTaskButton = Component.extend({
invokeAction(this, 'action');
task.perform();

this.get('_restartAnimation').perform();

// prevent the click from bubbling and triggering form actions
return false;
},
Expand All @@ -100,6 +103,18 @@ const GhTaskButton = Component.extend({
// this.$().width('');
// this.$().height('');
}
}),

// when local validation fails there's no transition from failed->running
// so we want to restart the retry spinner animation to show something
// has happened when the button is clicked
_restartAnimation: task(function* () {
if (this.$('.retry-animated').length) {
let elem = this.$('.retry-animated')[0];
elem.classList.remove('retry-animated');
yield timeout(10);
elem.classList.add('retry-animated');
}
})
});

Expand Down
10 changes: 4 additions & 6 deletions app/styles/patterns/buttons.css
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ fieldset[disabled] .gh-btn {
display: flex;
align-items: center;
justify-content: center;

}

.gh-btn-icon svg,
Expand All @@ -308,15 +307,14 @@ fieldset[disabled] .gh-btn {
margin-right: 0;
}

.gh-btn-block svg {
margin-right: 0;
}


.gh-btn-icon svg path {
stroke: #fff;
}

.gh-btn svg.no-margin {
margin: 0;
}

/*
/* Animated button icons
/* ---------------------------------------------------------- */
Expand Down
14 changes: 14 additions & 0 deletions app/styles/patterns/icons.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Animated checkmark ------------------------------------------------------- */

path.animated-check-circle {
stroke: white;
stroke-dashoffset: 300;
Expand All @@ -14,6 +16,18 @@ path.animated-check-circle {
}
}

/* Animated retry cross ----------------------------------------------------- */

svg.retry-animated {
animation: rotate-360 0.5s ease-in-out forwards;
}

@keyframes rotate-360 {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}


/* Icons
/* ---------------------------------------------------------- */
/* CUSTOM GENERATED FILE */
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/gh-task-button.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
{{#if isRunning}}{{inline-svg "spinner"}}{{/if}}
{{if (or isIdle isRunning) buttonText}}
{{#if isSuccess}}{{inline-svg "check-circle"}} {{successText}}{{/if}}
{{#if isFailure}}{{inline-svg "close"}} {{failureText}}{{/if}}
{{#if isFailure}}{{inline-svg "retry"}} {{failureText}}{{/if}}
</span>
{{/if}}
8 changes: 7 additions & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ module.exports = function (defaults) {
plugins: [
{removeDimensions: true},
{removeTitle: true},
{removeXMLNS: true}
{removeXMLNS: true},
// Transforms on groups are necessary to work around Firefox
// not supporting transform-origin on line/path elements.
{convertPathData: {
applyTransforms: false
}},
{moveGroupAttrsToElems: false}
]
}
}
Expand Down
6 changes: 6 additions & 0 deletions public/assets/icons/retry.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5c76346

Please sign in to comment.