rails_toastify 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -1
- data/README.md +8 -0
- data/app/assets/javascripts/rails_toastify.js +22 -11
- data/app/assets/stylesheets/rails_toastify.css +6 -3
- data/lib/rails_toastify/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 041d336902b6df731f5af562e2277cd7a3553e8a3f1993e6c3b9616b1c356605
|
4
|
+
data.tar.gz: 21e63fa2d7676cb312449e2b9d56eefb5129ecbdff0e04b30b53dd6b9a3658fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 689f7d721c8a252f8fd37bd2dbdbcbcf6c3f5d937a11fb1c54394d124ca80f306d0b0a99a2b9e54a3a7f84a5073b62e8a2df4dc5d0e2e07b2578dd088573dd6d
|
7
|
+
data.tar.gz: 9a3167a81c64d577366013c6f3075773f30ad6d747b7dd0fcf5ec7eee5e5e65afc213da6c6c930c896bfefaaf8131f91be3297c1a3ff329be3c0ddfbc8c68840
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,15 @@
|
|
1
|
-
# 0.1.
|
1
|
+
# 0.1.7
|
2
|
+
|
3
|
+
- Fix problem with toast disappear when mouseover
|
4
|
+
- Change README
|
5
|
+
|
6
|
+
# 0.1.6
|
7
|
+
|
8
|
+
- Fix css and js
|
9
|
+
- Close toast on progress bar finish
|
10
|
+
- Toast appear on top right
|
11
|
+
|
12
|
+
# 0.1.5
|
2
13
|
|
3
14
|
- Adjustments CSS progress bar and shadow
|
4
15
|
|
data/README.md
CHANGED
@@ -56,6 +56,14 @@ RailsToastify.showToast('This is an info message!', 'info');
|
|
56
56
|
RailsToastify.showToast('This is a warning message!', 'warning');
|
57
57
|
```
|
58
58
|
|
59
|
+
To see notice in a toast add:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
<%= javascript_tag do %>
|
63
|
+
RailsToastify.showToast('<%= notice %>', 'success')
|
64
|
+
<% end %>
|
65
|
+
```
|
66
|
+
|
59
67
|
## Requirements
|
60
68
|
|
61
69
|
- Ruby >= 2.6.0 (recommended 2.7+)
|
@@ -4,10 +4,24 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
4
4
|
const toastContainer = document.querySelector('.toast-container') || createToastContainer();
|
5
5
|
const toast = createToast(message, type, duration);
|
6
6
|
toastContainer.appendChild(toast);
|
7
|
-
|
8
|
-
|
7
|
+
|
8
|
+
let timeoutId = setTimeout(() => {
|
9
|
+
toast.classList.add('hide');
|
9
10
|
toast.addEventListener('transitionend', () => toast.remove());
|
10
11
|
}, duration);
|
12
|
+
|
13
|
+
toast.addEventListener('mouseover', () => {
|
14
|
+
clearTimeout(timeoutId);
|
15
|
+
progressBar.style.animationPlayState = 'paused';
|
16
|
+
});
|
17
|
+
|
18
|
+
toast.addEventListener('mouseout', () => {
|
19
|
+
progressBar.style.animationPlayState = 'running';
|
20
|
+
timeoutId = setTimeout(() => {
|
21
|
+
toast.classList.add('hide');
|
22
|
+
toast.addEventListener('transitionend', () => toast.remove());
|
23
|
+
}, duration - progressBar.getBoundingClientRect().width * (duration / progressBar.offsetWidth));
|
24
|
+
});
|
11
25
|
}
|
12
26
|
};
|
13
27
|
|
@@ -22,7 +36,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
22
36
|
const toast = document.createElement('div');
|
23
37
|
toast.className = `toast toast--${type}`;
|
24
38
|
toast.classList.add('show');
|
25
|
-
|
39
|
+
|
26
40
|
const closeButton = document.createElement('button');
|
27
41
|
closeButton.className = 'toast__close-button';
|
28
42
|
closeButton.innerHTML = '<svg aria-hidden="true" viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"></path></svg>';
|
@@ -30,27 +44,24 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
30
44
|
toast.classList.add('hide');
|
31
45
|
toast.addEventListener('transitionend', () => toast.remove());
|
32
46
|
});
|
33
|
-
|
47
|
+
|
34
48
|
const progressBar = document.createElement('div');
|
35
49
|
progressBar.className = `toast__progress-bar toast__progress-bar--${type}`;
|
36
50
|
progressBar.style.animationDuration = `${duration}ms`;
|
37
|
-
|
51
|
+
|
38
52
|
const body = document.createElement('div');
|
39
53
|
body.className = 'toast__body';
|
40
54
|
body.textContent = message;
|
41
|
-
|
55
|
+
|
42
56
|
toast.appendChild(body);
|
43
57
|
toast.appendChild(closeButton);
|
44
58
|
toast.appendChild(progressBar);
|
45
|
-
|
59
|
+
|
46
60
|
toast.addEventListener('click', () => {
|
47
61
|
toast.classList.add('hide');
|
48
62
|
toast.addEventListener('transitionend', () => toast.remove());
|
49
63
|
});
|
50
|
-
|
51
|
-
toast.addEventListener('mouseout', () => progressBar.style.animationPlayState = 'running');
|
52
|
-
|
64
|
+
|
53
65
|
return toast;
|
54
66
|
}
|
55
|
-
|
56
67
|
});
|
@@ -17,9 +17,10 @@
|
|
17
17
|
margin: 8px;
|
18
18
|
color: #333;
|
19
19
|
position: relative;
|
20
|
-
transition: transform 0.
|
20
|
+
transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
|
21
21
|
transform: translateX(100%);
|
22
22
|
max-width: 300px;
|
23
|
+
pointer-events: auto; /* Para permitir interações do mouse */
|
23
24
|
}
|
24
25
|
|
25
26
|
.toast.show {
|
@@ -28,6 +29,7 @@
|
|
28
29
|
|
29
30
|
.toast.hide {
|
30
31
|
transform: translateX(100%);
|
32
|
+
opacity: 0;
|
31
33
|
}
|
32
34
|
|
33
35
|
.toast--success .toast__progress-bar {
|
@@ -85,8 +87,8 @@
|
|
85
87
|
}
|
86
88
|
|
87
89
|
.toast {
|
88
|
-
@apply flex items-center bg-white rounded-lg shadow-lg p-4 my-2 text-gray-800 relative max-w-sm;
|
89
|
-
transition: transform 0.
|
90
|
+
@apply flex items-center bg-white rounded-lg shadow-lg p-4 my-2 text-gray-800 relative max-w-sm pointer-events-auto;
|
91
|
+
transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
|
90
92
|
transform: translateX(100%);
|
91
93
|
}
|
92
94
|
|
@@ -96,6 +98,7 @@
|
|
96
98
|
|
97
99
|
.toast.hide {
|
98
100
|
transform: translateX(100%);
|
101
|
+
opacity: 0;
|
99
102
|
}
|
100
103
|
|
101
104
|
.toast--success .toast__progress-bar {
|