rails_toastify 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +8 -0
- data/app/assets/javascripts/rails_toastify.js +21 -9
- data/app/assets/stylesheets/rails_toastify.css +2 -1
- 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
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
|
-
|
|
7
|
+
|
|
8
|
+
let timeoutId = setTimeout(() => {
|
|
8
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,26 +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
67
|
});
|
|
@@ -20,6 +20,7 @@
|
|
|
20
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 {
|
|
@@ -86,7 +87,7 @@
|
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
.toast {
|
|
89
|
-
@apply flex items-center bg-white rounded-lg shadow-lg p-4 my-2 text-gray-800 relative max-w-sm;
|
|
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;
|
|
90
91
|
transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
|
|
91
92
|
transform: translateX(100%);
|
|
92
93
|
}
|