Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions addon/components/notification-container.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-disable ember/no-classic-components, ember/no-computed-properties-in-native-classes */
import Component from '@ember/component';
import { computed } from '@ember/object';
import { htmlSafe } from '@ember/template';
import { inject as service } from '@ember/service';

import layout from '../templates/components/notification-container';
Expand All @@ -12,15 +10,4 @@ export default class NotificationContainerComponent extends Component {
tagName = '';
layout = layout;
position = 'top';
zindex = '1060';

@computed('position')
get positionClass() {
return `ember-cli-notifications-notification__container--${this.position}`;
}

@computed('zindex')
get inlineStyle() {
return htmlSafe(`z-index: ${this.zindex};`);
}
}
26 changes: 15 additions & 11 deletions addon/styles/components/notification-container.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
:root {
--ecn-container-position: 10px;
/* Spacing */
--ecn-spacing-1: 0.5rem;
--ecn-spacing-2: 1rem;

/* Container */
--ecn-container-z-index: 9999;
--ecn-container-position: var(--ecn-spacing-1);
--ecn-container-width: 80%;
--ecn-container-max-with: 400px;

Expand All @@ -17,51 +23,49 @@
--ecn-orange: #ff7f48;
--ecn-red: #e74c3c;

/* Spacing */
--ecn-spacing-1: .5rem;
--ecn-spacing-2: 1rem;
}

/* Base */
.ember-cli-notifications-notification__container {
.ecn_container {
position: fixed;
margin: 0 auto;
width: var(--ecn-container-width);
max-width: var(--ecn-container-max-with);
z-index: var(--ecn-container-z-index, 9999);
}

/* Position */
.ember-cli-notifications-notification__container--top {
.ecn_container-top {
top: var(--ecn-container-position);
right: 0;
left: 0;
}

.ember-cli-notifications-notification__container--top-left {
.ecn_container-top-left {
top: var(--ecn-container-position);
right: auto;
left: var(--ecn-container-position);
}

.ember-cli-notifications-notification__container--top-right {
.ecn_container-top-right {
top: var(--ecn-container-position);
right: var(--ecn-container-position);
left: auto;
}

.ember-cli-notifications-notification__container--bottom {
.ecn_container-bottom {
right: 0;
bottom: var(--ecn-container-position);
left: 0;
}

.ember-cli-notifications-notification__container--bottom-left {
.ecn_container-bottom-left {
right: auto;
bottom: var(--ecn-container-position);
left: var(--ecn-container-position);
}

.ember-cli-notifications-notification__container--bottom-right {
.ecn_container-bottom-right {
right: var(--ecn-container-position);
bottom: var(--ecn-container-position);
left: auto;
Expand Down
30 changes: 15 additions & 15 deletions addon/styles/components/notification-message.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Values */
.ember-cli-notifications-notification__container .c-notification {
.c-notification {
display: flex;
align-items: stretch;
position: relative;
Expand All @@ -13,15 +13,15 @@
margin-bottom: var(--ecn-spacing-2);
}

.ember-cli-notifications-notification__container .c-notification--clickable {
.c-notification--clickable {
cursor: pointer;
}

.ember-cli-notifications-notification__container .c-notification--in {
.c-notification--in {
animation: notification-show 180ms cubic-bezier(.175, .885, .32, 1.27499);
}

.ember-cli-notifications-notification__container .c-notification__content {
.c-notification__content {
display: flex;
flex: 1 1 auto;
min-width: 0;
Expand All @@ -31,12 +31,12 @@
word-break: break-word;
}

.ember-cli-notifications-notification__container .c-notification__content a {
.c-notification__content a {
color: #fff;
text-decoration: underline;
}

.ember-cli-notifications-notification__container .c-notification__icon {
.c-notification__icon {
padding: var(--ecn-spacing-1) 0;
text-align: center;
flex: none;
Expand All @@ -45,25 +45,25 @@
color: var(--ecn-icon-color);
}

.ember-cli-notifications-notification__container .c-notification__svg {
.c-notification__svg {
width: 16px;
height: 16px;
vertical-align: text-top;
}

.ember-cli-notifications-notification__container .c-notification__close {
.c-notification__close {
margin-left: var(--ecn-spacing-2);
align-self: flex-start;
opacity: .74;
cursor: pointer;
}

.ember-cli-notifications-notification__container .c-notification__close:hover,
.ember-cli-notifications-notification__container .c-notification__close:focus {
.c-notification__close:hover,
.c-notification__close:focus {
opacity: 1;
}

.ember-cli-notifications-notification__container .c-notification__countdown {
.c-notification__countdown {
position: absolute;
bottom: 0;
left: 0;
Expand All @@ -74,19 +74,19 @@
}

/* Theme */
.ember-cli-notifications-notification__container .c-notification--info {
.c-notification--info {
background-color: var(--ecn-blue);
}

.ember-cli-notifications-notification__container .c-notification--success {
.c-notification--success {
background-color: var(--ecn-green);
}

.ember-cli-notifications-notification__container .c-notification--warning {
.c-notification--warning {
background-color: var(--ecn-orange);
}

.ember-cli-notifications-notification__container .c-notification--error {
.c-notification--error {
background-color: var(--ecn-red);
}

Expand Down
5 changes: 3 additions & 2 deletions addon/templates/components/notification-container.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div
class="ember-cli-notifications-notification__container {{this.positionClass}}"
style={{this.inlineStyle}}
class="ecn_container ecn_container-{{this.position}}"
role="status"
aria-live="polite"
data-test-notification-container={{this.position}}
>
{{#each this.notifications.content as |notification|}}
Expand Down
8 changes: 4 additions & 4 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{! template-lint-disable link-rel-noopener no-action no-unbalanced-curlies require-button-type require-input-label }}
<NotificationContainer @position={{this.position}} @zindex={{this.zindex}} />
<NotificationContainer @position={{this.position}} />
<div class="bg-blue white py4">
<div class="max-width-4 mx-auto px2">
<div class="mb3">
Expand All @@ -26,9 +26,9 @@
<h2>Basic usage</h2>
<hr>
<p>Include the container component in your template.</p>
<p>Optionally, change the position or z-index value of the notifications container.</p>
<p class="h5"><i>Default value is top</i></p>
<CodeBlock @language="handlebars">&#123;&#123;notification-container position="top-right" zindex="9999"&#125;&#125;</CodeBlock>
<p>Optionally, change the position of the notifications container. The default value is <code>top</code>.</p>
<CodeBlock @language="handlebars">&#123;&#123;notification-container position="top-right"&#125;&#125;</CodeBlock>
<p>To change the <code>z-index</code> of the container, override the CSS custom property <code>--ecn-container-zindex</code>. The default value is <code>9999</code>.</p>

<p>Inject the notifications service where required.</p>
<CodeBlock @language="js">import Controller from '@ember/controller';
Expand Down