feat: Add enterFrom prop to control toast entry direction (#671)#721
Open
dosAnjosGustavo wants to merge 1 commit intoemilkowalski:mainfrom
Open
feat: Add enterFrom prop to control toast entry direction (#671)#721dosAnjosGustavo wants to merge 1 commit intoemilkowalski:mainfrom
enterFrom prop to control toast entry direction (#671)#721dosAnjosGustavo wants to merge 1 commit intoemilkowalski:mainfrom
Conversation
…lski#671) - Introduce an `EnterFromDirection` type and `enterFrom` prop on `ToastT`, `ToastProps`, `ToastOptions` and `ToasterProps` to control the horizontal entry side (left or right) of a toast. - Define `enterFrom` precedence so per-toast settings override the Toaster-level prop, which in turn overrides `toastOptions`, keeping existing behavior unchanged when `enterFrom` is not provided. - Add a `data-enter-from` attribute to each toast and split the base transform into `--initial-x` and `--y` so horizontal entry can be configured without affecting the vertical stacking logic. - Update the CSS so toasts slide in from the configured side and, when removed as the front toast, exit horizontally instead of using the default vertical animation. - Update the test app to accept `enterFrom` via query string and add a Playwright test to assert that the attribute is rendered correctly.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #671.
This PR adds a way to control which horizontal side a toast should enter from, without changing the existing default behavior.
What’s new
Introduces an
EnterFromDirectiontype:Adds an optional
enterFrom?: EnterFromDirectionprop to:ToastTToastPropsToastOptionsToasterPropsBehaviour & precedence
enterFromcan be set:toast('Message', { enterFrom: 'left' })Toaster:<Toaster enterFrom="left" />toastOptionson theToasterPrecedence:
enterFromToasterenterFromproptoastOptions.enterFromWhen
enterFromis not provided, the current behaviour is preserved.Implementation details
Each toast now has a
data-enter-fromattribute so the entry direction can be styled in CSS.The base transform is split into two parts:
--initial-x(horizontal offset)--y(existing vertical stacking)Updated CSS to:
leftorright)Testing
Added a Playwright test to assert that
enterFromis rendered on the toast when set via query string in the test app:applies enterFrom attribute to toast when setRan
pnpm testlocally:cancel button dismisses the custom toast with empty idcase, which is already failing on the current main build as well (so it should be unrelated to this change).