Add alpine.js and make flashed messages dismissable
This commit is contained in:
5
app/static/js/alpine.min.js
vendored
Normal file
5
app/static/js/alpine.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -6,6 +6,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}BP Tracker{% endblock %}</title>
|
||||
<script src="/static/js/tailwindcss@3.2.4.js"></script>
|
||||
<script src="/static/js/alpine.min.js" defer></script>
|
||||
</head>
|
||||
|
||||
<body class="bg-gray-100 text-gray-800">
|
||||
@@ -29,10 +30,12 @@
|
||||
|
||||
{% with messages = get_flashed_messages(with_categories=True) %}
|
||||
{% if messages %}
|
||||
<div class="container mx-auto mt-4">
|
||||
<div class="container mx-auto mt-4 space-y-4">
|
||||
{% for category, message in messages %}
|
||||
<div class="p-4 mb-4 rounded text-white bg-{{ 'red' if category == 'danger' else 'green' }}-500">
|
||||
{{ message }}
|
||||
<div class="flex items-center justify-between p-4 rounded-lg shadow text-white bg-{{ 'red' if category == 'danger' else 'green' }}-500"
|
||||
x-data="{ visible: true }" x-show="visible" x-transition.duration.300ms>
|
||||
<span>{{ message }}</span>
|
||||
<button @click="visible = false" class="text-xl font-bold">×</button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user