-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
_toast.scss
230 lines (193 loc) · 5.72 KB
/
_toast.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
// Copyright 2016 Palantir Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0.
@import "../../common/variables";
@import "../../common/react-transition";
$toast-height: $pt-button-height-large !default;
$toast-min-width: $pt-grid-size * 30 !default;
$toast-max-width: $pt-grid-size * 50 !default;
$toast-margin: $pt-grid-size * 2 !default;
$toast-intent-colors: (
"primary": ($pt-intent-primary, $white, $blue2, $blue1),
"success": ($pt-intent-success, $white, $green2, $green1),
"warning": ($orange5, $dark-gray1, $orange4, $orange3),
"danger": ($pt-intent-danger, $white, $red2, $red1),
) !default;
@mixin pt-toast-intent(
$background-color,
$text-color,
$button-hover-color,
$button-active-color,
) {
background-color: $background-color;
color: $text-color;
.#{$ns}-icon:first-child {
color: rgba($text-color, 0.7);
}
// HACKHACK custom colors for buttons on intent background so they always show up nice
/* stylelint-disable declaration-no-important */
.#{$ns}-button {
background-color: $background-color !important;
color: $text-color !important;
&:hover {
background-color: $button-hover-color !important;
color: $text-color !important;
}
&:active {
background-color: $button-active-color !important;
color: $text-color !important;
}
&:focus {
// blue outline color shows poorly on colored bg
outline-color: rgba($white, 0.5);
}
&:last-child > .#{$ns}-icon-cross {
color: rgba($text-color, 0.7) !important;
}
}
/* stylelint-enable declaration-no-important */
}
.#{$ns}-toast {
// toast transition properties
$enter-translate: (transform: translateY(-$toast-height) translateY(0));
$leave-blur: (opacity: 0 1, filter: blur($pt-grid-size) blur(0));
// new toasts slide in from the top
@include react-transition-phase(
"#{$ns}-toast",
"enter",
$enter-translate,
$duration: $pt-transition-duration * 3,
$easing: $pt-transition-ease-bounce,
$before: "&"
);
@include react-transition-phase(
"#{$ns}-toast",
"enter",
$enter-translate,
$duration: $pt-transition-duration * 3,
$easing: $pt-transition-ease-bounce,
$before: "&",
$after: "~ &"
);
// leaving toasts simply fade away
@include react-transition-phase(
"#{$ns}-toast",
"exit",
$leave-blur,
$duration: $pt-transition-duration * 3,
$before: "&"
);
// younger siblings of leaving toasts wait a moment before moving to fill gap
@include react-transition-phase(
"#{$ns}-toast",
"exit",
$enter-translate,
$delay: $pt-transition-duration * 0.5,
$before: "&",
$after: "~ &"
);
align-items: flex-start;
background-color: $white;
border-radius: $pt-border-radius;
box-shadow: $pt-toast-box-shadow;
display: flex;
margin: $toast-margin 0 0;
max-width: $toast-max-width;
min-width: $toast-min-width;
// toast is interactive even though container isn't
pointer-events: all;
// override inline styles (#367): toasts rely on relative positioning for stacking.
/* stylelint-disable-next-line declaration-no-important */
position: relative !important;
.#{$ns}-button-group {
flex: 0 0 auto;
padding: ($toast-height - $pt-button-height) * 0.5;
padding-left: 0;
}
> .#{$ns}-icon {
color: $pt-icon-color;
margin: ($toast-height - $pt-icon-size-standard) * 0.5;
margin-right: 0;
}
&.#{$ns}-dark,
.#{$ns}-dark & {
background-color: $dark-gray5;
box-shadow: $pt-dark-toast-box-shadow;
> .#{$ns}-icon {
color: $pt-dark-icon-color;
}
// increase contrast for default intent in dark mode
.#{$ns}-button .#{$ns}-icon {
color: rgba($white, 0.7);
}
}
&[class*="#{$ns}-intent-"] {
a {
color: rgba($white, 0.7);
&:hover {
color: $white;
}
}
> .#{$ns}-icon {
color: $white;
}
}
@each $intent, $colors in $toast-intent-colors {
&.#{$ns}-intent-#{$intent} {
@include pt-toast-intent($colors...);
}
}
}
.#{$ns}-toast-message {
flex: 1 1 auto;
padding: centered-text($toast-height);
word-break: break-word;
}
.#{$ns}-toast-container {
align-items: center;
// override inline overlay styles (#2626)
/* stylelint-disable-next-line declaration-no-important */
display: flex !important;
flex-direction: column;
left: 0;
// toasts have margin-top so omit it on container
// prevent container from scrolling as new toasts enter (from bottom)
overflow: hidden;
// ensure there's enough space for full box-shadow
padding: 0 $toast-margin $toast-margin;
// container will not block clicks on elements behind it
pointer-events: none;
right: 0;
// #975 ensure toasts are on top of everything (esp dialogs)
z-index: $pt-z-index-overlay * 2;
&.#{$ns}-toast-container-in-portal {
position: fixed;
}
&.#{$ns}-toast-container-inline {
position: absolute;
}
&.#{$ns}-toast-container-top {
top: 0;
}
&.#{$ns}-toast-container-bottom {
bottom: 0;
flex-direction: column-reverse;
top: auto;
}
&.#{$ns}-toast-container-left {
align-items: flex-start;
}
&.#{$ns}-toast-container-right {
align-items: flex-end;
}
}
.#{$ns}-toast-container-bottom .#{$ns}-toast {
// minimal diff in react-transition styles so we can avoid calling those mixins again
&.#{$ns}-toast-enter:not(.#{$ns}-toast-enter-active),
&.#{$ns}-toast-enter:not(.#{$ns}-toast-enter-active) ~ .#{$ns}-toast,
&.#{$ns}-toast-appear:not(.#{$ns}-toast-appear-active),
&.#{$ns}-toast-appear:not(.#{$ns}-toast-appear-active) ~ .#{$ns}-toast,
&.#{$ns}-toast-exit-active ~ .#{$ns}-toast,
&.#{$ns}-toast-leave-active ~ .#{$ns}-toast {
transform: translateY($toast-margin + $toast-height);
}
}