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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15bb2821e582dbb096ce2cece0f0f40dab03f2596adaf264eefe930243690d7c
4
- data.tar.gz: cb87d2f3bb44533969bc8933a625a5cb210aa80d738cdb83e7f82e756318f03a
3
+ metadata.gz: 3251764a4055f5f57e1c709ac9ced12e5842374cc189a725f0963cef27a3958c
4
+ data.tar.gz: cbacb64c366911555660d8e755ca6532301a06f77066a9815f5a2aee107bab52
5
5
  SHA512:
6
- metadata.gz: 2868b8b9771a26dca581dab27df5eb483e4773350a8c38fdd30deaecabdc8bac4657c45468d32358e8c83ee3afc85a0854d239bf7ee876076254217e999233a8
7
- data.tar.gz: 22db02499c2e62c068dd0b7a12e804092225708305b9c1c791c1af8b63ee279c1db62b4a99562896c4431764f2dfc8cbc8a1a1aa37cbd1215e3235c3356caf6a
6
+ metadata.gz: 588ffa8f5ebc8059df077e29adc6daa20ac602fc54ebef9ca9ba55499817c2dac4243eb17923fc1bb0c38f8a99823ad9f68048bbf8211c5aad18928db8cf456d
7
+ data.tar.gz: 55c50bd63963810c8ff3db7bb4b014f4b22859b5bada19b07abcf3b8f82012dbfb5225ab45dae0a394b6ecb798a0f1e9dacf33900b62f373a76e4e5ec24448e6
data/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ ## 0.1.2
2
+
3
+ - Change README
4
+ - Add CHANGELOG
5
+ - Add MIT LICENSE
6
+ - Create Engine
7
+ - Create Javascript
8
+ - Create Style
9
+
10
+ ## 0.1.1
11
+
12
+ - Add basic structure
13
+
14
+ ## 0.1.0
15
+
16
+ - First release
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
- TODO: Delete this and the text below, and describe your gem
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
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rails_toastify`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
9
+ Add gem in your Gemfile:
10
+ ```ruby
11
+ gem 'rails_toastify'
12
+ ```
13
+ and run **bundle install**
10
14
 
11
- Install the gem and add to the application's Gemfile by executing:
12
-
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
+ ## Usage
14
16
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
17
+ In your *application.html.erb* add:
16
18
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
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
- ## Usage
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
- TODO: Write usage instructions here
32
+ ## Requirements
22
33
 
23
- ## Development
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
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+ ## Licence
28
42
 
29
- ## Contributing
43
+ This gem is available as open-source under the terms of The MIT License (MIT).
30
44
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rails_toastify.
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
+ }
@@ -0,0 +1,4 @@
1
+ module RailsToastify
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsToastify
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "rails_toastify/version"
4
+ require_relative "rails_toastify/engine"
4
5
 
5
6
  module RailsToastify
6
7
  class Error < StandardError; end
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.0
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-23 00:00:00.000000000 Z
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