diff --git a/docs/panel-design.md b/docs/panel-design.md index 5241b0e..87e8736 100644 --- a/docs/panel-design.md +++ b/docs/panel-design.md @@ -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 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 + +``` + ## Review a UI change Compare the result with a Core page that serves the same purpose. In light diff --git a/src/coulobre/hosting/static/hosting/panel.css b/src/coulobre/hosting/static/hosting/panel.css index 41c6062..dde9819 100644 --- a/src/coulobre/hosting/static/hosting/panel.css +++ b/src/coulobre/hosting/static/hosting/panel.css @@ -959,8 +959,65 @@ dd { width: 100%; } -.editor input:is([type="checkbox"], [type="radio"]) { +input:is([type="checkbox"], [type="radio"]) { 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 { @@ -973,6 +1030,11 @@ dd { min-width: 0; } +.limit-control input[type="checkbox"] { + flex: none; + margin: 0; +} + .limit-control label { display: inline-flex; align-items: center; diff --git a/src/coulobre/hosting/templates/hosting/dns_zone_form.html b/src/coulobre/hosting/templates/hosting/dns_zone_form.html index 96f894c..ac2272b 100644 --- a/src/coulobre/hosting/templates/hosting/dns_zone_form.html +++ b/src/coulobre/hosting/templates/hosting/dns_zone_form.html @@ -26,8 +26,8 @@ Zone settings {{ form.nameservers.as_field_group }} {{ form.responsible_name.as_field_group }} - {{ form.delegate_dns.as_field_group }} - {{ form.manage_mail_dns.as_field_group }} +
{{ form.delegate_dns.as_field_group }}
+
{{ form.manage_mail_dns.as_field_group }}
{% endif %}
diff --git a/src/coulobre/hosting/templates/hosting/feature_configuration.html b/src/coulobre/hosting/templates/hosting/feature_configuration.html index 781d776..82a5968 100644 --- a/src/coulobre/hosting/templates/hosting/feature_configuration.html +++ b/src/coulobre/hosting/templates/hosting/feature_configuration.html @@ -28,11 +28,7 @@ {{ form.non_field_errors }} {{ form.revision }} {% for field in form.visible_fields %} -
- - {{ field.errors }} -

{{ field.help_text }}

-
+
{{ field.as_field_group }}
{% empty %}

No installed features can be configured here yet.

{% endfor %} diff --git a/src/coulobre/hosting/templates/hosting/notification_preferences.html b/src/coulobre/hosting/templates/hosting/notification_preferences.html index 0f54e5a..743ca16 100644 --- a/src/coulobre/hosting/templates/hosting/notification_preferences.html +++ b/src/coulobre/hosting/templates/hosting/notification_preferences.html @@ -12,10 +12,10 @@ {% else %}

Send the selected notifications to {{ request.user.email }}.

{% endif %} -
+ {% csrf_token %} - {{ form.as_p }} - + {{ form.as_div }} +
{% if deliveries %} diff --git a/src/coulobre/hosting/templates/hosting/remote_deployment.html b/src/coulobre/hosting/templates/hosting/remote_deployment.html index a4b9ca4..2c1b92f 100644 --- a/src/coulobre/hosting/templates/hosting/remote_deployment.html +++ b/src/coulobre/hosting/templates/hosting/remote_deployment.html @@ -49,7 +49,7 @@ {{ form.plan.as_field_group }} {{ form.password.as_field_group }} - {{ form.confirmed.as_field_group }} +
{{ form.confirmed.as_field_group }}
{% endif %}