diff --git a/undercover/routes.py b/undercover/routes.py index af6d355..9a39a4b 100644 --- a/undercover/routes.py +++ b/undercover/routes.py @@ -126,8 +126,12 @@ def logout() -> Response: @writing_blueprint.route('/add_letter') -def add_letter(user: db.User) -> Response: - # TODO: Add new letter to db +def add_letter() -> Response: + email_address = session.get('username') + if not email_address: + return render_index() + user = db.get_user(email_address) + existing_letter_count = len(db.get_user_letters(user.id)) new_letter_name = f'Letter{existing_letter_count + 2}' default_form_json = jsonify(CLForm().to_cl_data()).get_data(True) @@ -135,6 +139,7 @@ def add_letter(user: db.User) -> Response: return redirect(f'/?letter_name={new_letter_name}') + @writing_blueprint.route('/', methods=['GET']) def index_get() -> Response: email_address = session.get('username') diff --git a/undercover/static/styles.css b/undercover/static/styles.css index 0a47db5..27b033b 100644 --- a/undercover/static/styles.css +++ b/undercover/static/styles.css @@ -11,14 +11,30 @@ span.logo { padding: 0.2em; } -span.logo.left { +h1 span.logo.left { color: black; background-color: white; + transition-property: color, background-color; + transition-duration: 300ms; + transition-timing-function: ease-in; } -span.logo.right { +h1 span.logo.right { color: white; background-color: black; + transition-property: color, background-color; + transition-duration: 300ms; + transition-timing-function: ease-in; +} + +h1:hover span.logo.left { + color: white; + background-color: black; +} + +h1:hover span.logo.right { + color: black; + background-color: white; } body { @@ -45,6 +61,11 @@ h2 { margin-bottom: 1em; } +.field { + display: flex; + flex-direction: column; +} + label { font-size: 100%; font-weight: bold; @@ -54,7 +75,15 @@ label { } input, textarea { - font-family: sans-serif; + font-family: sans-serif; +} + +select { + background-color: white; + border-radius: 0; + border-style: solid; + border-width: 1px; + border-color: #ccc; } .letter-form { @@ -98,7 +127,7 @@ div.user form input { color: black; background-color: white; transition-property: color, background-color; - transition-duration: 300ms; + transition-duration: 135ms; transition-timing-function: ease-in; } @@ -114,7 +143,7 @@ div.user form input { color: white; background-color: black; transition-property: color, background-color; - transition-duration: 300ms; + transition-duration: 135ms; transition-timing-function: ease-in; } @@ -224,8 +253,14 @@ textarea { width: 100%; } dd { - margin-bottom: 2em; margin-left: 0; + flex-grow: 1; + } + dd select { + flex-grow: 1; + } + .field { + margin-bottom: 2em; } textarea { width: 80vw; diff --git a/undercover/templates/_formhelpers.jinja2 b/undercover/templates/_formhelpers.jinja2 index cf68b33..5971558 100644 --- a/undercover/templates/_formhelpers.jinja2 +++ b/undercover/templates/_formhelpers.jinja2 @@ -1,6 +1,8 @@ -{% macro render_field(field, extra="") %} +{% macro render_label(field) %}
{{ username }}