rails_toastify 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c9016ace17fcc8e2c9752befff1bb4dbe57a9759016fcaf4645fad02f747da2
4
- data.tar.gz: d53c5284e34737ba275d1a2938dd281fdfa49157b75820565070fbdbf4c63bf7
3
+ metadata.gz: 041d336902b6df731f5af562e2277cd7a3553e8a3f1993e6c3b9616b1c356605
4
+ data.tar.gz: 21e63fa2d7676cb312449e2b9d56eefb5129ecbdff0e04b30b53dd6b9a3658fe
5
5
  SHA512:
6
- metadata.gz: a56648ac935a1a150cdf1833b520e6666aed710930b174bb81b3ad030de8a617f1bf553061ecc0f7c3600c9b45309c18b143a8a9ac7fb7bb073eecc792b6dbde
7
- data.tar.gz: cc9cbaec8bd2eb43bff831ce1922abd37cd5946e12c8f8d20e0309f191db50866eaaac49fa47954adb65b23a569956717d8821102d02e2103319609a946f561d
6
+ metadata.gz: 689f7d721c8a252f8fd37bd2dbdbcbcf6c3f5d937a11fb1c54394d124ca80f306d0b0a99a2b9e54a3a7f84a5073b62e8a2df4dc5d0e2e07b2578dd088573dd6d
7
+ data.tar.gz: 9a3167a81c64d577366013c6f3075773f30ad6d747b7dd0fcf5ec7eee5e5e65afc213da6c6c930c896bfefaaf8131f91be3297c1a3ff329be3c0ddfbc8c68840
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.1.7
2
+
3
+ - Fix problem with toast disappear when mouseover
4
+ - Change README
5
+
1
6
  # 0.1.6
2
7
 
3
8
  - Fix css and js
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
- setTimeout(() => {
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
- toast.addEventListener('mouseover', () => progressBar.style.animationPlayState = 'paused');
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
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsToastify
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_toastify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elton Santos