HM-101. Добавлен сервис для вывода уведомлений (#41)

This commit is contained in:
Nikolay
2020-08-01 17:46:08 +03:00
committed by GitHub
parent 8c1daa5771
commit f7ddce5bb0
12 changed files with 185 additions and 0 deletions

View File

@ -0,0 +1,5 @@
.NotifyContainer {
position: absolute;
bottom: 24px;
right: 24px;
}

View File

@ -0,0 +1,12 @@
import Component from '../component';
import './NotifyContainer.css';
class NotifyContainer extends Component {
constructor () {
super('#notify-container', document.body);
}
}
const notifyContainer = new NotifyContainer();
export default notifyContainer;

View File

@ -0,0 +1,3 @@
import NotifyContainer from './NotifyContainer';
export default NotifyContainer;

View File

@ -0,0 +1,3 @@
.Notify__element {
min-width: 240px;
}

View File

@ -0,0 +1,39 @@
import Component from '../component';
import notifyContainer from '../notify-container';
import './NotifyMessage.css';
class NotifyMessage extends Component {
constructor ({
title,
message,
icon,
autohide,
} = {}) {
super('#notify-message', notifyContainer.mainNode);
this.title = this.mainNode.querySelector('.Notify__title');
this.message = this.mainNode.querySelector('.Notify__message');
this.iconImage = this.mainNode.querySelector('.Notify__icon');
this.closeButton = this.mainNode.querySelector('.Notify__closeButton');
this.title.textContent = title;
this.message.textContent = message;
if (icon) {
this.iconImage.src = icon;
} else {
this.iconImage.remove();
}
if (autohide) {
this.closeButton.remove();
} else {
this.addEventListener(this.closeButton, 'click', () => {
this.mainNode.remove();
});
}
}
}
export default NotifyMessage;

View File

@ -0,0 +1,3 @@
import NotifyMessage from './NotifyMessage';
export default NotifyMessage;