Skip to content

Commit 686529b

Browse files
authored
feat(toast): top and bottom attached and centered support
new position variants top attached and bottom attached which will show the toast over the whole width of the screen. Just like notificatons on mobile devices support for centered content and actions as we now have in other components as well fixed a visual bug when more than 2 vertical attached action buttons were used made compact variant unselectable at compile time
1 parent ab3d931 commit 686529b

File tree

3 files changed

+85
-10
lines changed

3 files changed

+85
-10
lines changed

src/definitions/modules/toast.less

Lines changed: 80 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,42 @@
2525
.ui.toast-container {
2626
position: fixed;
2727
z-index: 9999;
28+
&.ui.attached when (@variationToastAttached) {
29+
width: 100%;
30+
left: 0;
31+
margin-top: -@toastAttachedMargin;
32+
& .vertical.attached when (@variationToastVertical) {
33+
border-radius: 0;
34+
}
35+
&.ui.ui .attached.actions .button when (@variationToastActions) {
36+
border-radius: 0;
37+
}
38+
& .toast-box {
39+
margin-top: -@toastAttachedMargin;
40+
margin-bottom: 0;
41+
width: 100%;
42+
border-radius: 0;
43+
& > .vertical > .content when (@variationToastVertical) {
44+
flex: 1;
45+
}
46+
& > * {
47+
width: 100%;
48+
border-radius: 0;
49+
& > .vertical:not(.actions) when (@variationToastVertical) {
50+
flex: 1;
51+
}
52+
}
53+
& > .attached.actions when (@variationToastActions) {
54+
margin-right: @toastLeftRightMargin;
55+
}
56+
}
57+
&.top when (@variationToastTop) {
58+
top: 0;
59+
}
60+
&.bottom when (@variationToastBottom) {
61+
bottom: 0;
62+
}
63+
}
2864
&.top when (@variationToastTop) {
2965
&.right when (@variationToastRight) {
3066
top: @toastContainerDistance;
@@ -88,9 +124,11 @@
88124
border: @toastBoxBorder;
89125
}
90126
}
91-
&.compact,
92-
> .compact {
93-
width: @toastWidth;
127+
& when (@variationToastCompact) {
128+
&.compact,
129+
> .compact {
130+
width: @toastWidth;
131+
}
94132
}
95133
& > .ui.toast,
96134
> .ui.message {
@@ -348,9 +386,6 @@
348386
border-top-right-radius: 0;
349387
border-bottom-right-radius: 0;
350388
}
351-
& .button:not(:first-child):not(:last-child) {
352-
margin-left: -@toastLeftRightMargin;
353-
}
354389
}
355390
&.message.message.message when (@variationToastMessage) {
356391
border-top-right-radius: @toastBorderRadius;
@@ -426,8 +461,15 @@
426461
font-size: @toastIconFontSize;
427462
}
428463
&:not(.vertical) {
464+
&:not(.centered):not(.center) {
465+
& > i.icon:not(.close) when (@variationToastIcon) {
466+
position: absolute;
467+
}
468+
& > .ui.image when (@variationToastImage) {
469+
position: absolute;
470+
}
471+
}
429472
& > i.icon:not(.close) when (@variationToastIcon) {
430-
position: absolute;
431473
& + .content {
432474
padding-left: @toastIconContentPadding;
433475
}
@@ -436,7 +478,6 @@
436478
padding-left: @toastCloseDistance;
437479
}
438480
& > .ui.image when (@variationToastImage) {
439-
position: absolute;
440481
&.avatar + .content {
441482
padding-left: @toastAvatarImageContentPadding;
442483
min-height: @toastAvatarImageHeight;
@@ -454,7 +495,7 @@
454495
min-height: @toastSmallImageHeight;
455496
}
456497
}
457-
& when (@variationToastImage) or (@variationToastIcon) {
498+
&:not(.centered):not(.center) when (@variationToastImage) or (@variationToastIcon) {
458499
& > .centered.image,
459500
> .centered.icon {
460501
transform: translateY(-50%);
@@ -516,6 +557,36 @@
516557
margin-right: auto;
517558
}
518559

560+
& when (@variationToastCentered) {
561+
.ui.ui.toast-container .toast-box .centered.toast,
562+
.ui.ui.toast-container .toast-box .center.aligned.toast {
563+
text-align: center;
564+
display: flex;
565+
justify-content: center;
566+
567+
& > .content,
568+
& > .ui.image,
569+
& > i.icon:not(.close) {
570+
align-self: center;
571+
}
572+
}
573+
574+
.ui.toast-container .toast-box .toast .centered.content,
575+
.ui.toast-container .toast-box .toast .center.aligned.content {
576+
text-align: center;
577+
}
578+
579+
.ui.toast-container .toast-box .centered.actions,
580+
.ui.toast-container .toast-box .center.aligned.actions {
581+
text-align: center;
582+
583+
&:not(.attached) > .button:not(.fluid) {
584+
margin-left: @toastActionCenteredMargin;
585+
margin-right: @toastActionCenteredMargin;
586+
}
587+
}
588+
}
589+
519590
/*--------------
520591
Colors
521592
-------------- */

src/themes/default/globals/variation.variables

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,8 @@
552552
@variationToastActions: true;
553553
@variationToastVertical: true;
554554
@variationToastAttached: true;
555+
@variationToastCompact: true;
556+
@variationToastCentered: true;
555557

556558
/* Transition */
557559
@variationTransitionDisabled: true;

src/themes/default/modules/toast.variables

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
@toastTextColor: @invertedTextColor;
1919
@toastInvertedTextColor: @textColor;
2020
@toastNeutralTextColor: @textColor;
21+
@toastAttachedMargin: 1px;
2122

2223
/* Mobile */
2324
@mobileToastBreakpoint: 420px;
@@ -81,4 +82,5 @@
8182
@toastActionMarginLeft: 1em;
8283
@toastActionMarginBottom: 0.3em;
8384
@toastActionPadding: 0.5em;
84-
@toastActionPaddingBottom: 0.75em;
85+
@toastActionPaddingBottom: 0.75em;
86+
@toastActionCenteredMargin: 0.25em;

0 commit comments

Comments
 (0)