Skip to content

Commit 6c27a47

Browse files
authored
Merge pull request #1532 from code-corps/improve-fixed-alerts
Improve fixed alerts
2 parents fae8f7c + 5ec2e9c commit 6c27a47

File tree

33 files changed

+235
-128
lines changed

33 files changed

+235
-128
lines changed

app/components/category-item.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,6 @@ export default Component.extend({
122122
*/
123123
_flashError(message) {
124124
let options = { fixed: true, sticky: false, timeout: 5000 };
125-
get(this, 'flashMessages').clearMessages().danger(message, options);
125+
get(this, 'flashMessages').danger(message, options);
126126
}
127127
});

app/components/flash-messages.js

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Component from '@ember/component';
2+
import { inject as service } from '@ember/service';
3+
4+
export default Component.extend({
5+
classNames: ['flash-messages', 'flash-messages--fixed'],
6+
7+
flashMessages: service()
8+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Component from '@ember/component';
2+
import { inject as service } from '@ember/service';
3+
4+
export default Component.extend({
5+
classNames: ['flash-messages', 'flash-messages--full-width'],
6+
7+
flashMessages: service()
8+
});

app/components/role-item.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ export default Component.extend({
4444

4545
_flashError(message) {
4646
let options = { fixed: true, sticky: false, timeout: 5000 };
47-
get(this, 'flashMessages').clearMessages().danger(message, options);
47+
get(this, 'flashMessages').danger(message, options);
4848
}
4949
});

app/components/task-card.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default Component.extend(EmberKeyboardMixin, {
1616
classNameBindings: ['canReposition:task-card--can-reposition', 'isLoading:task-card--is-loading'],
1717
tagName: 'div',
1818

19+
flashMessages: service(),
1920
session: service(),
2021
store: service(),
2122

@@ -55,6 +56,10 @@ export default Component.extend(EmberKeyboardMixin, {
5556
set(task, 'archived', true);
5657
let next = this.$().next(); // get the next sibling
5758
yield task.save().then(() => {
59+
let options = { fixed: true, icon: 'archive', sticky: false, timeout: 5000 };
60+
let message = `Archived <strong>${get(task, 'title')}</strong>`;
61+
get(this, 'flashMessages').success(message, options);
62+
5863
// trigger a mouseenter since the mouse doesn't update without the user
5964
if (next) {
6065
next.trigger('mouseenter');

app/components/user-list-item.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ export default Component.extend({
3636
return RSVP.resolve();
3737
}
3838

39+
let username = get(projectUser, 'user.username');
40+
3941
set(projectUser, 'role', role);
4042
return projectUser.save().then(() => {
41-
this._flashSuccess(`Role changed to ${role}`);
43+
this._flashSuccess(`Role for <strong>${username}</strong> changed to ${role}`);
4244
});
4345
},
4446

@@ -55,7 +57,7 @@ export default Component.extend({
5557
},
5658

5759
_flashSuccess(message) {
58-
let options = { fixed: true, sticky: false, timeout: 5000 };
59-
get(this, 'flashMessages').clearMessages().success(message, options);
60+
let options = { icon: 'check', fixed: true, sticky: false, timeout: 5000, extendedTimeout: 600, preventDuplicates: false };
61+
get(this, 'flashMessages').success(message, options);
6062
}
6163
});

app/styles/_alerts.scss

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
.flash {
1+
.flash-messages--fixed {
2+
display: flex;
3+
flex-direction: column-reverse;
4+
padding-bottom: 1em;
5+
position: fixed;
6+
top: 0; bottom: 0; left: 0;
7+
z-index: 99999;
8+
}
9+
10+
.flash-message {
211
cursor: pointer;
312
}
413

@@ -16,46 +25,76 @@
1625
padding: 5px 10px 5px 35px;
1726
}
1827

19-
// fixed positioned flash message container, displayed at the very top of the page
20-
// as wide as the text, centered
21-
.fixed-flash {
22-
position: fixed;
23-
top: 0; left: 0; right: 0;
24-
text-align: center;
25-
28+
&.active {
2629
.fixed-flash-inner {
27-
border-radius: 4px;
28-
cursor: pointer;
29-
display: inline-block;
30-
padding: 5px 20px;
31-
margin-top: 15px;
32-
33-
@include fadeInDown(0.6s);
30+
left: -30px;
31+
// @include moveInLeft(0.6s);
32+
}
3433

35-
p {
36-
margin: 5px 0;
34+
&.exiting {
35+
.fixed-flash-inner {
36+
left: -310px;
37+
// @include moveOutLeft(0.6s);
3738
}
3839
}
3940
}
4041
}
4142

43+
.fixed-flash {
44+
z-index: 99999;
45+
46+
.fixed-flash-inner {
47+
background: white;
48+
border-top-right-radius: 4px;
49+
border-bottom-right-radius: 4px;
50+
box-shadow: 0 3px 12px rgba(0,0,0,0.15);
51+
color: black;
52+
cursor: pointer;
53+
display: inline-block;
54+
left: -310px;
55+
margin-top: 15px;
56+
padding: 5px 20px 5px 50px;
57+
position: relative;
58+
transition: all 600ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
59+
width: 310px;
60+
61+
p {
62+
margin: 5px 0;
63+
}
64+
}
65+
}
66+
4267
// ember-cli-flash package doesn't currently support custom classes.
4368
// but they will in their 2.0.0 release. https://github.com/poteto/ember-cli-flash/issues/99
4469
// Once they do so, the following classes can be renamed after BEM standards (ex: .alert--state-danger)
4570
.alert-success {
46-
.full-width-container,
47-
.fixed-flash-inner {
71+
.full-width-container {
4872
background: $blue;
4973
color: white;
5074
}
75+
76+
.fixed-flash-inner {
77+
border-top: 5px solid $blue;
78+
}
79+
80+
i {
81+
color: $blue;
82+
}
5183
}
5284

5385
.alert-danger {
54-
.full-width-container,
55-
.fixed-flash-inner {
86+
.full-width-container {
5687
background: $red;
5788
color: white;
5889
}
90+
91+
.fixed-flash-inner {
92+
border-top: 5px solid $red;
93+
}
94+
95+
i {
96+
color: $red;
97+
}
5998
}
6099

61100
.alert__close {

app/styles/base/_animations.scss

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@
1414
animation: fadeInDown $duration;
1515
}
1616

17+
@mixin moveInLeft($duration: 2s) {
18+
-webkit-animation: moveInLeft $duration; /* Safari, Chrome and Opera > 12.1 */
19+
-moz-animation: moveInLeft $duration; /* Firefox < 16 */
20+
-ms-animation: moveInLeft $duration; /* Internet Explorer */
21+
-o-animation: moveInLeft $duration; /* Opera < 12.1 */
22+
animation: moveInLeft $duration;
23+
}
24+
25+
@mixin moveOutLeft($duration: 2s) {
26+
-webkit-animation: moveOutLeft $duration; /* Safari, Chrome and Opera > 12.1 */
27+
-moz-animation: moveOutLeft $duration; /* Firefox < 16 */
28+
-ms-animation: moveOutLeft $duration; /* Internet Explorer */
29+
-o-animation: moveOutLeft $duration; /* Opera < 12.1 */
30+
animation: moveOutLeft $duration;
31+
}
32+
1733
@mixin fadeInUp($duration: 2s) {
1834
-webkit-animation: fadeInUp $duration; /* Safari, Chrome and Opera > 12.1 */
1935
-moz-animation: fadeInUp $duration; /* Firefox < 16 */
@@ -30,6 +46,14 @@
3046
animation: fadeOut $duration;
3147
}
3248

49+
@mixin fadeOutUp($duration: 2s) {
50+
-webkit-animation: fadeOutUp $duration; /* Safari, Chrome and Opera > 12.1 */
51+
-moz-animation: fadeOutUp $duration; /* Firefox < 16 */
52+
-ms-animation: fadeOutUp $duration; /* Internet Explorer */
53+
-o-animation: fadeOutUp $duration; /* Opera < 12.1 */
54+
animation: fadeOutUp $duration;
55+
}
56+
3357
@mixin shake {
3458
animation-name: shake;
3559
animation-duration: 1s;
@@ -51,6 +75,16 @@
5175
to { opacity: 1; transform: none; }
5276
}
5377

78+
@keyframes moveInLeft {
79+
from { opacity: 1; transform: translate3d(-100%, 0, 0); }
80+
to { opacity: 1; transform: none; }
81+
}
82+
83+
@keyframes moveOutLeft {
84+
from { opacity: 1; transform: none; }
85+
to { opacity: 1; transform: translate3d(-100%, 0, 0);; }
86+
}
87+
5488
@keyframes fadeInUp {
5589
from { opacity: 0; transform: translate3d(0, 50%, 0); }
5690
to { opacity: 1; transform: none; }
@@ -61,6 +95,11 @@
6195
to { opacity: 0; }
6296
}
6397

98+
@keyframes fadeOutUp {
99+
from { opacity: 1; transform: none; }
100+
to { opacity: 0; transform: translate3d(0, -100%, 0); }
101+
}
102+
64103
@keyframes shake {
65104
from, to {
66105
transform: translate3d(0, 0, 0);

app/templates/application.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ isn't this here mainly for updating a user's image? }}
1212
{{! it'd be nice for the sake of consistency to rename
1313
'navigation-menu' to 'site-header' }}
1414
{{navigation-menu}}
15-
{{flash-messages}}
15+
{{flash-messages/full-width}}
16+
{{flash-messages/fixed-position}}
1617
<div class="site-content {{if isOnboarding "site-content--start"}} {{codeTheme.className}} {{conversations.className}} {{projectTaskBoard.className}}">
1718
{{outlet}}
1819
</div>

0 commit comments

Comments
 (0)