Redesign sign in screen

This commit is contained in:
rubenwardy 2021-02-03 00:56:43 +00:00
parent b5f47b1b73
commit 21cf5b57c1
5 changed files with 76 additions and 58 deletions

View File

@ -33,8 +33,8 @@ from . import bp
class LoginForm(FlaskForm): class LoginForm(FlaskForm):
username = StringField("Username or email", [InputRequired()]) username = StringField("Username or email", [InputRequired()])
password = PasswordField("Password", [InputRequired(), Length(6, 100)]) password = PasswordField("Password", [InputRequired(), Length(6, 100)])
remember_me = BooleanField("Remember me") remember_me = BooleanField("Remember me", default=True)
submit = SubmitField("Login") submit = SubmitField("Sign in")
def handle_login(form): def handle_login(form):
@ -86,6 +86,9 @@ def login():
if ret: if ret:
return ret return ret
if request.method == "GET":
form.remember_me.data = True
return render_template("users/login.html", form=form) return render_template("users/login.html", form=form)

View File

@ -169,3 +169,43 @@ blockquote {
margin-bottom: 0.5em; margin-bottom: 0.5em;
} }
} }
.signin {
width: 100%;
max-width: 330px;
padding: 15px;
margin: 0 auto;
.form-control {
position: relative;
box-sizing: border-box;
height: auto;
padding: 10px;
font-size: 16px;
}
.form-group {
margin-bottom: 0;
}
.form-control:focus {
z-index: 2;
}
.checkbox {
font-weight: 400;
}
input[type="text"] {
margin-bottom: -1px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
}

View File

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}title{% endblock %} - {{ config.USER_APP_NAME }}</title> <title>{% block title %}title{% endblock %} - {{ config.USER_APP_NAME }}</title>
<link rel="stylesheet" type="text/css" href="/static/bootstrap.css"> <link rel="stylesheet" type="text/css" href="/static/bootstrap.css">
<link rel="stylesheet" type="text/css" href="/static/custom.css?v=21"> <link rel="stylesheet" type="text/css" href="/static/custom.css?v=22">
<link rel="search" type="application/opensearchdescription+xml" href="/static/opensearch.xml" title="ContentDB" /> <link rel="search" type="application/opensearchdescription+xml" href="/static/opensearch.xml" title="ContentDB" />
<link rel="shortcut icon" href="/favicon-16.png" sizes="16x16"> <link rel="shortcut icon" href="/favicon-16.png" sizes="16x16">
<link rel="icon" href="/favicon-128.png" sizes="128x128"> <link rel="icon" href="/favicon-128.png" sizes="128x128">

View File

@ -6,9 +6,9 @@
{% macro render_field(field, label=None, label_visible=true, right_url=None, right_label=None, fieldclass=None, hint=None) -%} {% macro render_field(field, label=None, label_visible=true, right_url=None, right_label=None, fieldclass=None, hint=None) -%}
<div class="form-group {% if field.errors %}has-danger{% endif %} {{ kwargs.pop('class_', '') }}"> <div class="form-group {% if field.errors %}has-danger{% endif %} {{ kwargs.pop('class_', '') }}">
{% if field.type != 'HiddenField' and label_visible %} {% if field.type != 'HiddenField' %}
{% if not label and label != "" %}{% set label=field.label.text %}{% endif %} {% if not label and label != "" %}{% set label=field.label.text %}{% endif %}
{% if label %}<label for="{{ field.id }}">{{ label|safe }}</label>{% endif %} {% if label %}<label for="{{ field.id }}" {% if not label_visible %}class="sr-only"{% endif %}>{{ label|safe }}</label>{% endif %}
{% endif %} {% endif %}
{{ field(class_=fieldclass or 'form-control', **kwargs) }} {{ field(class_=fieldclass or 'form-control', **kwargs) }}
{% if hint %} {% if hint %}

View File

@ -1,64 +1,39 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %} {% block title %}
Sign in Sign in
{% endblock %} {% endblock %}
{% block content %} {% block container %}
<div class="row"> <main class="text-center pt-5">
<div class="col-sm-8"> {% from "macros/forms.html" import render_field, render_checkbox_field, render_submit_field %}
<div class="card"> <form class="signin" method="POST">
{% from "macros/forms.html" import render_field, render_checkbox_field, render_submit_field %} {{ form.hidden_tag() }}
<h2 class="card-header">{%trans%}Sign in{%endtrans%}</h2>
<form action="" method="POST" class="form card-body" role="form"> <h1 class="h3 mb-4 font-weight-normal">Sign in</h1>
{{ form.hidden_tag() }}
{# Username or Email field #} {{ render_field(form.username, tabindex=110, label_visible=False, placeholder=_("Username or email")) }}
{{ render_field(form.username, tabindex=110) }} {{ render_field(form.password, tabindex=120, label_visible=False, placeholder=_("Password")) }}
<div class="row mb-3">
{# Password field #} {{ render_checkbox_field(form.remember_me, tabindex=130, class_="col-sm") }}
{% set field = form.password %} <a class="col-sm" href="{{ url_for('users.forgot_password') }}">
<div class="form-group {% if field.errors %}has-error{% endif %}"> {{ _("Forgot my password") }}
<label for="{{ field.id }}" class="control-label">{{ field.label.text }} </a>
<a href="{{ url_for('users.forgot_password') }}" tabindex='195'>
[{%trans%}Forgot my password{%endtrans%}]</a>
</label>
{{ field(class_='form-control', tabindex=120) }}
{% if field.errors %}
{% for e in field.errors %}
<p class="help-block">{{ e }}</p>
{% endfor %}
{% endif %}
</div>
{# Remember me #}
{{ render_checkbox_field(form.remember_me, tabindex=130) }}
{# Submit button #}
<p>
{{ render_submit_field(form.submit, tabindex=180) }}
</p>
</form>
</div>
<div class="card mt-4">
<h2 class="card-header">{%trans%}Sign in with Github{%endtrans%}</h2>
<div class="card-body">
<a class="btn btn-primary" href="{{ url_for('github.start') }}">GitHub</a>
</div> </div>
</div> {{ render_submit_field(form.submit, tabindex=140, class_="btn btn-lg btn-primary btn-block") }}
</div>
<aside class="col-sm-4"> <hr class="my-5" />
<div class="card">
<h2 class="card-header">{%trans%}New here?{%endtrans%}</h2>
<div class="card-body">
<p>Create an account using your forum account or email.</p>
<a href="{{ url_for('users.claim') }}" class="btn btn-primary">{%trans%}Claim your account{%endtrans%}</a> <p>
</div> <a class="btn btn-secondary mr-3" href="{{ url_for('github.start') }}">
</div> <i class="fab fa-github mr-1"></i>
</aside> {{ _("GitHub") }}
</div> </a>
<a class="btn btn-secondary" href="{{ url_for('users.claim') }}">
<i class="fas fa-user-plus mr-1"></i>
{{ _("Register") }}
</a>
</p>
</form>
</main>
{% endblock %} {% endblock %}