Improve flash messages

This commit is contained in:
julien committed 2026-11-03 15:59:30 +01:00
1 parent 2d72b20cad
commit 189ad45eea
6 files changed
+68 -106

No files matched your search

+23 -19
View File
@@ -31,7 +31,6 @@ class Netig
# Déconnexion # Déconnexion
logout_notice_flash "Vous êtes maintenant déconnecté." logout_notice_flash "Vous êtes maintenant déconnecté."
logout_redirect "/"
# Création de compte # Création de compte
create_account_page_title "Créer un compte — NETig" create_account_page_title "Créer un compte — NETig"
@@ -39,34 +38,39 @@ class Netig
create_account_link_text "Créer un compte" create_account_link_text "Créer un compte"
before_create_account do before_create_account do
case param("kind") first_name = param("first_name").to_s.strip
when "individual" last_name = param("last_name").to_s.strip
throw_error_status( organization_name = param("organization_name").to_s.strip
422, "first_name", "doit être renseigné"
) if param("first_name").to_s.strip.empty?
throw_error_status( individual =
422, "last_name", "doit être renseigné" !first_name.empty? &&
) if param("last_name").to_s.strip.empty? !last_name.empty? &&
organization_name.empty?
when "organization" organization =
throw_error_status( first_name.empty? &&
422, "organization_name", "doit être renseignée" last_name.empty? &&
) if param("organization_name").to_s.strip.empty? !organization_name.empty?
else unless individual || organization
throw_error_status( throw_error_status(
422, "kind", "choisissez un type de compte" 422,
"first_name",
"Renseignez soit le prénom et le nom, soit la dénomination."
) )
end end
end end
after_create_account do after_create_account do
member = if param("kind") == "individual" first_name = param("first_name").to_s.strip
last_name = param("last_name").to_s.strip
organization_name = param("organization_name").to_s.strip
member = if organization_name.empty?
{ {
kind: "individual", kind: "individual",
first_name: param("first_name").to_s.strip, first_name: first_name,
last_name: param("last_name").to_s.strip, last_name: last_name,
organization_name: nil organization_name: nil
} }
else else
@@ -74,7 +78,7 @@ class Netig
kind: "organization", kind: "organization",
first_name: nil, first_name: nil,
last_name: nil, last_name: nil,
organization_name: param("organization_name").to_s.strip organization_name: organization_name
} }
end end
+1 -22
View File
@@ -37,7 +37,6 @@
--color-flash-notice-background: #294e43; --color-flash-notice-background: #294e43;
--color-flash-error-background: #2c4647; --color-flash-error-background: #2c4647;
--color-flash-error-border: #e6afa2; --color-flash-error-border: #e6afa2;
--flash-space: 6rem;
/* Ombres */ /* Ombres */
--color-shadow-light: rgb(202 210 197 / 20%); --color-shadow-light: rgb(202 210 197 / 20%);
@@ -558,17 +557,10 @@ summary:focus-visible {
/* Notifications /* Notifications
------------------------------------------------------------------------ */ ------------------------------------------------------------------------ */
main.main--with-flash {
position: relative;
}
.flash-container { .flash-container {
position: absolute;
z-index: 1;
inset: 0 0 auto;
display: grid; display: grid;
gap: 10px; gap: 10px;
padding: 20px; margin-block: 1.5rem;
} }
.flash { .flash {
@@ -591,15 +583,6 @@ main.main--with-flash {
color: var(--color-text); color: var(--color-text);
} }
main.main--with-flash > section:first-of-type {
padding-top: var(--flash-space);
}
main.main--with-flash > section.page-section:first-of-type {
padding-top:
calc(var(--flash-space) + clamp(24px, 5vw, 72px));
}
/* Tableaux /* Tableaux
------------------------------------------------------------------------ */ ------------------------------------------------------------------------ */
@@ -685,10 +668,6 @@ footer {
------------------------------------------------------------------------ */ ------------------------------------------------------------------------ */
@media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
:root {
--flash-space: 8rem;
}
.box { .box {
margin-top: 60px; margin-top: 60px;
padding: 20px; padding: 20px;
+16 -45
View File
@@ -1,39 +1,24 @@
<% kind = request.params["kind"] %>
<% valid_kind = %w[individual organization].include?(kind) %>
<section class="page-section"> <section class="page-section">
<div class="content page-panel"> <div class="content page-panel">
<h1>Créer un compte</h1> <h1>Créer un compte</h1>
<% if flash["error"] || flash["notice"] %>
<div class="flash-container">
<% if error = flash["error"] %>
<p class="flash flash--error" role="alert"><%= error %></p>
<% end %>
<% if notice = flash["notice"] %>
<p class="flash flash--notice" role="status"><%= notice %></p>
<% end %>
</div>
<% end %>
<p> <p>
Créez un compte pour accéder à votre espace personnel Créez un compte pour accéder à votre espace personnel
et, si vous le souhaitez, demander à rejoindre NETig. et, si vous le souhaitez, demander à rejoindre NETig.
</p> </p>
<% if error = flash["error"] %>
<p class="flash flash--error" role="alert"><%= error %></p>
<% end %>
<% unless valid_kind %>
<p>Quel type de compte souhaitez-vous créer ?</p>
<div class="hero__actions">
<a
class="button button--secondary"
href="<%= rodauth.create_account_path %>?kind=individual"
>
Personne physique
</a>
<a
class="button button--secondary"
href="<%= rodauth.create_account_path %>?kind=organization"
>
Personne morale
</a>
</div>
<% else %>
<form <form
action="<%= rodauth.create_account_path %>" action="<%= rodauth.create_account_path %>"
method="post" method="post"
@@ -42,10 +27,10 @@
> >
<%== rodauth.csrf_tag %> <%== rodauth.csrf_tag %>
<input type="hidden" name="kind" value="<%= kind %>"> <p>
Renseignez soit le prénom et le nom d'une personne physique,
<% if kind == "individual" %> soit la dénomination d'une personne morale.
<h2>Personne physique</h2> </p>
<label for="first_name">Prénom</label> <label for="first_name">Prénom</label>
<input <input
@@ -55,7 +40,6 @@
maxlength="128" maxlength="128"
autocomplete="given-name" autocomplete="given-name"
value="<%= request.params["first_name"] %>" value="<%= request.params["first_name"] %>"
required
> >
<% if error = rodauth.field_error("first_name") %> <% if error = rodauth.field_error("first_name") %>
@@ -70,16 +54,12 @@
maxlength="128" maxlength="128"
autocomplete="family-name" autocomplete="family-name"
value="<%= request.params["last_name"] %>" value="<%= request.params["last_name"] %>"
required
> >
<% if error = rodauth.field_error("last_name") %> <% if error = rodauth.field_error("last_name") %>
<p class="flash flash--error"><%= error %></p> <p class="flash flash--error"><%= error %></p>
<% end %> <% end %>
<% else %>
<h2>Personne morale</h2>
<label for="organization_name">Dénomination</label> <label for="organization_name">Dénomination</label>
<input <input
id="organization_name" id="organization_name"
@@ -88,13 +68,11 @@
maxlength="255" maxlength="255"
autocomplete="organization" autocomplete="organization"
value="<%= request.params["organization_name"] %>" value="<%= request.params["organization_name"] %>"
required
> >
<% if error = rodauth.field_error("organization_name") %> <% if error = rodauth.field_error("organization_name") %>
<p class="flash flash--error"><%= error %></p> <p class="flash flash--error"><%= error %></p>
<% end %> <% end %>
<% end %>
<label for="<%= rodauth.login_param %>"> <label for="<%= rodauth.login_param %>">
Adresse électronique Adresse électronique
@@ -125,13 +103,6 @@
> >
</form> </form>
<p>
<a href="<%= rodauth.create_account_path %>">
Changer de type de compte
</a>
</p>
<% end %>
<p> <p>
Vous avez déjà un compte ? Vous avez déjà un compte ?
<a href="<%= rodauth.login_path %>">Se connecter</a>. <a href="<%= rodauth.login_path %>">Se connecter</a>.
+4 -20
View File
@@ -36,9 +36,11 @@
<img src="/images/favicon.svg" alt="Accueil NETig"> <img src="/images/favicon.svg" alt="Accueil NETig">
</a> </a>
<% end %> <% end %>
<a href="https://webmail.netig.net" target="_blank" rel="noopener noreferrer">NETmail ↗</a> <a href="https://webmail.netig.net" target="_blank" rel="noopener noreferrer">NETmail ↗</a>
<a href="https://cloud.netig.net" target="_blank" rel="noopener noreferrer">NETcloud ↗</a> <a href="https://cloud.netig.net" target="_blank" rel="noopener noreferrer">NETcloud ↗</a>
<a href="https://git.netig.net" target="_blank" rel="noopener noreferrer">NETgit ↗</a> <a href="https://git.netig.net" target="_blank" rel="noopener noreferrer">NETgit ↗</a>
<% if rodauth.logged_in? %> <% if rodauth.logged_in? %>
<form method="post" action="<%= rodauth.logout_path %>"> <form method="post" action="<%= rodauth.logout_path %>">
<%== rodauth.csrf_tag(rodauth.logout_path) %> <%== rodauth.csrf_tag(rodauth.logout_path) %>
@@ -54,25 +56,7 @@
</nav> </nav>
</header> </header>
<% notice = flash["notice"] %> <main id="main-content">
<% error = flash["error"] %>
<main
id="main-content"
class="<%= 'main--with-flash' if notice || error %>"
>
<% if notice || error %>
<div class="flash-container">
<% if notice %>
<p class="flash flash--notice" role="status"><%= notice %></p>
<% end %>
<% if error %>
<p class="flash flash--error" role="alert"><%= error %></p>
<% end %>
</div>
<% end %>
<%== yield %> <%== yield %>
</main> </main>
@@ -83,6 +67,7 @@
<p><a href="/legal">Mentions légales</a></p> <p><a href="/legal">Mentions légales</a></p>
<p>Fait avec ❤️ et <a href="https://roda.jeremyevans.net/" target="_blank" rel="noopener noreferrer">Roda</a> !</p> <p>Fait avec ❤️ et <a href="https://roda.jeremyevans.net/" target="_blank" rel="noopener noreferrer">Roda</a> !</p>
</div> </div>
<div class="botbar"> <div class="botbar">
<p>* L'association NETig est en cours de constitution et n'est pas encore déclarée.</p> <p>* L'association NETig est en cours de constitution et n'est pas encore déclarée.</p>
</div> </div>
@@ -91,4 +76,3 @@
</body> </body>
</html> </html>
+12
View File
@@ -2,6 +2,18 @@
<div class="content page-panel auth-panel"> <div class="content page-panel auth-panel">
<h1>Connexion</h1> <h1>Connexion</h1>
<% if flash["error"] || flash["notice"] %>
<div class="flash-container">
<% if error = flash["error"] %>
<p class="flash flash--error" role="alert"><%= error %></p>
<% end %>
<% if notice = flash["notice"] %>
<p class="flash flash--notice" role="status"><%= notice %></p>
<% end %>
</div>
<% end %>
<%== rodauth.login_form_header %> <%== rodauth.login_form_header %>
<%== rodauth.render("login-form") %> <%== rodauth.render("login-form") %>
+12
View File
@@ -2,6 +2,18 @@
<div class="content page-panel auth-panel"> <div class="content page-panel auth-panel">
<h1>Renvoyer le courriel de vérification</h1> <h1>Renvoyer le courriel de vérification</h1>
<% if flash["error"] || flash["notice"] %>
<div class="flash-container">
<% if error = flash["error"] %>
<p class="flash flash--error" role="alert"><%= error %></p>
<% end %>
<% if notice = flash["notice"] %>
<p class="flash flash--notice" role="status"><%= notice %></p>
<% end %>
</div>
<% end %>
<form <form
action="<%= rodauth.verify_account_resend_path %>" action="<%= rodauth.verify_account_resend_path %>"
method="post" method="post"