Skip to content

๐ŸŽ‰ Rails Toastify allows you to add notifications to your app with ease. Pay Attention: this gem still is in development. Please CONTRIBUTE

License

Notifications You must be signed in to change notification settings

eltonsantos/rails_toastify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

RailsToastify

Rails Toastify allows you to easily add notifications to your app. Please CONTRIBUTE.

The Rails Toastify gem is completely inspired by the React Toastify 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. ๐ŸŽ‰

Installation

Add gem in your Gemfile:

gem 'rails_toastify'

and run bundle install

After run:

rails generate rails_toastify:install

This will create a file config/initializers/rails_toastify.rb where you can define the framework you want to use:

RailsToastify.configure do |config|
  config.framework = :tailwind # or :bootstrap
end

Usage

In your application.html.erb add in your header:

<%= stylesheet_link_tag 'rails_toastify', media: 'all' %>
<%= javascript_include_tag 'rails_toastify' %>

And in your body:

<div id="toast-container" class="toast-container"></div>

In your config/manifest.js add:

//= link rails_toastify.css
//= link rails_toastify.js

And call function RailsToastify.showToast any javascript or console:

RailsToastify.showToast('This is a success message!', 'success');
RailsToastify.showToast('This is an error message!', 'error');
RailsToastify.showToast('This is an info message!', 'info');
RailsToastify.showToast('This is a warning message!', 'warning');

To see notice in a toast add:

<%= javascript_tag do %>
  RailsToastify.showToast('<%= notice %>', 'success')
<% end %>

Requirements

  • Ruby >= 2.6.0 (recommended 2.7+)
  • Rails >= 6.0 (compatible up to Rails 7)

Contributing to Rails Toastify

Fork, fix, then send a pull request. Bug reports and pull requests are welcome on GitHub at https://github.com/eltonsantos/rails_toastify.

License

This gem is available as open-source under the terms of The MIT License (MIT).

Copyright (c) 2024 Elton Santos. See MIT-LICENSE for further details.

About

๐ŸŽ‰ Rails Toastify allows you to add notifications to your app with ease. Pay Attention: this gem still is in development. Please CONTRIBUTE

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published