0.0
No commit activity in last 3 years
No release in over 3 years
Simple gem for alerts messages
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1
>= 3.0.0, ~> 3.0
>= 6.0, < 7
>= 12.3.3
~> 2.53, >= 2.53.4
 Project Readme

Alert Message

Gem Version Build Status

This is a simple gem for alerts messages.

Installation

Add to your Gemfile:

gem 'alert_message'

Then run:

$ bundle install

Run install script:

$ rails g alert_message:install

Add styles in app/assets/application.css

*= require alert_message

** For less than Rails 6 ** Add scripts in app/assets/application.js

//= require alert_message

For greater than Rails 6 add in app\javascript\packs\application.js

document.addEventListener('DOMContentLoaded', () => {
  let alertMessage = document.getElementById('alert');
  
  alertMessage.classList.add('alert-message--visible');
  
  setTimeout((() => {
    alertMessage.classList.remove('alert-message--visible');
  }), 10000);
  
  alertMessage.addEventListener('click', () => {
    alertMessage.classList.remove('alert-message--visible');
  });
});

How to use

Add in app/views/layouts/application.html.erb

<%= render "layouts/alerts" %>

To show your alerts, use:

flash[:error] = "YOUR MESSAGE"
flash[:notice] = "YOUR MESSAGE"
flash[:success] = "YOUR MESSAGE"

Example

class HomeController < ApplicationController
  def index
    flash[:error] = "YOUR MESSAGE"  
  end
end

Run testes

in progress

Contributing

Welcome to contribute

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

MIT License. Copyright 2014 Luiz Picolo. http://www.luizpicolo.com.br