Align checkbox and radio controls across the panel #271

Merged
parkel merged 1 commits from fix/compact-panel-choices into main 2026-12-03 23:54:08 +01:00
6 changed files with 92 additions and 12 deletions

No files matched your search

+22
View File
@@ -58,6 +58,28 @@ heading, help, fields, and actions should share a left edge.
and its theme tokens for type, color, spacing, and focus states. Avoid and its theme tokens for type, color, spacing, and focus states. Avoid
fixed control widths, inline styles, and page-specific font sizes. fixed control widths, inline styles, and page-specific font sizes.
### Checkboxes and radio choices
Place the native control before its label, on the same row. The visible
label should toggle the control, and a long label should wrap underneath
its own text. Keep descriptions and errors below the label text. Preserve
Django's label association, error state, and description IDs.
- For Django-generated forms, use `form.as_div`. When rendering a single
bound field, put `field.as_field_group` in its own wrapper. The shared
stylesheet aligns the control and label without replacing the widget.
- For a handwritten confirmation, wrap the input and text in one label.
Keep radio choices and multi-checkbox groups in a fieldset with a
visible legend naming the group.
- Keep a compound control, such as a numeric quota with **Unlimited**,
in its own editor row. Its checkbox still sits next to its own label.
- Use the shared stylesheet in both Core and Premium. Check click and
keyboard operation, wrapping, and focus in both themes at a narrow width.
```html
<label><input type="checkbox" name="confirm" required> Confirm this change</label>
```
## Review a UI change ## Review a UI change
Compare the result with a Core page that serves the same purpose. In light Compare the result with a Core page that serves the same purpose. In light
+63 -1
View File
@@ -959,8 +959,65 @@ dd {
width: 100%; width: 100%;
} }
.editor input:is([type="checkbox"], [type="radio"]) { input:is([type="checkbox"], [type="radio"]) {
accent-color: var(--accent); accent-color: var(--accent);
inline-size: 1rem;
block-size: 1rem;
margin: 0.15rem 0 0;
}
/* Django renders a bound checkbox as a sibling of its label. */
:is(div, p):has(> input[type="checkbox"]):has(> :is(label[for], .plan-field-heading)) {
display: grid;
grid-template-columns: max-content minmax(0, 1fr);
gap: 0.2rem 0.55rem;
align-items: start;
}
:is(div, p):has(> input[type="checkbox"]):has(> :is(label[for], .plan-field-heading)) > * {
grid-column: 2;
}
:is(div, p):has(> input[type="checkbox"]):has(> :is(label[for], .plan-field-heading)) > input[type="checkbox"] {
grid-area: 1 / 1;
}
:is(div, p):has(> input[type="checkbox"]):has(> :is(label[for], .plan-field-heading)) > :is(label[for], .plan-field-heading) {
grid-row: 1;
margin-block-end: 0;
overflow-wrap: anywhere;
}
:is(div, p):has(> input[type="checkbox"]):has(> :is(label[for], .plan-field-heading)) > .helptext {
color: var(--muted);
}
/* Handwritten confirmations and Django choice widgets wrap the input. */
label:has(> input:is([type="checkbox"], [type="radio"]):first-child) {
display: grid;
grid-template-columns: max-content minmax(0, 1fr);
column-gap: 0.55rem;
align-items: start;
margin-block-end: 0;
overflow-wrap: anywhere;
}
fieldset:has(> div > div > label > input:is([type="checkbox"], [type="radio"])) {
min-inline-size: 0;
border: 0;
margin: 0;
padding: 0;
}
fieldset:has(> div > div > label > input:is([type="checkbox"], [type="radio"])) > legend {
margin-block-end: 0.35rem;
padding: 0;
font-weight: var(--font-weight-semibold);
}
fieldset > div:has(> div > label > input:is([type="checkbox"], [type="radio"])) {
display: grid;
gap: 0.4rem;
} }
.limit-control { .limit-control {
@@ -973,6 +1030,11 @@ dd {
min-width: 0; min-width: 0;
} }
.limit-control input[type="checkbox"] {
flex: none;
margin: 0;
}
.limit-control label { .limit-control label {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@@ -26,8 +26,8 @@
<summary>Zone settings</summary> <summary>Zone settings</summary>
{{ form.nameservers.as_field_group }} {{ form.nameservers.as_field_group }}
{{ form.responsible_name.as_field_group }} {{ form.responsible_name.as_field_group }}
{{ form.delegate_dns.as_field_group }} <div>{{ form.delegate_dns.as_field_group }}</div>
{{ form.manage_mail_dns.as_field_group }} <div>{{ form.manage_mail_dns.as_field_group }}</div>
</details> </details>
{% endif %} {% endif %}
<div data-dns-text-fields> <div data-dns-text-fields>
@@ -28,11 +28,7 @@
{{ form.non_field_errors }} {{ form.non_field_errors }}
{{ form.revision }} {{ form.revision }}
{% for field in form.visible_fields %} {% for field in form.visible_fields %}
<div> <div>{{ field.as_field_group }}</div>
<label for="{{ field.id_for_label }}">{{ field }} {{ field.label }}</label>
{{ field.errors }}
<p class="heading-meta" id="{{ field.id_for_label }}_helptext">{{ field.help_text }}</p>
</div>
{% empty %} {% empty %}
<p>No installed features can be configured here yet.</p> <p>No installed features can be configured here yet.</p>
{% endfor %} {% endfor %}
@@ -12,10 +12,10 @@
{% else %} {% else %}
<p>Send the selected notifications to {{ request.user.email }}.</p> <p>Send the selected notifications to {{ request.user.email }}.</p>
{% endif %} {% endif %}
<form method="post"> <form method="post" class="editor">
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} {{ form.as_div }}
<button type="submit" class="button primary">Save preferences</button> <div class="form-actions"><button type="submit" class="button primary">Save preferences</button></div>
</form> </form>
</section> </section>
{% if deliveries %} {% if deliveries %}
@@ -49,7 +49,7 @@
{{ form.plan.as_field_group }} {{ form.plan.as_field_group }}
{{ form.password.as_field_group }} {{ form.password.as_field_group }}
</details> </details>
{{ form.confirmed.as_field_group }} <div>{{ form.confirmed.as_field_group }}</div>
<div class="form-actions"><button class="button primary" type="submit">Start installation</button></div> <div class="form-actions"><button class="button primary" type="submit">Start installation</button></div>
</form> </form>
{% endif %} {% endif %}