improve management of available devices

- make config more explicit
- DRY rendering of radio buttons
- style disabled radio buttons
This commit is contained in:
Alexej Rotar 2023-09-12 18:01:56 +02:00 committed by Yannik Rödel
parent 16f5d3c9a3
commit 32a0bacee9
3 changed files with 25 additions and 33 deletions

View file

@ -1,7 +1,8 @@
{
"applicationsClosed": false,
"applicationsClosedFor": [
"laptop",
"bare-laptop"
"devices": [
{ "name": "Laptop", "available": false },
{ "name": "Laptop ohne Akku", "available": false },
{ "name": "Desktop-Computer", "available": true }
]
}

View file

@ -1,28 +1,28 @@
---
layout: layouts/page.njk
useForms: true
devices:
laptop: Laptop
bare-laptop: Laptop ohne Akku
desktop: Desktop-Computer
---
# Privat einen Computer beantragen
{% if config.applicationsClosed %}
> Aktuell haben wir keine Hardware verfügbar.
> Bitte schaue in ein paar Wochen wieder auf unserer Homepage vorbei.
>
> Danke für dein Verständnis!
{% endif %}
Auf dieser Seite kannst du einen Antrag einreichen, um einen Computer von uns zu
erhalten. Bitte teile uns zunächst deine Kontaktdaten mit.
<form method="post" action="/computer-beantragen/privat" enctype="multipart/form-data">
{% if config.applicationsClosed %}
<fieldset disabled="disabled" class="blanked-out-form">
{% endif %}
Auf dieser Seite kannst du einen Antrag einreichen, um einen Computer von uns zu
erhalten. Bitte teile uns zunächst deine Kontaktdaten mit.
<label class="form-input">
<span>Name:</span>
<input type="text" name="contactname" required placeholder="Vorname Nachname" />
@ -35,33 +35,15 @@ erhalten. Bitte teile uns zunächst deine Kontaktdaten mit.
Welches Gerät würdest du gerne von uns erhalten?
{% if config.applicationsClosedFor.length > 0 %}
Bitte beachte, dass wir derzeit folgende Geräte leider nicht anbieten können:
<ul>
{% for device in config.applicationsClosedFor %}
<li>{{ devices[device] }}</li>
{% endfor %}
</ul>
{% endif %}
{% for device in config.devices %}
{% if 'desktop' not in config.applicationsClosedFor %}
<input type="radio" id="hardware-desktop" class="radio-input" name="hardware" required value="Desktop-Computer" />
<input type="radio" id="hardware-{{ loop.index }}" class="radio-input" name="hardware" required value="{{ device.name }}" {% if not device.available %}disabled{% endif %}/>
<div class="form-input">
<label for="hardware-desktop">Desktop-Computer</label>
<label for="hardware-{{ loop.index }}">{{ device.name }}</label>
</div>
{% endif %}
{% if 'bare-laptop' not in config.applicationsClosedFor %}
<input type="radio" id="hardware-bare-laptop" class="radio-input" name="hardware" required value="Laptop ohne Akku" />
<div class="form-input">
<label for="hardware-bare-laptop">Laptop ohne Akku</label>
</div>
{% endif %}
{% if 'laptop' not in config.applicationsClosedFor %}
<input type="radio" id="hardware-laptop" class="radio-input" name="hardware" required value="Laptop" />
<div class="form-input">
<label for="hardware-laptop">Laptop</label>
</div>
{% endif %}
{% endfor %}
Damit du einen Computer von uns erhalten kannst, benötigen wir von dir einen
Nachweis der Bedürftigkeit. Das ist eines dieser Papiere, die von offiziellen

View file

@ -50,6 +50,7 @@
&:hover {
background-color: colors.$gray-300;
cursor: pointer;
}
&:focus-visible,
@ -127,6 +128,14 @@
&:focus-visible + .form-input > label {
@extend %focused-form-input;
}
&:disabled + .form-input > label {
background-color: colors.$gray-300;
&:hover {
cursor: default;
}
}
}
.form-checkbox {