HM-101. Добавлен сервис для вывода уведомлений (#41)
This commit is contained in:
5
src/components/notify-container/NotifyContainer.css
Normal file
5
src/components/notify-container/NotifyContainer.css
Normal file
@ -0,0 +1,5 @@
|
||||
.NotifyContainer {
|
||||
position: absolute;
|
||||
bottom: 24px;
|
||||
right: 24px;
|
||||
}
|
||||
12
src/components/notify-container/NotifyContainer.js
Normal file
12
src/components/notify-container/NotifyContainer.js
Normal 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;
|
||||
3
src/components/notify-container/index.js
Normal file
3
src/components/notify-container/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
import NotifyContainer from './NotifyContainer';
|
||||
|
||||
export default NotifyContainer;
|
||||
3
src/components/notify-message/NotifyMessage.css
Normal file
3
src/components/notify-message/NotifyMessage.css
Normal file
@ -0,0 +1,3 @@
|
||||
.Notify__element {
|
||||
min-width: 240px;
|
||||
}
|
||||
39
src/components/notify-message/NotifyMessage.js
Normal file
39
src/components/notify-message/NotifyMessage.js
Normal 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;
|
||||
3
src/components/notify-message/index.js
Normal file
3
src/components/notify-message/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
import NotifyMessage from './NotifyMessage';
|
||||
|
||||
export default NotifyMessage;
|
||||
Reference in New Issue
Block a user