rails_toastify 0.1.7 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -4
- data/README.md +7 -5
- data/app/assets/javascripts/rails_toastify.js +13 -8
- data/app/assets/stylesheets/rails_toastify.css +5 -3
- data/lib/rails_toastify/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfc517981d8a050d33fffb5adb0a1b570991332062839d0f68bc28795c2a36b8
|
4
|
+
data.tar.gz: 291c73972c9f7d278676f95f42153bc2fcddf6bfb78ecb007712abf0c71b49b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e04322f2c8a0c85f4436e3de91ebbe782d23e31965b1ad101cd1ab4c64ebfdfd8a41b05e078ad1cf0e2e0ca68867d538344979b13c88d6f3b6907c41f9d178a
|
7
|
+
data.tar.gz: 23a755965aaa27fb5aa8f33683cbbf701919806310074414faa8831167423237ab0659f30936891c9a7ed079bb24c5f49607b3e033050d16d7fd4cd658b97469
|
data/CHANGELOG.md
CHANGED
@@ -1,19 +1,29 @@
|
|
1
|
-
|
1
|
+
## 1.0.0
|
2
|
+
|
3
|
+
- Version stable tested and approved
|
4
|
+
- Change Changelog
|
5
|
+
- Change Readme
|
6
|
+
|
7
|
+
## 0.1.8
|
8
|
+
|
9
|
+
- Fix progressbar
|
10
|
+
|
11
|
+
## 0.1.7
|
2
12
|
|
3
13
|
- Fix problem with toast disappear when mouseover
|
4
14
|
- Change README
|
5
15
|
|
6
|
-
|
16
|
+
## 0.1.6
|
7
17
|
|
8
18
|
- Fix css and js
|
9
19
|
- Close toast on progress bar finish
|
10
20
|
- Toast appear on top right
|
11
21
|
|
12
|
-
|
22
|
+
## 0.1.5
|
13
23
|
|
14
24
|
- Adjustments CSS progress bar and shadow
|
15
25
|
|
16
|
-
|
26
|
+
## 0.1.4
|
17
27
|
|
18
28
|
- Change CSS
|
19
29
|
- Change JS
|
data/README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# RailsToastify
|
2
2
|
|
3
|
-
**Rails Toastify** allows you to easily add notifications to your app. Please
|
3
|
+
**Rails Toastify** allows you to easily add notifications to your app. Please CONTRIBUTE.
|
4
4
|
|
5
5
|
The **Rails Toastify** gem is completely inspired by the [React Toastify](https://fkhadra.github.io/react-toastify/introduction/) lib and is specially made for those React developers who are migrating to Rails thanks to Hotwire or for any other reason, and who love using Toasts and wanted a gem that makes it as easy as it is in React. 🎉
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
Add gem in your Gemfile:
|
10
|
+
|
10
11
|
```ruby
|
11
12
|
gem 'rails_toastify'
|
12
13
|
```
|
@@ -28,17 +29,18 @@ end
|
|
28
29
|
|
29
30
|
## Usage
|
30
31
|
|
31
|
-
In your *application.html.erb* add:
|
32
|
+
In your *application.html.erb* add in your header:
|
32
33
|
|
33
34
|
```ruby
|
34
35
|
<%= stylesheet_link_tag 'rails_toastify', media: 'all' %>
|
35
36
|
<%= javascript_include_tag 'rails_toastify' %>
|
36
37
|
```
|
37
|
-
And:
|
38
|
+
And in your body:
|
38
39
|
|
39
40
|
```html
|
40
41
|
<div id="toast-container" class="toast-container"></div>
|
41
42
|
```
|
43
|
+
*
|
42
44
|
|
43
45
|
In your *config/manifest.js* add:
|
44
46
|
|
@@ -47,7 +49,7 @@ In your *config/manifest.js* add:
|
|
47
49
|
//= link rails_toastify.js
|
48
50
|
```
|
49
51
|
|
50
|
-
And call function `RailsToastify.showToast` any javascript:
|
52
|
+
And call function `RailsToastify.showToast` any javascript or console:
|
51
53
|
|
52
54
|
```ruby
|
53
55
|
RailsToastify.showToast('This is a success message!', 'success');
|
@@ -73,7 +75,7 @@ To see notice in a toast add:
|
|
73
75
|
|
74
76
|
Fork, fix, then send a pull request. Bug reports and pull requests are welcome on GitHub at **https://github.com/eltonsantos/rails_toastify**.
|
75
77
|
|
76
|
-
##
|
78
|
+
## License
|
77
79
|
|
78
80
|
This gem is available as open-source under the terms of The MIT License (MIT).
|
79
81
|
|
@@ -5,22 +5,27 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
5
5
|
const toast = createToast(message, type, duration);
|
6
6
|
toastContainer.appendChild(toast);
|
7
7
|
|
8
|
-
let
|
8
|
+
let startTime = Date.now();
|
9
|
+
let remainingTime = duration;
|
10
|
+
|
11
|
+
const hideToast = () => {
|
9
12
|
toast.classList.add('hide');
|
10
13
|
toast.addEventListener('transitionend', () => toast.remove());
|
11
|
-
}
|
14
|
+
};
|
15
|
+
|
16
|
+
let timeoutId = setTimeout(hideToast, remainingTime);
|
12
17
|
|
13
18
|
toast.addEventListener('mouseover', () => {
|
14
19
|
clearTimeout(timeoutId);
|
15
|
-
|
20
|
+
const elapsedTime = Date.now() - startTime;
|
21
|
+
remainingTime -= elapsedTime;
|
22
|
+
toast.querySelector('.toast__progress-bar').style.animationPlayState = 'paused';
|
16
23
|
});
|
17
24
|
|
18
25
|
toast.addEventListener('mouseout', () => {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
toast.addEventListener('transitionend', () => toast.remove());
|
23
|
-
}, duration - progressBar.getBoundingClientRect().width * (duration / progressBar.offsetWidth));
|
26
|
+
startTime = Date.now();
|
27
|
+
toast.querySelector('.toast__progress-bar').style.animationPlayState = 'running';
|
28
|
+
timeoutId = setTimeout(hideToast, remainingTime);
|
24
29
|
});
|
25
30
|
}
|
26
31
|
};
|
@@ -20,7 +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;
|
23
|
+
pointer-events: auto;
|
24
24
|
}
|
25
25
|
|
26
26
|
.toast.show {
|
@@ -71,6 +71,7 @@
|
|
71
71
|
width: 100%;
|
72
72
|
height: 4px;
|
73
73
|
animation: progress-bar 5s linear forwards;
|
74
|
+
animation-play-state: running;
|
74
75
|
}
|
75
76
|
|
76
77
|
@keyframes progress-bar {
|
@@ -91,11 +92,11 @@
|
|
91
92
|
transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
|
92
93
|
transform: translateX(100%);
|
93
94
|
}
|
94
|
-
|
95
|
+
|
95
96
|
.toast.show {
|
96
97
|
transform: translateX(0);
|
97
98
|
}
|
98
|
-
|
99
|
+
|
99
100
|
.toast.hide {
|
100
101
|
transform: translateX(100%);
|
101
102
|
opacity: 0;
|
@@ -127,6 +128,7 @@
|
|
127
128
|
.toast__progress-bar {
|
128
129
|
@apply absolute bottom-0 left-0 w-full h-1;
|
129
130
|
animation: progress-bar 5s linear forwards;
|
131
|
+
animation-play-state: running;
|
130
132
|
}
|
131
133
|
|
132
134
|
@keyframes progress-bar {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_toastify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elton Santos
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "\U0001F389 Rails Toastify allows you to add notifications to your app
|
14
14
|
with ease. Pay Attention: this gem still is in development. Please CONTRIBUTE"
|