Allow for drag & drop when creating partition

This commit is contained in:
augustin64 2024-10-10 10:54:46 +02:00
parent 4fd789436b
commit 009be93b7a
6 changed files with 68 additions and 1 deletions

View File

@ -1,2 +1,5 @@
[extractors]
jinja2 = jinja2.ext:babel_extract
[python: partitioncloud/**.py] [python: partitioncloud/**.py]
[jinja2: partitioncloud/templates/**.html] [jinja2: partitioncloud/templates/**.html]

View File

@ -718,3 +718,44 @@ midi-player {
border-radius: 5px; border-radius: 5px;
background-color: var(--color-crust); background-color: var(--color-crust);
} }
/** Input[file] */
.file-area {
position: relative;
}
.file-area input[type=file] {
position: absolute;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
opacity: 0;
cursor: pointer;
}
.file-area .file-dummy {
padding: 30px;
background: var(--color-mantle);
border: 2px dashed var(--color-red);
text-align: center;
transition: background 0.3s ease-in-out;
}
.file-area .file-dummy .success {
display: none;
}
.file-area:hover > .file-dummy {
background: var(--color-surface0);
}
.file-area input[type=file]:valid + .file-dummy {
border-color: var(--color-green);
}
.file-area input[type=file]:valid + .file-dummy .success {
display: inline-block;
}
.file-area input[type=file]:valid + .file-dummy .default {
display: none;
}

View File

@ -7,7 +7,7 @@
{% if partition_uuid %} {% if partition_uuid %}
<input name="partition-uuid" value="{{ partition_uuid }}" type="hidden"> <input name="partition-uuid" value="{{ partition_uuid }}" type="hidden">
{% else %} {% else %}
<input name="file" type="file" accept=".pdf" required=""><br/> {% include 'components/input_file.html' %}
{% endif %} {% endif %}
<input type="submit" value="{{ _('Add') }}" /> <input type="submit" value="{{ _('Add') }}" />
</form> </form>

View File

@ -0,0 +1,7 @@
<div class="file-area">
<input name="file" type="file" accept=".pdf" required="">
<div class="file-dummy">
<div class="success">{{ _("Your file is selected.") }}</div>
<div class="default">{{ _("Select or drag & drop your file (pdf).") }}</div>
</div>
</div>

View File

@ -532,6 +532,14 @@ msgstr "lyrics"
msgid "Add" msgid "Add"
msgstr "Add" msgstr "Add"
#: partitioncloud/templates/components/input_file.html:4
msgid "Your file is selected."
msgstr "Your file is selected."
#: partitioncloud/templates/components/input_file.html:5
msgid "Select or drag & drop your file (pdf)."
msgstr "Select or drag & drop your file (pdf)."
#: partitioncloud/templates/groupe/index.html:8 #: partitioncloud/templates/groupe/index.html:8
#, python-format #, python-format
msgid "Add an album to group %(name)s" msgid "Add an album to group %(name)s"

View File

@ -538,6 +538,14 @@ msgstr "paroles"
msgid "Add" msgid "Add"
msgstr "Ajouter" msgstr "Ajouter"
#: partitioncloud/templates/components/input_file.html:4
msgid "Your file is selected."
msgstr "Fichier sélectionné."
#: partitioncloud/templates/components/input_file.html:5
msgid "Select or drag & drop your file (pdf)."
msgstr "Sélectionner ou déposer un fichier (pdf)."
#: partitioncloud/templates/groupe/index.html:8 #: partitioncloud/templates/groupe/index.html:8
#, python-format #, python-format
msgid "Add an album to group %(name)s" msgid "Add an album to group %(name)s"