favoritter/web/templates/pages/fave_form.html
Ole-Morten Duesund a9d84a4de8 a11y: fix WCAG 2.2 AA and Uutilsynet audit findings
Tag autocomplete combobox pattern (WCAG 2.1.1, 4.1.2, 4.1.3):
- Add role="combobox", aria-expanded, aria-haspopup to tag input
- Implement arrow key navigation (up/down) through suggestions
- Add Space key support alongside Enter for selecting tags
- Manage aria-activedescendant to track highlighted option
- Add Escape to close suggestions
- Add aria-live="polite" status region announcing suggestion count
- Add aria-selected state on options
- Tag suggestions now have stable IDs for activedescendant

Focus visibility (WCAG 2.4.7):
- Remove outline:none on tag suggestions, replace with visible
  2px solid outline on :focus-visible

Contrast (WCAG 1.4.3):
- Replace opacity:0.5 on disabled rows with muted text color
  and strikethrough on username (maintains 4.5:1 ratio)

Structure and semantics (WCAG 1.3.1):
- Fix heading hierarchy H1→H3 skip in import.html (now H2)
- Replace <nav> misuse for fave actions with div[role="group"]
- Add aria-label="Administrasjonsmeny" to admin dashboard nav
- Wrap admin users table in responsive scrollable region
- Remove redundant "Bilde for:" prefix from image alt text
- Make error page H1 descriptive: "Feil 404: Ikke funnet"
- Add .sr-only utility class for screen-reader-only content
- Add hreflang="en" to English-language external link

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 17:54:24 +02:00

96 lines
3.8 KiB
HTML

{{define "content"}}
<article>
{{with .Data}}
{{if .IsNew}}
<h1>Ny favoritt</h1>
{{else}}
<h1>Rediger favoritt</h1>
{{end}}
<form method="POST"
enctype="multipart/form-data"
{{if .IsNew}}
action="{{basePath}}/faves"
{{else}}
action="{{basePath}}/faves/{{.Fave.ID}}"
{{end}}>
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<label for="description">
Beskrivelse *
<input type="text" id="description" name="description"
value="{{.Description}}" required autofocus
placeholder="F.eks. «Blade Runner 2049» eller «Rød tulipan»">
</label>
<label for="url">
Lenke (valgfri)
<input type="url" id="url" name="url"
value="{{.URL}}"
placeholder="https://...">
</label>
<label for="image">
Bilde (valgfri)
<input type="file" id="image" name="image"
accept="image/jpeg,image/png,image/gif,image/webp">
</label>
{{if not .IsNew}}
{{if .Fave.ImagePath}}
<div class="current-image">
<img src="{{basePath}}/uploads/{{.Fave.ImagePath}}"
alt="Nåværende bilde"
style="max-width: 200px; max-height: 200px;">
<label>
<input type="checkbox" name="remove_image" value="1">
Fjern bilde
</label>
</div>
{{end}}
{{end}}
<label for="tags">
Merkelapper (kommaseparert)
<input type="text" id="tags" name="tags"
value="{{.Tags}}"
placeholder="film, sci-fi, favoritt"
autocomplete="off"
role="combobox"
aria-expanded="false"
aria-haspopup="listbox"
aria-autocomplete="list"
aria-controls="tag-suggestions"
aria-describedby="tags-help"
hx-get="{{basePath}}/tags/search"
hx-trigger="keyup changed delay:300ms"
hx-target="#tag-suggestions"
hx-params="*"
hx-vals='{"q": ""}'>
<small id="tags-help">Skriv for å søke i eksisterende merkelapper. Maks {{maxTags}} stk. Bruk piltaster for å velge.</small>
</label>
<ul id="tag-suggestions" role="listbox" class="tag-suggestions" aria-label="Merkelappforslag"></ul>
<div id="tag-status" class="sr-only" aria-live="polite"></div>
<fieldset>
<legend>Synlighet</legend>
<label>
<input type="radio" name="privacy" value="public"
{{if eq .Privacy "public"}}checked{{end}}
{{if .IsNew}}{{if eq .DefaultPrivacy "public"}}checked{{end}}{{end}}>
Offentlig
</label>
<label>
<input type="radio" name="privacy" value="private"
{{if eq .Privacy "private"}}checked{{end}}
{{if .IsNew}}{{if eq .DefaultPrivacy "private"}}checked{{end}}{{end}}>
Privat
</label>
</fieldset>
<button type="submit">
{{if .IsNew}}Legg til{{else}}Lagre{{end}}
</button>
</form>
{{end}}
</article>
{{end}}