Skip to content

Add(CSS): View Transitions API foundation (Layer 1 + 2) - #427

Closed
0Miles wants to merge 1 commit into
master-co:rcfrom
0Miles:feat/265-view-transition-foundation
Closed

0Miles wants to merge 1 commit into
master-co:rcfrom
0Miles:feat/265-view-transition-foundation

Conversation

@0Miles

@0Miles 0Miles commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Closes #265 (foundation + Layer 2). Layer 3 (`@view-transition` at-rule) deferred to a separate PR with maintainer design call.

Summary

Two layers of View Transitions API support:

Layer 1 — element marking

  • `view-transition-name` and `view-transition-class` registered as native rules
  • `` works directly

Layer 2 — pseudo-element selectors

Five short-form aliases under `config/selectors.ts`:

Token Maps to
`::vt` `::view-transition`
`::vt-group` `::view-transition-group`
`::vt-image-pair` `::view-transition-image-pair`
`::vt-old` `::view-transition-old`
`::vt-new` `::view-transition-new`

The `(name)` parameter sticks: `opacity:0.5::vt-old(hero)` produces `::view-transition-old(hero){opacity:0.5}`.

Bonus fix in parse-selector

Building Layer 2 surfaced a parser bug: `pre.lastIndexOf(':')` for `::name(args)` only stripped ONE colon, so `::view-transition-old(hero)` rendered as `:view-transition-old(hero)` (single colon → typed as pseudo-class). Walk back through any leading consecutive colons so the full prefix is captured.

Layer 3 — needs design call

`@view-transition { navigation: auto; }` is a document-level at-rule, not a class. Three options documented in `css-docs/view-transitions-design.md`:

  1. New config field `crossDocumentViewTransitions: 'auto'` → core prepends the at-rule to output
  2. Generic "raw declarations" config field
  3. Don't ship — users add it manually

I lean to (1) but it needs maintainer choice on schema + scope.

Testing

  • 10 new test cases covering Layer 1 + the parser fix + each Layer 2 alias with parameter
  • 109 core test files still pass
  • Real Chrome verification: rendered stylesheet contains `.opacity\:0\.5\:\:vt-old\(hero\)::view-transition-old(hero){opacity:0.5}` with proper double colons; `getComputedStyle(...).viewTransitionName === "hero"`

@vercel

vercel Bot commented Apr 30, 2026

Copy link
Copy Markdown

@0Miles is attempting to deploy a commit to the Aoyue Team on Vercel.

A member of the Team first needs to authorize it.

Layer 1 — element marking:
- view-transition-name and view-transition-class registered as
  native rules
- <img class="view-transition-name:hero"> works directly

Layer 2 — pseudo-element selectors:
Five short-form aliases under config/selectors.ts:
- ::vt → ::view-transition
- ::vt-group → ::view-transition-group
- ::vt-image-pair → ::view-transition-image-pair
- ::vt-old → ::view-transition-old
- ::vt-new → ::view-transition-new

The (name) parameter sticks: opacity:0.5::vt-old(hero) →
::view-transition-old(hero){opacity:0.5}

Bonus parser fix in parse-selector: pre.lastIndexOf(':') for
::name(args) only stripped ONE colon, so ::view-transition-old(hero)
rendered as :view-transition-old(hero) (single colon → typed as
pseudo-class). Walk back through any leading consecutive colons so
the full prefix is captured.

Layer 3 (@view-transition at-rule) deferred — it's a document-level
declaration that doesn't fit the class-based model. Three design
options documented in css-docs/view-transitions-design.md, needs
maintainer choice.

- 10 test cases covering Layer 1 + parser fix + each Layer 2 alias
  with parameter
- Real Chrome verification: rendered stylesheet contains proper
  ::view-transition-old(hero) selector with double colons; computed
  viewTransitionName === "hero"

Closes master-co#265
@0Miles
0Miles force-pushed the feat/265-view-transition-foundation branch from 63c9c79 to 7b2f097 Compare April 30, 2026 19:05
@0Miles
0Miles requested a review from 1aron April 30, 2026 19:12
@0Miles 0Miles mentioned this pull request Apr 30, 2026
@1aron 1aron closed this May 3, 2026
1aron added a commit that referenced this pull request May 3, 2026
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.

✨ View Transition API

2 participants