Skip to content

feat(html): animation dialect (anim attribute)#34

Merged
LeadcodeDev merged 1 commit into
mainfrom
feat/html-animation-dialect
Jul 18, 2026
Merged

feat(html): animation dialect (anim attribute)#34
LeadcodeDev merged 1 commit into
mainfrom
feat/html-animation-dialect

Conversation

@LeadcodeDev

Copy link
Copy Markdown
Owner

Closes #19.

Goal: declare animations in HTML — the biggest authoring barrier of the dialect, which forced a JSON round-trip for any entrance.

Two frozen forms, on any scene element (HTML tags and rm-*):

  • JSON: anim='[{"name":"fade_in_up","delay":0.3}]' (single object auto-wrapped) → style.animation verbatim
  • Compact DSL: anim="fade-in-up delay:0.3 duration:0.8; pulse delay:2 loop:true";-separated effects, name key:value…, kebab→snake on names and keys, numbers/bools coerced

Malformed DSL/JSON → dedicated transpile errors (InvalidAnimDsl/InvalidAnimJson), including the forgot-the-preset-name case (anim="delay:0.3"). Unknown preset names are deliberately not validated in the transpiler (no schema dependency): the typed AnimationEffect deserialization — blocking since #33 — rejects them at validate with unknown variant 'not_a_preset', expected one of 'fade_in', ….

Tests: 15 new (TDD): both forms, multi-effect DSL, case conversions, five malformed-input errors, style coexistence, rm-* non-leakage, studio round-trip preservation, and the CLI-level unknown-preset blocking error. showcase.html now exercises DSL entrances, a staggered card (composing with #31), and a JSON-form continuous pulse — validates green end-to-end.

Verify: cargo test --workspace → 174 passed ✓ · cargo fmt --check ✓ · clippy 0 warnings ✓ · rustmotion validate on showcase + manual DSL sample ✓

Animations are now expressible in HTML — the dialect's biggest gap:

- JSON form: anim='[{"name":"fade_in_up","delay":0.3}]' (object
  auto-wrapped), inserted into style.animation
- compact DSL: anim="fade-in-up delay:0.3 duration:0.8; pulse
  loop:true" — ;-separated effects, kebab->snake on names and keys,
  numbers/bools coerced
- malformed input (empty effect, pair without ':', missing preset
  name, bad JSON) is an explicit transpile error; unknown preset names
  are rejected downstream by the typed deserialization made blocking
  in #33, with a readable unknown-variant message
- anim is consumed on rm-* elements (never leaked as component field)
  and survives the studio round-trip (set_inline_style/set_text_content)
@LeadcodeDev
LeadcodeDev merged commit 68dbf19 into main Jul 18, 2026
@LeadcodeDev
LeadcodeDev deleted the feat/html-animation-dialect branch July 18, 2026 20:44
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.

feat(html): animation dialect (anim attribute)

1 participant