Skip to content

Commit 07e739a

Browse files
entombrandyscarney
authored andcommitted
feat(toast): add variables to change position start/end of toast (#17961)
closes #17854
1 parent e5c8c10 commit 07e739a

File tree

7 files changed

+30
-2
lines changed

7 files changed

+30
-2
lines changed

core/api.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,11 +1165,13 @@ ion-toast,css-prop,--border-width
11651165
ion-toast,css-prop,--box-shadow
11661166
ion-toast,css-prop,--button-color
11671167
ion-toast,css-prop,--color
1168+
ion-toast,css-prop,--end
11681169
ion-toast,css-prop,--height
11691170
ion-toast,css-prop,--max-height
11701171
ion-toast,css-prop,--max-width
11711172
ion-toast,css-prop,--min-height
11721173
ion-toast,css-prop,--min-width
1174+
ion-toast,css-prop,--start
11731175
ion-toast,css-prop,--width
11741176

11751177
ion-toggle,shadow

core/src/components/toast/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,13 @@ Type: `Promise<void>`
271271
| `--box-shadow` | Box shadow of the toast |
272272
| `--button-color` | Color of the button text |
273273
| `--color` | Color of the toast text |
274+
| `--end` | Position from the end |
274275
| `--height` | Height of the toast |
275276
| `--max-height` | Maximum height of the toast |
276277
| `--max-width` | Maximum width of the toast |
277278
| `--min-height` | Minimum height of the toast |
278279
| `--min-width` | Minimum width of the toast |
280+
| `--start` | Position from the start |
279281
| `--width` | Width of the toast |
280282

281283

core/src/components/toast/test/basic/e2e.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ test('toast: basic, custom class', async () => {
4242
await testToast(DIRECTORY, '#custom-class-toast');
4343
});
4444

45+
test('toast: start end position', async () => {
46+
await testToast(DIRECTORY, '#toast-start-and-end');
47+
});
48+
4549
/**
4650
* RTL Tests
4751
*/
@@ -85,3 +89,7 @@ test('toast:rtl: basic, color', async () => {
8589
test('toast:rtl: basic, custom class', async () => {
8690
await testToast(DIRECTORY, '#custom-class-toast', true);
8791
});
92+
93+
test('toast:rtl: start end position', async () => {
94+
await testToast(DIRECTORY, '#toast-start-and-end', true);
95+
});

core/src/components/toast/test/basic/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
Custom Class
6969
</ion-button>
7070

71+
<ion-button expand="block" id="toast-start-and-end" onclick="presentToastWithOptions({message: 'click to close', showCloseButton: true, cssClass: 'toast-start-and-end'})">
72+
Show Toast with start-end position
73+
</ion-button>
74+
7175
<ion-toast-controller></ion-toast-controller>
7276

7377
<ion-grid>
@@ -210,6 +214,12 @@
210214
.orange {
211215
background-color: #f69234;
212216
}
217+
218+
.toast-start-and-end {
219+
--start: 0;
220+
--end: 0;
221+
--max-width: 100%;
222+
}
213223
</style>
214224
</body>
215225

core/src/components/toast/toast.ios.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
--button-color: #{$toast-ios-button-color};
1111
--color: #{$toast-ios-title-color};
1212
--max-width: #{$toast-max-width};
13+
--start: 10px;
14+
--end: 10px;
1315

1416
font-size: $toast-ios-content-font-size;
1517
}
1618

1719
.toast-wrapper {
18-
@include position-horizontal(10px, 10px);
1920
@include margin(auto);
2021

2122
display: block;

core/src/components/toast/toast.md.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
--button-color: #{ion-color(primary, base)};
1212
--color: #{$toast-md-color};
1313
--max-width: #{$toast-max-width};
14+
--start: 8px;
15+
--end: 8px;
1416

1517
font-size: #{$toast-md-font-size};
1618
}
1719

1820
.toast-wrapper {
19-
@include position-horizontal(8px, 8px);
2021
@include margin(auto);
2122

2223
display: block;

core/src/components/toast/toast.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
* @prop --max-height: Maximum height of the toast
2525
*
2626
* @prop --button-color: Color of the button text
27+
*
28+
* @prop --start: Position from the start
29+
* @prop --end: Position from the end
2730
*/
2831
--border-width: 0;
2932
--border-style: none;
@@ -68,6 +71,7 @@
6871

6972
.toast-wrapper {
7073
@include border-radius(var(--border-radius));
74+
@include position-horizontal(var(--start), var(--end));
7175

7276
width: var(--width);
7377
min-width: var(--min-width);

0 commit comments

Comments
 (0)