Initial form refactor

This commit is contained in:
sonny 2020-05-14 20:20:09 +02:00
parent 13d33749da
commit 9a46fa7ab0
4 changed files with 63 additions and 38 deletions

View file

@ -1,37 +1,10 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load static i18n %} {% load static %}
{% block content %} {% block content %}
<main id="import--page" class="main"> <main id="import--page" class="main">
<form class="form import-form" method="post" enctype="multipart/form-data"> {% url "news:collection:rules" as cancel_url %}
{% csrf_token %} {% include "form.html" with form=form title="Import an OPML file" cancel_url=cancel_url only %}
{{ form.non_field_errors }}
<div class="form__header">
<h1 class="h1 form__title">{% trans "Import an OPML file" %}</h1>
</div>
<section class="section form__section import-form__section">
<fieldset class="form__fieldset import-form__fieldset">
<label class="label import-form__label" for="name">
{% trans "File" %}
</label>
{{ form.file.errors }}
{{ form.file }}
</fieldset>
<fieldset class="form__fieldset import-form__fieldset">
<label class="label import-form__label" for="name">
{% trans "Skip existing" %}
</label>
{{ form.skip_existing }}
</fieldset>
<fieldset class="form__fieldset import-form__fieldset">
<a class="link button button--cancel" href="{% url 'news:collection:rules' %}">Cancel</a>
<button class="button button--confirm">Import</button>
</fieldset>
</section>
</form>
</main> </main>
{% endblock %} {% endblock %}

View file

@ -8,6 +8,16 @@
font-family: $form-font; font-family: $form-font;
background-color: $white; background-color: $white;
&__section {
&--last {
& .form__fieldset {
display: flex;
flex-direction: row;
justify-content: space-between;
}
}
}
&__fieldset { &__fieldset {
@extend .fieldset; @extend .fieldset;
} }
@ -19,14 +29,6 @@
padding: 15px; padding: 15px;
} }
&__actions {
display: flex;
justify-content: space-between;
width: 50%;
padding: 15px;
}
&__title { &__title {
font-size: 18px; font-size: 18px;
} }

View file

@ -8,6 +8,15 @@
&:focus { &:focus {
border: 1px $focus-blue solid; border: 1px $focus-blue solid;
} }
&[type="file"] {
width: 40%;
}
&[type="checkbox"] {
align-self: flex-start;
margin: 0 0 0 10px;
}
} }
input { input {

View file

@ -0,0 +1,41 @@
{% load i18n %}
<form class="form{% if classes %} {{ classes }}{% endif %}" method="{{ method|default:"post" }}" enctype="multipart/form-data">
{% csrf_token %}
{% if form.non_field_errors %}
<section class="section form__errors">
{{ form.non_field_errors }}
</section>
{% endif %}
{% if title %}
<section class="section form__header">
<h1 class="h1 form__title">{{ title }}</h1>
</section>
{% endif %}
<section class="section form__section">
{% for field in form %}
<fieldset class="form__fieldset">
<label class="label form__label" for="{{ field.name }}">
{{ field.label }}
</label>
{{ field.errors }}
{{ field }}
{{ field.help_text }}
</fieldset>
{% endfor %}
</section>
<section class="section form__section--last">
<fieldset class="form__fieldset">
{% if cancel_url %}
<a class="link button button--cancel" href="{{ cancel_url }}">{% trans "Cancel" %}</a>
{% endif %}
<button class="button button--confirm">{% trans "Save" %}</button>
</fieldset>
</section>
</form>