rails_toastify 0.1.2 → 0.1.3
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 +9 -0
- data/README.md +27 -0
- data/app/assets/stylesheets/rails_toastify.css +60 -32
- data/lib/generators/rails_toastify/install/install_generator.rb +13 -0
- data/lib/generators/rails_toastify/install/templates/rails_toastify.rb +3 -0
- data/lib/rails_toastify/engine.rb +3 -0
- data/lib/rails_toastify/version.rb +1 -1
- data/lib/rails_toastify.rb +17 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4c911f3af15f4890c1444105b9f61e171df86f803c36b673664876fd1b5df78
|
4
|
+
data.tar.gz: 925b7c0a30747f92a1e9f2bf7d1ee306a000a445e7d35722c35b35dcb79bd87a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 928bab3cac6f526bb1b5261a5fbedb31e33412e335344e60a377c6500c17c14496af4fbe85fb8fa4c8ce7856f29678bf386d38689a431a1cff318872dab7b11b
|
7
|
+
data.tar.gz: 4af1c98f67a8b37f05089c8d11060398a7a0046dcfd8c6d5d9361e93eff8a2a6c28eef410eb24247eda7f105c3683501bfc9bb63931c38c8f6ccd724c87313bf
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -12,6 +12,20 @@ gem 'rails_toastify'
|
|
12
12
|
```
|
13
13
|
and run **bundle install**
|
14
14
|
|
15
|
+
After run:
|
16
|
+
|
17
|
+
```sh
|
18
|
+
rails generate rails_toastify:install
|
19
|
+
```
|
20
|
+
|
21
|
+
This will create a file *config/initializers/rails_toastify.rb* where you can define the framework you want to use:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
RailsToastify.configure do |config|
|
25
|
+
config.framework = :tailwind # or :bootstrap
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
15
29
|
## Usage
|
16
30
|
|
17
31
|
In your *application.html.erb* add:
|
@@ -20,6 +34,19 @@ In your *application.html.erb* add:
|
|
20
34
|
<%= stylesheet_link_tag 'rails_toastify', media: 'all' %>
|
21
35
|
<%= javascript_include_tag 'rails_toastify' %>
|
22
36
|
```
|
37
|
+
And:
|
38
|
+
|
39
|
+
```html
|
40
|
+
<div id="toast-container" class="toast-container"></div>
|
41
|
+
```
|
42
|
+
|
43
|
+
In your *config/manifest.js* add:
|
44
|
+
|
45
|
+
```js
|
46
|
+
//= link rails_toastify.css
|
47
|
+
//= link rails_toastify.js
|
48
|
+
```
|
49
|
+
|
23
50
|
And call function `RailsToastify.showToast` any javascript:
|
24
51
|
|
25
52
|
```ruby
|
@@ -1,32 +1,60 @@
|
|
1
|
-
.
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
1
|
+
<% if RailsToastify.configuration.framework == :bootstrap %>
|
2
|
+
.toast-container {
|
3
|
+
position: fixed;
|
4
|
+
z-index: 9999;
|
5
|
+
pointer-events: none;
|
6
|
+
top: 20px;
|
7
|
+
right: 20px;
|
8
|
+
}
|
9
|
+
|
10
|
+
.toast {
|
11
|
+
display: flex;
|
12
|
+
align-items: center;
|
13
|
+
background-color: #fff;
|
14
|
+
border-radius: 4px;
|
15
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
16
|
+
padding: 16px;
|
17
|
+
margin: 8px;
|
18
|
+
color: #333;
|
19
|
+
}
|
20
|
+
|
21
|
+
.toast--success {
|
22
|
+
border-left: 5px solid #4caf50;
|
23
|
+
}
|
24
|
+
|
25
|
+
.toast--error {
|
26
|
+
border-left: 5px solid #f44336;
|
27
|
+
}
|
28
|
+
|
29
|
+
.toast--info {
|
30
|
+
border-left: 5px solid #2196f3;
|
31
|
+
}
|
32
|
+
|
33
|
+
.toast--warning {
|
34
|
+
border-left: 5px solid #ff9800;
|
35
|
+
}
|
36
|
+
<% elsif RailsToastify.configuration.framework == :tailwind %>
|
37
|
+
.toast-container {
|
38
|
+
@apply fixed z-50 pointer-events-none top-4 right-4;
|
39
|
+
}
|
40
|
+
|
41
|
+
.toast {
|
42
|
+
@apply flex items-center bg-white rounded shadow p-4 my-2 text-gray-800;
|
43
|
+
}
|
44
|
+
|
45
|
+
.toast--success {
|
46
|
+
@apply border-l-4 border-green-500;
|
47
|
+
}
|
48
|
+
|
49
|
+
.toast--error {
|
50
|
+
@apply border-l-4 border-red-500;
|
51
|
+
}
|
52
|
+
|
53
|
+
.toast--info {
|
54
|
+
@apply border-l-4 border-blue-500;
|
55
|
+
}
|
56
|
+
|
57
|
+
.toast--warning {
|
58
|
+
@apply border-l-4 border-yellow-500;
|
59
|
+
}
|
60
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module RailsToastify
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('templates', __dir__)
|
5
|
+
|
6
|
+
desc "Create RailsToastify config"
|
7
|
+
|
8
|
+
def create_config_file
|
9
|
+
copy_file "rails_toastify.rb", "config/initializers/rails_toastify.rb"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/rails_toastify.rb
CHANGED
@@ -4,6 +4,22 @@ require_relative "rails_toastify/version"
|
|
4
4
|
require_relative "rails_toastify/engine"
|
5
5
|
|
6
6
|
module RailsToastify
|
7
|
+
class << self
|
8
|
+
attr_accessor :configuration
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.setup
|
12
|
+
self.configuration ||= Configuration.new
|
13
|
+
yield(configuration)
|
14
|
+
end
|
15
|
+
|
16
|
+
class Configuration
|
17
|
+
attr_accessor :framework
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
@framework = :tailwind
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
7
24
|
class Error < StandardError; end
|
8
|
-
# Your code goes here...
|
9
25
|
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.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elton Santos
|
@@ -24,6 +24,8 @@ files:
|
|
24
24
|
- Rakefile
|
25
25
|
- app/assets/javascripts/rails_toastify.js
|
26
26
|
- app/assets/stylesheets/rails_toastify.css
|
27
|
+
- lib/generators/rails_toastify/install/install_generator.rb
|
28
|
+
- lib/generators/rails_toastify/install/templates/rails_toastify.rb
|
27
29
|
- lib/rails_toastify.rb
|
28
30
|
- lib/rails_toastify/engine.rb
|
29
31
|
- lib/rails_toastify/version.rb
|