rails_toastify 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/MIT-LICENSE.md +5 -0
- data/README.md +29 -15
- data/app/assets/javascripts/rails_toastify.js +27 -0
- data/app/assets/stylesheets/rails_toastify.css +32 -0
- data/lib/rails_toastify/engine.rb +4 -0
- data/lib/rails_toastify/version.rb +1 -1
- data/lib/rails_toastify.rb +1 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3251764a4055f5f57e1c709ac9ced12e5842374cc189a725f0963cef27a3958c
|
4
|
+
data.tar.gz: cbacb64c366911555660d8e755ca6532301a06f77066a9815f5a2aee107bab52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 588ffa8f5ebc8059df077e29adc6daa20ac602fc54ebef9ca9ba55499817c2dac4243eb17923fc1bb0c38f8a99823ad9f68048bbf8211c5aad18928db8cf456d
|
7
|
+
data.tar.gz: 55c50bd63963810c8ff3db7bb4b014f4b22859b5bada19b07abcf3b8f82012dbfb5225ab45dae0a394b6ecb798a0f1e9dacf33900b62f373a76e4e5ec24448e6
|
data/CHANGELOG.md
ADDED
data/MIT-LICENSE.md
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
2
|
+
|
3
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
4
|
+
|
5
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,31 +1,45 @@
|
|
1
1
|
# RailsToastify
|
2
2
|
|
3
|
-
|
3
|
+
**Rails Toastify** allows you to easily add notifications to your app. Please note: this gem is still under development. 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
|
+
```ruby
|
11
|
+
gem 'rails_toastify'
|
12
|
+
```
|
13
|
+
and run **bundle install**
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
15
|
+
## Usage
|
14
16
|
|
15
|
-
|
17
|
+
In your *application.html.erb* add:
|
16
18
|
|
17
|
-
|
19
|
+
```ruby
|
20
|
+
<%= stylesheet_link_tag 'rails_toastify', media: 'all' %>
|
21
|
+
<%= javascript_include_tag 'rails_toastify' %>
|
22
|
+
```
|
23
|
+
And call function `RailsToastify.showToast` any javascript:
|
18
24
|
|
19
|
-
|
25
|
+
```ruby
|
26
|
+
RailsToastify.showToast('This is a success message!', 'success');
|
27
|
+
RailsToastify.showToast('This is an error message!', 'error');
|
28
|
+
RailsToastify.showToast('This is an info message!', 'info');
|
29
|
+
RailsToastify.showToast('This is a warning message!', 'warning');
|
30
|
+
```
|
20
31
|
|
21
|
-
|
32
|
+
## Requirements
|
22
33
|
|
23
|
-
|
34
|
+
- Ruby >= 2.6.0 (recommended 2.7+)
|
35
|
+
- Rails >= 6.0 (compatible up to Rails 7)
|
36
|
+
|
37
|
+
## Contributing to Rails Toastify
|
24
38
|
|
25
|
-
|
39
|
+
Fork, fix, then send a pull request. Bug reports and pull requests are welcome on GitHub at **https://github.com/eltonsantos/rails_toastify**.
|
26
40
|
|
27
|
-
|
41
|
+
## Licence
|
28
42
|
|
29
|
-
|
43
|
+
This gem is available as open-source under the terms of The MIT License (MIT).
|
30
44
|
|
31
|
-
|
45
|
+
Copyright (c) 2024 **Elton Santos**. See **MIT-LICENSE** for further details.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
document.addEventListener('DOMContentLoaded', () => {
|
2
|
+
window.RailsToastify = {
|
3
|
+
showToast(message, type = 'info', duration = 3000) {
|
4
|
+
const toastContainer = document.querySelector('.toast-container') || createToastContainer();
|
5
|
+
const toast = createToast(message, type);
|
6
|
+
toastContainer.appendChild(toast);
|
7
|
+
setTimeout(() => {
|
8
|
+
toast.classList.add('fade-out');
|
9
|
+
toast.addEventListener('transitionend', () => toast.remove());
|
10
|
+
}, duration);
|
11
|
+
}
|
12
|
+
};
|
13
|
+
|
14
|
+
function createToastContainer() {
|
15
|
+
const container = document.createElement('div');
|
16
|
+
container.className = 'toast-container';
|
17
|
+
document.body.appendChild(container);
|
18
|
+
return container;
|
19
|
+
}
|
20
|
+
|
21
|
+
function createToast(message, type) {
|
22
|
+
const toast = document.createElement('div');
|
23
|
+
toast.className = `toast toast--${type}`;
|
24
|
+
toast.textContent = message;
|
25
|
+
return toast;
|
26
|
+
}
|
27
|
+
});
|
@@ -0,0 +1,32 @@
|
|
1
|
+
.toast-container {
|
2
|
+
position: fixed;
|
3
|
+
z-index: 9999;
|
4
|
+
pointer-events: none;
|
5
|
+
}
|
6
|
+
|
7
|
+
.toast {
|
8
|
+
display: flex;
|
9
|
+
align-items: center;
|
10
|
+
background-color: #fff;
|
11
|
+
border-radius: 4px;
|
12
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
13
|
+
padding: 16px;
|
14
|
+
margin: 8px;
|
15
|
+
color: #333;
|
16
|
+
}
|
17
|
+
|
18
|
+
.toast--success {
|
19
|
+
border-left: 5px solid #4caf50;
|
20
|
+
}
|
21
|
+
|
22
|
+
.toast--error {
|
23
|
+
border-left: 5px solid #f44336;
|
24
|
+
}
|
25
|
+
|
26
|
+
.toast--info {
|
27
|
+
border-left: 5px solid #2196f3;
|
28
|
+
}
|
29
|
+
|
30
|
+
.toast--warning {
|
31
|
+
border-left: 5px solid #ff9800;
|
32
|
+
}
|
data/lib/rails_toastify.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.2
|
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-06-
|
11
|
+
date: 2024-06-25 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"
|
@@ -18,9 +18,14 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
+
- CHANGELOG.md
|
22
|
+
- MIT-LICENSE.md
|
21
23
|
- README.md
|
22
24
|
- Rakefile
|
25
|
+
- app/assets/javascripts/rails_toastify.js
|
26
|
+
- app/assets/stylesheets/rails_toastify.css
|
23
27
|
- lib/rails_toastify.rb
|
28
|
+
- lib/rails_toastify/engine.rb
|
24
29
|
- lib/rails_toastify/version.rb
|
25
30
|
- rails_toastify.gemspec
|
26
31
|
- sig/rails_toastify.rbs
|