Skip to content

Add x-image web component#9

Merged
avanelsas merged 2 commits intomainfrom
feature/x-image
Apr 15, 2026
Merged

Add x-image web component#9
avanelsas merged 2 commits intomainfrom
feature/x-image

Conversation

@avanelsas
Copy link
Copy Markdown
Owner

Summary

  • Adds x-image, a stateless image component that wraps a native <img> in open shadow DOM with a skeleton shimmer placeholder, fade-in on load, optional aspect-ratio box (ratio="16:9" etc.) to prevent CLS, a default or slotted error fallback, and an enforced alt hygiene warning.
  • Public API: attributes src, alt, decorative, ratio, fit, position, loading; properties mirror attributes plus read-only naturalWidth / naturalHeight / state; events x-image-load and x-image-error (both bubbles + composed, non-cancelable).
  • Ships with 18 model unit tests, 21 browser integration tests, full docs, and a demo with a live editor + a11y state readout.

Test plan

  • npx shadow-cljs watch testhttp://localhost:8021 — all baredom.components.x-image.* deftests green.
  • npx shadow-cljs watch apphttp://localhost:8000 — walk the demo: ratio variants reserve space (no CLS), fit variants render as expected, decorative toggle flips the a11y readout, default 404 fallback renders, slotted <div slot="error"> fallback renders, event log shows x-image-load / x-image-error with detail payloads.
  • Chrome devtools mobile: 320 px width, no horizontal overflow; prefers-reduced-motion: reduce → shimmer static, fade-in instant; prefers-color-scheme: dark → surface background adapts.
  • npm run build — clean Closure Advanced release, 0 warnings, dist/x-image.js emitted.

🤖 Generated with Claude Code

Stateless image component that wraps a native <img> in shadow DOM with
a skeleton shimmer placeholder, fade-in on load, optional aspect ratio
to prevent layout shift, a default or slotted error fallback, and
enforced alt hygiene. Ships with model unit tests, browser integration
tests, docs, and a demo with a live editor + a11y state readout.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@avanelsas avanelsas mentioned this pull request Apr 15, 2026
3 tasks
clj-kondo CI check surfaced an unused-refer warning which failed the
lint job. The macro was imported but every deftest uses async polling
loops rather than nested testing blocks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@avanelsas avanelsas merged commit c06f5fa into main Apr 15, 2026
1 check passed
@avanelsas avanelsas deleted the feature/x-image branch April 15, 2026 12:34
@avanelsas avanelsas mentioned this pull request Apr 15, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant