Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace style binding for z-index with CSS variable #272

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
7 changes: 0 additions & 7 deletions addon/components/notification-container.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Component from '@ember/component';
import { computed } from '@ember/object';
import { htmlSafe } from '@ember/string';
import { inject as service } from '@ember/service';

import layout from '../templates/components/notification-container';
Expand All @@ -13,13 +12,7 @@ export default Component.extend({
classNameBindings: ['computedPosition', ':ember-cli-notifications-notification__container'],
attributeBindings: ['computedStyle:style', 'position:data-test-notification-container'],

zindex: '1060',

computedPosition: computed('position', function() {
return `ember-cli-notifications-notification__container--${this.get('position')}`;
}),

computedStyle: computed('zindex', function() {
return htmlSafe(`z-index: ${this.get('zindex')};`);
})
});
2 changes: 2 additions & 0 deletions addon/styles/components/notification-container.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
--ecn-container-position: 10px;
--ecn-container-width: 80%;
--ecn-container-max-with: 400px;
--ecn-container-z-index: 1060;

--ecn-icon-width: 30px;
--ecn-icon-position: 10px;
Expand All @@ -28,6 +29,7 @@
margin: 0 auto;
width: var(--ecn-container-width);
max-width: var(--ecn-container-max-with);
z-index: var(--ecn-container-z-index),
}

/* Position */
Expand Down
91 changes: 91 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"code-highlight-linenums": "^0.2.1",
"ember-angle-bracket-invocation-polyfill": "^2.0.2",
"ember-cli": "~3.15.1",
"ember-cli-content-security-policy": "^2.0.0-1",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-eslint": "^5.1.0",
"ember-cli-github-pages": "^0.2.0",
Expand Down
1 change: 0 additions & 1 deletion tests/dummy/app/controllers/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default Controller.extend({
clearDuration: 2800,
htmlContent: false,
position: 'top',
zindex: '9999',
clearAll: true,
cssClasses: 'profile-saved-success-notification',

Expand Down
6 changes: 3 additions & 3 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{notification-container position=position zindex=zindex}}
{{notification-container position=position}}
<div class="bg-blue white py4">
<div class="max-width-4 mx-auto px2">
<div class="mb3">
Expand All @@ -25,9 +25,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>Optionally, change the position 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>
<CodeBlock @language="handlebars">&#123;&#123;notification-container position="top-right"&#125;&#125;</CodeBlock>

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