mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-24 11:10:12 +01:00
Add flash styling of the login page.
This commit is contained in:
parent
37c61fa60a
commit
a07567086c
3 changed files with 38 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ body {
|
|||
@include make-xs-column(12);
|
||||
@include make-sm-column(6);
|
||||
@include make-sm-column-offset(3);
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.login-wrapper {
|
||||
|
|
|
|||
36
app/helpers/bootstrap_flash_helper.rb
Normal file
36
app/helpers/bootstrap_flash_helper.rb
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
module BootstrapFlashHelper
|
||||
ALERT_MAPPING = {
|
||||
:notice => :success,
|
||||
:alert => :danger,
|
||||
:error => :danger,
|
||||
:info => :info,
|
||||
:warning => :warning
|
||||
} unless const_defined?(:ALERT_MAPPING)
|
||||
|
||||
def bootstrap_flash(options = {:close_button => true})
|
||||
flash_messages = []
|
||||
flash.each do |type, message|
|
||||
# Skip empty messages, e.g. for devise messages set to nothing in a locale file.
|
||||
next if message.blank?
|
||||
type = type.to_sym
|
||||
next unless ALERT_MAPPING.keys.include?(type)
|
||||
|
||||
|
||||
tag_class = options.extract!(:class)[:class]
|
||||
tag_options = {
|
||||
class: "alert fade in alert-#{ALERT_MAPPING[type]} #{tag_class}"
|
||||
}.merge(options)
|
||||
|
||||
close_button = ""
|
||||
if options[:close_button]
|
||||
close_button = content_tag(:button, raw("×"), type: "button", class: "close", "data-dismiss" => "alert")
|
||||
end
|
||||
|
||||
Array(message).each do |msg|
|
||||
text = content_tag(:div, close_button + msg, tag_options)
|
||||
flash_messages << text if msg
|
||||
end
|
||||
end
|
||||
flash_messages.join("\n").html_safe
|
||||
end
|
||||
end
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="login-flash">
|
||||
<%= render_flash %>
|
||||
<%= bootstrap_flash :close_button => false %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="login-wrapper">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue