update.eternae.ink/assets/js/message_icons.js

21 lines
676 B
JavaScript
Raw Normal View History

2020-04-23 18:07:39 +02:00
import feather from "feather-icons";
document.addEventListener('DOMContentLoaded', () => {
const messageTypeToIcon = {
info: 'info',
success: 'check',
warning: 'alert-triangle',
error: 'x-circle',
question: 'help-circle',
};
document.querySelectorAll('.message').forEach(el => {
const type = el.dataset['type'];
const icon = el.querySelector('.icon');
const svgContainer = document.createElement('div');
svgContainer.innerHTML = feather.icons[messageTypeToIcon[type]].toSvg();
el.insertBefore(svgContainer.firstChild, icon);
icon.remove();
});
feather.replace();
});