diff --git a/assets/css/base_login_page.css b/assets/css/base_login_page.css new file mode 100644 index 0000000..a338351 --- /dev/null +++ b/assets/css/base_login_page.css @@ -0,0 +1,57 @@ +html, +body { + height: 100%; +} + +body { + display: flex; + align-items: center; + padding-top: 40px; + padding-bottom: 40px; + /* background-color: #f5f5f5; */ +} + +.form-signin { + width: 100%; + max-width: 330px; + padding: 15px; + margin: auto; +} + +.form-signin .checkbox { + font-weight: 400; +} + +.form-signin .form-floating:focus-within { + z-index: 2; +} + +.form-floating:first-child input { + margin-bottom: -1px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} + +.form-floating:not(:first-child):not(:last-child) input { + margin-bottom: -1px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; + border-top-left-radius: 0; + border-top-right-radius: 0; +} + +.form-floating:last-child input { + margin-bottom: 10px; + border-top-left-radius: 0; + border-top-right-radius: 0; +} + +.form-control { + background-color: var(--bs-gray-700); + color: var(--bs-gray-100); +} + +.form-control:focus { + background-color: var(--bs-gray-600); + color: var(--bs-gray-100); +} diff --git a/assets/css/login.css b/assets/css/login.css deleted file mode 100644 index b01b25e..0000000 --- a/assets/css/login.css +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Login page - * - * @author Pierre Hubert - */ diff --git a/assets/js/base_login_page.js b/assets/js/base_login_page.js new file mode 100644 index 0000000..6365291 --- /dev/null +++ b/assets/js/base_login_page.js @@ -0,0 +1,5 @@ +// Remove un-used alerts +document.querySelectorAll("[role=alert]").forEach(el => { + if(el.innerHTML.trim() === "") + el.remove(); +}) diff --git a/src/controllers/login_controller.rs b/src/controllers/login_controller.rs index 86e0acd..a96fa96 100644 --- a/src/controllers/login_controller.rs +++ b/src/controllers/login_controller.rs @@ -1,15 +1,35 @@ -use actix_web::Responder; +use actix_web::{HttpResponse, Responder}; use askama::Template; use crate::constants::APP_NAME; +#[derive(Template)] +#[template(path = "base_login_page.html")] +struct BaseLoginPage { + danger: String, + success: String, + page_title: &'static str, + app_name: &'static str, +} + #[derive(Template)] #[template(path = "login.html")] -struct LoginTemplate<'a> { - app_name: &'a str, +struct LoginTemplate { + _parent: BaseLoginPage, + mail: String, } pub async fn login_route() -> impl Responder { - LoginTemplate { app_name: APP_NAME }.render().unwrap() + HttpResponse::Ok() + .content_type("text/html") + .body(LoginTemplate { + _parent: BaseLoginPage { + page_title: "Login", + danger: "".to_string(), + success: "".to_string(), + app_name: APP_NAME, + }, + mail: "".to_string() + }.render().unwrap()) } \ No newline at end of file diff --git a/templates/base_login_page.html b/templates/base_login_page.html new file mode 100644 index 0000000..a4fcade --- /dev/null +++ b/templates/base_login_page.html @@ -0,0 +1,63 @@ + + + + + + + {{ app_name }} - {{ page_title }} + + + + + + + + + + + + + + + +
+ +

{{ page_title }}

+ + + + + + {% block content %} + TO_REPLACE + {% endblock content %} + +

© 2022 - + +

+ +
+ + + + diff --git a/templates/login.html b/templates/login.html index 88aae15..dac46a1 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1 +1,22 @@ -here comes the login page for {{ app_name }} \ No newline at end of file +{% extends "base_login_page.html" %} +{% block content %} +
+
+
+ + +
+ +
+ + +
+
+ + + +
+ +{% endblock content %}