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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3251764a4055f5f57e1c709ac9ced12e5842374cc189a725f0963cef27a3958c
4
- data.tar.gz: cbacb64c366911555660d8e755ca6532301a06f77066a9815f5a2aee107bab52
3
+ metadata.gz: a4c911f3af15f4890c1444105b9f61e171df86f803c36b673664876fd1b5df78
4
+ data.tar.gz: 925b7c0a30747f92a1e9f2bf7d1ee306a000a445e7d35722c35b35dcb79bd87a
5
5
  SHA512:
6
- metadata.gz: 588ffa8f5ebc8059df077e29adc6daa20ac602fc54ebef9ca9ba55499817c2dac4243eb17923fc1bb0c38f8a99823ad9f68048bbf8211c5aad18928db8cf456d
7
- data.tar.gz: 55c50bd63963810c8ff3db7bb4b014f4b22859b5bada19b07abcf3b8f82012dbfb5225ab45dae0a394b6ecb798a0f1e9dacf33900b62f373a76e4e5ec24448e6
6
+ metadata.gz: 928bab3cac6f526bb1b5261a5fbedb31e33412e335344e60a377c6500c17c14496af4fbe85fb8fa4c8ce7856f29678bf386d38689a431a1cff318872dab7b11b
7
+ data.tar.gz: 4af1c98f67a8b37f05089c8d11060398a7a0046dcfd8c6d5d9361e93eff8a2a6c28eef410eb24247eda7f105c3683501bfc9bb63931c38c8f6ccd724c87313bf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.1.3
2
+
3
+ - Change README
4
+ - Load configs on module RailsToastify
5
+ - Change engine to add initializer
6
+ - Add style for tailwind template
7
+ - Add generator
8
+ - Add template
9
+
1
10
  ## 0.1.2
2
11
 
3
12
  - Change README
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
- .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
- }
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
@@ -0,0 +1,3 @@
1
+ RailsToastify.setup do |config|
2
+ config.framework = :tailwind #or :bootstrap
3
+ end
@@ -1,4 +1,7 @@
1
1
  module RailsToastify
2
2
  class Engine < ::Rails::Engine
3
+ initializer 'rails_toastify.assets.precompile' do |app|
4
+ app.config.assets.precompile += %w(rails_toastify.js rails_toastify.css)
5
+ end
3
6
  end
4
7
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsToastify
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
@@ -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.2
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