From 9a46fa7ab00e1261c25a76ad653d3dc40bd083e5 Mon Sep 17 00:00:00 2001 From: sonny Date: Thu, 14 May 2020 20:20:09 +0200 Subject: [PATCH] Initial form refactor --- .../templates/collection/import.html | 33 ++------------- .../scss/components/form/_form.scss | 18 ++++---- .../scss/elements/input/_input.scss | 9 ++++ src/newsreader/templates/form.html | 41 +++++++++++++++++++ 4 files changed, 63 insertions(+), 38 deletions(-) create mode 100644 src/newsreader/templates/form.html diff --git a/src/newsreader/news/collection/templates/collection/import.html b/src/newsreader/news/collection/templates/collection/import.html index 0ca15ab..9675842 100644 --- a/src/newsreader/news/collection/templates/collection/import.html +++ b/src/newsreader/news/collection/templates/collection/import.html @@ -1,37 +1,10 @@ {% extends "base.html" %} -{% load static i18n %} +{% load static %} {% block content %}
-
- {% csrf_token %} - {{ form.non_field_errors }} - -
-

{% trans "Import an OPML file" %}

-
-
-
- - {{ form.file.errors }} - {{ form.file }} -
- -
- - {{ form.skip_existing }} -
- -
- Cancel - -
-
-
+ {% url "news:collection:rules" as cancel_url %} + {% include "form.html" with form=form title="Import an OPML file" cancel_url=cancel_url only %}
{% endblock %} diff --git a/src/newsreader/scss/components/form/_form.scss b/src/newsreader/scss/components/form/_form.scss index 5b97958..feab671 100644 --- a/src/newsreader/scss/components/form/_form.scss +++ b/src/newsreader/scss/components/form/_form.scss @@ -8,6 +8,16 @@ font-family: $form-font; background-color: $white; + &__section { + &--last { + & .form__fieldset { + display: flex; + flex-direction: row; + justify-content: space-between; + } + } + } + &__fieldset { @extend .fieldset; } @@ -19,14 +29,6 @@ padding: 15px; } - &__actions { - display: flex; - justify-content: space-between; - - width: 50%; - padding: 15px; - } - &__title { font-size: 18px; } diff --git a/src/newsreader/scss/elements/input/_input.scss b/src/newsreader/scss/elements/input/_input.scss index 1cfb4bb..897fbf9 100644 --- a/src/newsreader/scss/elements/input/_input.scss +++ b/src/newsreader/scss/elements/input/_input.scss @@ -8,6 +8,15 @@ &:focus { border: 1px $focus-blue solid; } + + &[type="file"] { + width: 40%; + } + + &[type="checkbox"] { + align-self: flex-start; + margin: 0 0 0 10px; + } } input { diff --git a/src/newsreader/templates/form.html b/src/newsreader/templates/form.html new file mode 100644 index 0000000..c888754 --- /dev/null +++ b/src/newsreader/templates/form.html @@ -0,0 +1,41 @@ +{% load i18n %} + +
+ {% csrf_token %} + + {% if form.non_field_errors %} +
+ {{ form.non_field_errors }} +
+ {% endif %} + + {% if title %} +
+

{{ title }}

+
+ {% endif %} + +
+ {% for field in form %} +
+ + + {{ field.errors }} + {{ field }} + {{ field.help_text }} +
+ {% endfor %} +
+ +
+
+ {% if cancel_url %} + {% trans "Cancel" %} + {% endif %} + + +
+
+