-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add createViewTransition function (#1450)
Co-authored-by: Adam Skoufis <[email protected]>
- Loading branch information
Showing
8 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@vanilla-extract/babel-plugin-debug-ids": minor | ||
--- | ||
|
||
Add support for the new `createViewTransition` API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
"@vanilla-extract/css": minor | ||
--- | ||
|
||
Add `createViewTransition` API | ||
|
||
`createViewTransition` creates a single scoped view transition name for use with CSS View Transitions. This avoids potential naming collisions with other view transitions. | ||
|
||
```ts | ||
import { | ||
style, | ||
createViewTransition | ||
} from '@vanilla-extract/css'; | ||
|
||
export const titleViewTransition = createViewTransition(); | ||
|
||
export const pageTitle = style({ | ||
viewTransitionName: titleViewTransition | ||
}); | ||
`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { generateIdentifier } from './identifier'; | ||
|
||
// createViewTransition is used for locally scoping CSS view transitions | ||
// For now it is mostly just an alias of generateIdentifier | ||
export const createViewTransition = (debugId?: string) => | ||
generateIdentifier(debugId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
title: createViewTransition | ||
parent: api | ||
--- | ||
|
||
# createViewTransition | ||
|
||
Creates a single scoped view transition name for use with [CSS View Transitions]. | ||
This avoids potential naming collisions with other view transitions. | ||
|
||
> 🚧 Ensure your target browsers [support view transitions]. | ||
> Vanilla-extract supports the [view transition syntax][css view transitions] but does not polyfill the feature in unsupported browsers. | ||
```ts compiled | ||
// itemPage.css.ts | ||
import { | ||
style, | ||
createViewTransition | ||
} from '@vanilla-extract/css'; | ||
|
||
export const titleViewTransition = createViewTransition(); | ||
|
||
export const pageTitle = style({ | ||
viewTransitionName: titleViewTransition | ||
}); | ||
|
||
// navigation.css.ts | ||
import { style } from '@vanilla-extract/css'; | ||
import { titleViewTransition } from './itemPage.css.ts'; | ||
|
||
export const navigationLinkTitle = style({ | ||
viewTransitionName: titleViewTransition | ||
}); | ||
``` | ||
|
||
[css view transitions]: https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API#css_additions | ||
[support view transitions]: https://caniuse.com/view-transitions |