Skip to content

Commit e1fc0cb

Browse files
committed
feat: Redisign message element
1 parent 20abc82 commit e1fc0cb

File tree

3 files changed

+39
-20
lines changed

3 files changed

+39
-20
lines changed

djangosnippets/settings/base.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,6 @@ def user_url(user):
195195
DISQUS_WEBSITE_SHORTNAME = "djangosnippets"
196196
DISQUS_USE_SINGLE_SIGNON = True
197197

198-
MESSAGE_TAGS = {
199-
messages.DEBUG: "secondary",
200-
messages.INFO: "info",
201-
messages.SUCCESS: "success",
202-
messages.WARNING: "warning",
203-
messages.ERROR: "alert",
204-
}
205-
206-
207198
DATABASES = {"default": dj_database_url.config(conn_max_age=600, conn_health_checks=True)}
208199
DATABASES["default"]["ATOMIC_REQUESTS"] = True
209200

djangosnippets/templates/base.html

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
{% tailwind_css %}
1616
</head>
1717
<body class="{% block bodyclass %}{% endblock %}">
18+
{% block header %}
1819
<div id="accountbar"><div class="inner">
1920
<p>
2021
{% url 'account_logout' as logout_url %}
@@ -26,7 +27,7 @@
2627
{% endif %}
2728
</p>
2829
</div></div>
29-
<header><div class="inner">
30+
<header class="mb-0"><div class="inner">
3031
<a title="Go back to the frontpage" href="{% url 'home' %}" id="logo">django<b>snippets</b></a>
3132
<nav>
3233
<ul>
@@ -38,6 +39,8 @@
3839
</ul>
3940
</nav>
4041
</div></header>
42+
{% endblock %}
43+
{% include 'includes/messages.html' %}
4144
<div id="main" class="container mb-auto mx-auto w-7/8">
4245
{% block secondary_nav %}
4346
<nav id="subnav">
@@ -48,16 +51,6 @@
4851
</ul>
4952
</nav>
5053
{% endblock %}
51-
52-
{% if messages %}
53-
{% for message in messages %}
54-
<div data-alert class="alert-box {% if message.tags %} {{ message.tags }}{% else %}message_info{% endif %}">
55-
{{ message }}
56-
<a href="#" class="close">&times;</a>
57-
</div>
58-
{% endfor %}
59-
{% endif %}
60-
6154
<div id="base-container">
6255
<h1>{% block content_header %}{% endblock %}</h1>
6356
{% block new_content_header %}{% endblock %}
@@ -75,10 +68,12 @@ <h1>{% block content_header %}{% endblock %}</h1>
7568
{% endblock %}
7669
</div>
7770
</div>
71+
{% block footer %}
7872
<footer>
7973
<p id="copyright">Written by <a href="https://github.com/django-de/djangosnippets.org/graphs/contributors">various people</a>. Hosted by <a href="https://www.heroku.com" class="heroku">Heroku</a>, powered by <a href="http://www.djangoproject.com/">Django</a></p>
8074
<p class="legal"><a href="/about/">About</a> | <a href="/about/faq/">FAQ</a> | <a href="/about/tos/">Terms of service</a> | <a href="/about/legal/">Legal notices</a></p>
8175
</footer>
76+
{% endblock %}
8277
{% block extra_body %}{% endblock %}
8378
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
8479
<script src="{% static 'js/fastclick.js' %}"></script>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{% if messages %}
2+
{% for message in messages %}
3+
<div class="mx-4 relative" x-data="{ show: true }">
4+
<div data-alert
5+
class="absolute w-full flex justify-between pl-8 pr-4 py-2 border-2 rounded-md font-text text-lg
6+
{% if 'error' in message.tags %}
7+
border-red-600 bg-red-100
8+
{% elif 'warning' in message.tags %}
9+
border-orange-600 bg-orange-100
10+
{% elif 'success' in message.tags %}
11+
border-green-600 bg-green-100
12+
{% else %}
13+
border-blue-600 bg-blue-100
14+
{% endif %}
15+
"
16+
:class="show ? '' : 'opacity-0 duration-500 -translate-y-10'"
17+
>
18+
{{ message }}
19+
<button type="button" @click="show = false" href="#" class="m-0 text-base-black border-2 p-0 px-2 rounded-full text-base relative
20+
{% if 'error' in message.tags %}
21+
bg-red-400
22+
{% elif 'warning' in message.tags %}
23+
bg-orange-400
24+
{% elif 'success' in message.tags %}
25+
bg-green-400
26+
{% else %}
27+
bg-blue-400
28+
{% endif %}
29+
"><span class="relative -top-0.5">&times;</span></button>
30+
</div>
31+
</div>
32+
{% endfor %}
33+
{% endif %}

0 commit comments

Comments
 (0)