Files
member-console/internal/server/anatomy_disabled.go
T
cgalo5758 88db730fcc Add dual licensing and SPDX headers
Introduce a commercial license option alongside AGPL-3.0-only, require a
CLA for contributors, and document the terms in COMMERCIAL.md and
NOTICE. Add a script to stamp SPDX headers on Go files and apply it
across the tree.
2026-09-06 02:29:42 -05:00

44 lines
1.8 KiB
Go

// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
package server
// Page anatomy (docs/design-system.md §3 "Disabled controls", §6; spec
// form-conventions "Disabled controls carry their reason in the DOM").
// DisabledControl is what the disabledControl part
// (templates/partials/ui_disabled_control.html) renders: a disabled
// button plus the reason it is disabled, present in the DOM either way so
// a screen reader announces it regardless of whether the surface shows
// the reason as a tooltip or as visible text (design D10, ACC-8).
type DisabledControl struct {
// ID must be unique on the page: it names the reason element the
// button's aria-describedby points at.
ID string
// Label is the button's visible text.
Label string
// Classes is the button's class attribute, e.g.
// "btn btn-outline-primary btn-sm".
Classes string
// Reason is why the control is disabled, in plain language.
Reason string
// Visible renders Reason as ordinary <small> text below the button
// (member surface density) instead of a tooltip on a focusable
// wrapper (operator surface, the 2026-08-23 decision). See AsVisible.
Visible bool
}
// NewDisabledControl builds the operator surface's variant: the reason
// rides in a tooltip on a focusable wrapper, referenced by
// aria-describedby via a visually-hidden span. Call AsVisible for the
// member surface's variant instead.
func NewDisabledControl(id, label, classes, reason string) DisabledControl {
return DisabledControl{ID: id, Label: label, Classes: classes, Reason: reason}
}
// AsVisible returns the member surface's variant: the reason renders as
// ordinary <small> text instead of a tooltip.
func (d DisabledControl) AsVisible() DisabledControl {
d.Visible = true
return d
}