diff --git a/app/static/css/flash.css b/app/static/css/flash.css index c865bbe..7f08e3b 100644 --- a/app/static/css/flash.css +++ b/app/static/css/flash.css @@ -3,15 +3,14 @@ */ .flash { - position: fixed; left: 15%; - display: flex; align-items: center; - width: 70%; z-index: 10; - font-family: NotoSans; font-size: 14px; color: var(--text); - background: var(--background); + margin: 5px auto; + display: flex; + align-items: center; + width: 80%; + font-size: 14px; border-bottom: 5px solid var(--info); - border-radius: 1px; box-shadow: var(--shadow); - transition: opacity .15s ease; - transition: top .2s ease; + border-radius: 1px; + box-shadow: var(--shadow); } .flash.info { border-color: var(--info); @@ -26,18 +25,9 @@ border-color: var(--error); } .flash span { - flex-grow: 1; margin: 15px 10px 10px 0; + flex-grow: 1; + margin: 15px 10px 10px 0; } .flash svg { margin: 15px 20px 10px 30px; } - -.flash input[type="button"] { - margin: 3px 30px 0 0; padding: 10px 15px; - border: none; - background: var(--btn-bg); color: var(--btn-text); -} -.flash input[type="button"]:hover, -.flash input[type="button"]:focus { - background: var(--btn-bg-active); -} diff --git a/app/static/scripts/pc-utils.js b/app/static/scripts/pc-utils.js index 56434ec..9fb92c1 100644 --- a/app/static/scripts/pc-utils.js +++ b/app/static/scripts/pc-utils.js @@ -11,42 +11,3 @@ function getCookie(name) { if( end == -1 ) end = document.cookie.length; return unescape( document.cookie.substring( debut+name.length+1, end ) ); } - -/* - Flash messages - TODO: Find a way to have good flash messages in a KISS & DRY way -*/ -function flash_add(type, message) { - template = `
- - {{ icon }} - - - {{ message }} - - -
`; - paths = { - 'error': '', - 'warning': '', - 'ok': '', - 'info': '' - }; - var top = (document.getElementsByClassName('flash').length + 1) * 70 - 45; - template = template.replace("{{ category }}", type); - template = template.replace("{{ top }}", top); - template = template.replace("{{ icon }}", paths[type]); - template = template.replace("{{ message }}", message); - document.body.innerHTML += template; -} -function flash_close(element) { - element.style.opacity = 0; - setTimeout(function(){ - var parent = element.parentNode; - parent.removeChild(element); - var childs = parent.getElementsByClassName('flash'); - for(var i = 0; i < childs.length; i++) { - childs[i].style.top = ((i + 1) * 70 - 45) + 'px'; - } - }, 0); -} diff --git a/app/templates/base/base.html b/app/templates/base/base.html index 2cfa12e..92d8b1b 100644 --- a/app/templates/base/base.html +++ b/app/templates/base/base.html @@ -10,6 +10,7 @@
{% block title %}

Planète Casio

{% endblock %}
{% include "base/header.html" %} + {% include "base/flash.html" %} {% block content %} {% endblock %} @@ -17,8 +18,6 @@ {% include "base/footer.html" %} - {% include "base/flash.html" %} - {% include "base/scripts.html" %} diff --git a/app/templates/base/flash.html b/app/templates/base/flash.html index 795fd74..13bc864 100644 --- a/app/templates/base/flash.html +++ b/app/templates/base/flash.html @@ -1,7 +1,7 @@ {% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for category, message in messages %} -
+
{% if category=="error" %}{% endif %} {% if category=="warning" %}{% endif %} @@ -11,8 +11,8 @@ {{ message }} -
{% endfor %} {% endif %} {% endwith %} +