UNPKG

7.24 kBSCSSView Raw
1// Position
2.toast-center-center {
3 top: 50%;
4 left: 50%;
5 transform: translate(-50%, -50%);
6}
7.toast-top-center {
8 top: 0;
9 right: 0;
10 width: 100%;
11}
12.toast-bottom-center {
13 bottom: 0;
14 right: 0;
15 width: 100%;
16}
17.toast-top-full-width {
18 top: 0;
19 right: 0;
20 width: 100%;
21}
22.toast-bottom-full-width {
23 bottom: 0;
24 right: 0;
25 width: 100%;
26}
27.toast-top-left {
28 top: 12px;
29 left: 12px;
30}
31.toast-top-right {
32 top: 12px;
33 right: 12px;
34}
35.toast-bottom-right {
36 right: 12px;
37 bottom: 12px;
38}
39.toast-bottom-left {
40 bottom: 12px;
41 left: 12px;
42}
43.toast-container.toast-top-center .ngx-toastr,
44.toast-container.toast-bottom-center .ngx-toastr {
45 width: 300px;
46 margin-left: auto;
47 margin-right: auto;
48}
49.toast-container.toast-top-full-width .ngx-toastr,
50.toast-container.toast-bottom-full-width .ngx-toastr {
51 width: 96%;
52 margin-left: auto;
53 margin-right: auto;
54}
55
56// Toast
57.toast-container {
58 pointer-events: none;
59 position: fixed;
60 z-index: 999999;
61
62 .ngx-toastr {
63 @include border-radius($alert-border-radius);
64 position: relative;
65 overflow: hidden;
66 margin: 0 0 6px;
67 padding: 0.75rem 1.25rem 0.75rem 50px;
68 width: 300px;
69 background-position: 15px center;
70 background-repeat: no-repeat;
71 background-size: 24px;
72 box-shadow: 0 0 10px rgba(0, 0, 0, 0.03);
73 pointer-events: auto;
74
75 .toast-title {
76 font-weight: bold;
77 }
78 .toast-message {
79 word-wrap: break-word;
80 }
81 .toast-message a:hover {
82 text-decoration: underline;
83 }
84 .toast-close-button {
85 position: relative;
86 right: -0.3em;
87 top: -0.3em;
88 float: right;
89 font-size: 20px;
90 font-weight: bold;
91 color: inherit;
92 text-shadow: 0 1px 0 #fff;
93 opacity: 0.5;
94 background: transparent;
95 border: 0;
96 padding: 0;
97 }
98 .toast-progress {
99 position: absolute;
100 left: 0;
101 bottom: 0;
102 height: 4px;
103 background-color: #000000;
104 opacity: 0.3;
105 }
106 .toast-close-button:hover,
107 .toast-close-button:focus {
108 color: #000000;
109 text-decoration: none;
110 cursor: pointer;
111 opacity: 0.75;
112 }
113 }
114 .ngx-toastr:hover {
115 box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
116 opacity: 1;
117 cursor: pointer;
118 }
119}
120
121@function str-split($string, $separator) {
122 $split-arr: ();
123 // first index of separator in string
124 $index: str-index($string, $separator);
125 // loop through string
126 @while $index != null {
127 // get the substring from the first character to the separator
128 $item: str-slice($string, 1, $index - 1);
129 // push item to array
130 $split-arr: append($split-arr, $item);
131 // remove item and separator from string
132 $string: str-slice($string, $index + 1);
133 // find new index of separator
134 $index: str-index($string, $separator);
135 }
136 // add the remaining string to list (the last item)
137 $split-arr: append($split-arr, $string);
138
139 @return $split-arr;
140}
141
142@function svg-factory($fill-color, $viewbox, $path) {
143 $split: str-split($viewbox, ' ');
144 $width: nth($split, 3);
145 $height: nth($split, 4);
146
147 // opacity is 0.9999 otherwise it uses a hex equivelent
148 // firefox requires fill rgb
149 @return "%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='" + $viewbox +
150 "' width='" + $width + "' height='" + $height + "'%3E%3Cpath fill='" +
151 rgba($fill-color, 0.999999) + "' d='" + $path + "'/%3E%3C/svg%3E";
152}
153@function svg-encode($svg) {
154 @return 'data:image/svg+xml;charset=utf8,' + $svg;
155}
156.toast-success {
157 /* https://github.com/FortAwesome/Font-Awesome-Pro/blob/master/advanced-options/raw-svg/solid/check.svg */
158 background-image: url(svg-encode(
159 svg-factory(
160 theme-color-level('success', 6),
161 '0 0 512 512',
162 'M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z'
163 )
164 ));
165 color: theme-color-level('success', 6);
166 background-color: theme-color-level('success', -10);
167 border: 1px solid theme-color-level('success', -9);
168}
169.toast-error {
170 /* https://github.com/FortAwesome/Font-Awesome-Pro/blob/master/advanced-options/raw-svg/solid/times-circle.svg */
171 background-image: url(svg-encode(
172 svg-factory(
173 theme-color-level('danger', 6),
174 '0 0 512 512',
175 'M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z'
176 )
177 ));
178 color: theme-color-level('danger', 6);
179 background-color: theme-color-level('danger', -10);
180 border: 1px solid theme-color-level('danger', -9);
181}
182.toast-info {
183 /* https://github.com/FortAwesome/Font-Awesome-Pro/blob/master/advanced-options/raw-svg/solid/info-circle.svg */
184 background-image: url(svg-encode(
185 svg-factory(
186 theme-color-level('info', 6),
187 '0 0 512 512',
188 'M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z'
189 )
190 ));
191 color: theme-color-level('info', 6);
192 background-color: theme-color-level('info', -10);
193 border: 1px solid theme-color-level('info', -9);
194}
195.toast-warning {
196 /* https://github.com/FortAwesome/Font-Awesome-Pro/blob/master/advanced-options/raw-svg/solid/exclamation-triangle.svg */
197 background-image: url(svg-encode(
198 svg-factory(
199 theme-color-level('warning', 6),
200 '0 0 576 512',
201 'M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z'
202 )
203 ));
204 color: theme-color-level('warning', 6);
205 background-color: theme-color-level('warning', -10);
206 border: 1px solid theme-color-level('warning', -9);
207}
208
209// Responsive Design
210@media all and (max-width: 240px) {
211 .toast-container .ngx-toastr.div {
212 padding: 8px 8px 8px 50px;
213 width: 11em;
214 }
215 .toast-container .toast-close-button {
216 right: -0.2em;
217 top: -0.2em;
218 }
219}
220@media all and (min-width: 241px) and (max-width: 480px) {
221 .toast-container .ngx-toastr.div {
222 padding: 8px 8px 8px 50px;
223 width: 18em;
224 }
225 .toast-container .toast-close-button {
226 right: -0.2em;
227 top: -0.2em;
228 }
229}
230@media all and (min-width: 481px) and (max-width: 768px) {
231 .toast-container .ngx-toastr.div {
232 padding: 15px 15px 15px 50px;
233 width: 25em;
234 }
235}