Integrate Web Awesome copy-button web component for click-to-copy
closedGoal
Replace the current hand-rolled click-to-copy JS (data-copy attrs + static/app.js handler) with the Web Awesome <wa-copy-button> web component (https://webawesome.com/docs/components/copy-button/), which has better UX (built-in success/error feedback, tooltip) and accessibility (copy-label as accessible name, focus-visible tooltip).
Related: tracking epic c32b584 (shadcn appview migration). Explicitly out of scope there; do the swap here after the table/alert migrations land.
Current usage to replace
internal/appview/ui/domain.templdnsTable:<code data-copy={ r.Name }>/<code data-copy={ r.Content }>internal/appview/ui/fragments.templappPasswordSecret:<code data-copy={ secret }>+ Copy<button data-copy={ secret }>- Handler:
internal/appview/ui/static/app.js(data-copyclick ->navigator.clipboard.writeText) - Styles: shadcn
table/alertsubtasks own the surrounding markup; this issue owns only the copy trigger + feedback.
Plan
- Decide delivery: vendor the
wa-copy-buttoncomponent JS (preferred, likehtmx.min.jsinui/static/+embed.gohandler) vs CDN import. Vendored keeps CSP/offline behavior consistent with htmx. - Register the component once in
Layout(or per-page script include) and add theCopy/Copiedstyling via CSS parts to match shadcn tokens. - Swap each
data-copysite to<wa-copy-button value=...>(literal secret/record content) orfrom="id"pointing at the code element; setcopy-label/success-label/error-label. - Remove the
data-copyhandler fromapp.jsonce no call sites remain; keepdata-copyattrs only where still needed during transition. - Note:
clipboard.writeText()needs a secure context (HTTPS); verify dev (https://*.sovrn.test) + prod behavior and the error state when unavailable.
Files (likely):
- Edit: internal/appview/ui/domain.templ, internal/appview/ui/fragments.templ, internal/appview/ui/layout.templ, internal/appview/ui/static/app.js, internal/appview/ui/embed.go
- Add: vendored webawesome JS under internal/appview/ui/static/
Verify
go generate ./internal/appview/ui, rebuild CSS,SOVRN_INTEGRATION=0 go test ./internal/appview/...- Manual: copy DNS name/content, copy app-password secret (chunked display still copies full secret), success tooltip + accessible name announced, error state on non-secure context.
- Confirm no
data-copyhandlers/attrs remain (grep -r data-copy internal/appview/ui).
Done when: all click-to-copy flows use <wa-copy-button>; old JS removed; a11y (keyboard focus, tooltip, labels) verified.
1 Comment
Used a toast implementation instead, extending the original implementation