diff --git a/core/src/components/toast/test/basic/toast.e2e.ts b/core/src/components/toast/test/basic/toast.e2e.ts index 1dd6a02cfed..b53291271c7 100644 --- a/core/src/components/toast/test/basic/toast.e2e.ts +++ b/core/src/components/toast/test/basic/toast.e2e.ts @@ -47,26 +47,34 @@ class ToastFixture { /** * This behavior does not vary across directions. */ -configs({ modes: ['ios', 'md', 'ionic-md'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => { - test.describe(title('toast: position rendering'), () => { - let toastFixture: ToastFixture; - test.beforeEach(async ({ page }) => { - toastFixture = new ToastFixture(page); - await toastFixture.goto(config); - }); - test('should render toast at the top', async () => { - await toastFixture.openToast('#show-top-toast'); - await toastFixture.screenshot('top', screenshot); - }); - test('should render toast at the middle', async () => { - await toastFixture.openToast('#show-middle-toast'); - await toastFixture.screenshot('middle', screenshot); - }); - test('should render toast at the bottom', async () => { - await toastFixture.openToast('#show-bottom-toast'); - await toastFixture.screenshot('bottom', screenshot); +configs({ modes: ['ios', 'md', 'ionic-md', 'ionic-ios'], directions: ['ltr'] }).forEach( + ({ title, screenshot, config }) => { + test.describe(title('toast: position rendering'), () => { + let toastFixture: ToastFixture; + test.beforeEach(async ({ page }) => { + toastFixture = new ToastFixture(page); + await toastFixture.goto(config); + }); + test('should render toast at the top', async () => { + await toastFixture.openToast('#show-top-toast'); + await toastFixture.screenshot('top', screenshot); + }); + test('should render toast at the middle', async () => { + await toastFixture.openToast('#show-middle-toast'); + await toastFixture.screenshot('middle', screenshot); + }); + test('should render toast at the bottom', async () => { + await toastFixture.openToast('#show-bottom-toast'); + await toastFixture.screenshot('bottom', screenshot); + }); }); - }); + } +); + +/** + * This behavior does not vary across directions. + */ +configs({ modes: ['ios', 'md', 'ionic-md'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => { test.describe(title('toast: color rendering'), () => { test('should set color correctly', async ({ page }) => { const toastFixture = new ToastFixture(page); diff --git a/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-bottom-ionic-ios-ltr-light-Mobile-Chrome-linux.png b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-bottom-ionic-ios-ltr-light-Mobile-Chrome-linux.png new file mode 100644 index 00000000000..d41391673c4 Binary files /dev/null and b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-bottom-ionic-ios-ltr-light-Mobile-Chrome-linux.png differ diff --git a/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-bottom-ionic-ios-ltr-light-Mobile-Firefox-linux.png b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-bottom-ionic-ios-ltr-light-Mobile-Firefox-linux.png new file mode 100644 index 00000000000..6ee511d7e57 Binary files /dev/null and b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-bottom-ionic-ios-ltr-light-Mobile-Firefox-linux.png differ diff --git a/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-bottom-ionic-ios-ltr-light-Mobile-Safari-linux.png b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-bottom-ionic-ios-ltr-light-Mobile-Safari-linux.png new file mode 100644 index 00000000000..f1bcbb47be1 Binary files /dev/null and b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-bottom-ionic-ios-ltr-light-Mobile-Safari-linux.png differ diff --git a/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-middle-ionic-ios-ltr-light-Mobile-Chrome-linux.png b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-middle-ionic-ios-ltr-light-Mobile-Chrome-linux.png new file mode 100644 index 00000000000..4f5b0d0f683 Binary files /dev/null and b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-middle-ionic-ios-ltr-light-Mobile-Chrome-linux.png differ diff --git a/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-middle-ionic-ios-ltr-light-Mobile-Firefox-linux.png b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-middle-ionic-ios-ltr-light-Mobile-Firefox-linux.png new file mode 100644 index 00000000000..81fe21af0b4 Binary files /dev/null and b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-middle-ionic-ios-ltr-light-Mobile-Firefox-linux.png differ diff --git a/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-middle-ionic-ios-ltr-light-Mobile-Safari-linux.png b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-middle-ionic-ios-ltr-light-Mobile-Safari-linux.png new file mode 100644 index 00000000000..3e7ce773a39 Binary files /dev/null and b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-middle-ionic-ios-ltr-light-Mobile-Safari-linux.png differ diff --git a/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-top-ionic-ios-ltr-light-Mobile-Chrome-linux.png b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-top-ionic-ios-ltr-light-Mobile-Chrome-linux.png new file mode 100644 index 00000000000..9411b765604 Binary files /dev/null and b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-top-ionic-ios-ltr-light-Mobile-Chrome-linux.png differ diff --git a/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-top-ionic-ios-ltr-light-Mobile-Firefox-linux.png b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-top-ionic-ios-ltr-light-Mobile-Firefox-linux.png new file mode 100644 index 00000000000..6a485fd4e04 Binary files /dev/null and b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-top-ionic-ios-ltr-light-Mobile-Firefox-linux.png differ diff --git a/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-top-ionic-ios-ltr-light-Mobile-Safari-linux.png b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-top-ionic-ios-ltr-light-Mobile-Safari-linux.png new file mode 100644 index 00000000000..5281ddb8040 Binary files /dev/null and b/core/src/components/toast/test/basic/toast.e2e.ts-snapshots/toast-top-ionic-ios-ltr-light-Mobile-Safari-linux.png differ diff --git a/core/src/components/toast/toast.ionic.scss b/core/src/components/toast/toast.ionic.scss index 076f7df63a6..29eda6c9d99 100644 --- a/core/src/components/toast/toast.ionic.scss +++ b/core/src/components/toast/toast.ionic.scss @@ -19,18 +19,42 @@ z-index: 1001; } +// Toast Wrapper +// -------------------------------------------------- + .toast-wrapper { @include globals.margin(auto); display: block; position: absolute; - opacity: 0.01; - // TODO(ROU-10853): replace this value with a layer token. z-index: 10; } +/* + * In `md` mode, the toast fades in when presented. + * To achieve the fade-in effect, the initial opacity must be set + * to a value less than 1. + */ +:host(.md) .toast-wrapper { + opacity: 0.01; +} + +/* + * In `ios` mode, the toast will move into the screen based + * on the `position`. If the `position` is `middle`, the toast + * will fade in from the middle of the screen. + * To achieve the fade-in effect, the initial opacity must be set + * to a value less than 1. + */ +:host(.ios) .toast-wrapper.toast-middle { + opacity: 0.01; +} + +// Toast Container +// -------------------------------------------------- + .toast-container { @include globals.padding(globals.$ion-space-300, globals.$ion-space-400); } diff --git a/core/src/components/toast/toast.tsx b/core/src/components/toast/toast.tsx index bcffad5ca55..2d8cfec18cd 100644 --- a/core/src/components/toast/toast.tsx +++ b/core/src/components/toast/toast.tsx @@ -720,6 +720,7 @@ export class Toast implements ComponentInterface, OverlayInterface { const startButtons = allButtons.filter((b) => b.side === 'start'); const endButtons = allButtons.filter((b) => b.side !== 'start'); const theme = getIonTheme(this); + const mode = getIonMode(this); const shape = this.getShape(); const wrapperClass = { 'toast-wrapper': true, @@ -746,6 +747,7 @@ export class Toast implements ComponentInterface, OverlayInterface { zIndex: `${60000 + this.overlayIndex}`, }} class={createColorClasses(this.color, { + [mode]: true, [theme]: true, ...getClassMap(this.cssClass), 'overlay-hidden': true,