Wrap flash messages in a div instead of a paragraph

This allows more complex HTML in the message, closing #896.
This commit is contained in:
Tom Hughes 2015-02-11 21:26:22 +00:00
parent d5e90c0d87
commit 27179c8706
3 changed files with 27 additions and 20 deletions

View file

@ -1746,19 +1746,26 @@ header .search_form {
/* Rules for "flash" notice boxes shown at the top of the content area */
.error {
.flash {
padding: $lineheight;
background-color: #ff7070;
}
.warning {
padding: $lineheight;
background-color: #ffe0cc;
}
&.error {
background-color: #ff7070;
}
.notice {
padding: $lineheight;
background-color: #CBEEA7;
&.warning {
background-color: #ffe0cc;
}
&.notice {
background-color: #CBEEA7;
}
div.message {
display: inline-block;
margin-left: $lineheight / 2;
vertical-align: middle;
}
}
/* Rules for highlighting fields with rails validation errors */

View file

@ -1,20 +1,20 @@
<% if flash[:error] %>
<p class="error">
<div class="flash error">
<%= image_tag("notice.png", :class => "small_icon", :border => 0) %>
<%= raw flash[:error] %>
</p>
<div class="message"><%= raw flash[:error] %></div>
</div>
<% end %>
<% if flash[:warning] %>
<p class="warning">
<div class="flash warning">
<%= image_tag("notice.png", :class => "small_icon", :border => 0) %>
<%= raw flash[:warning] %>
</p>
<div class="message"><%= raw flash[:warning] %></div>
</div>
<% end %>
<% if flash[:notice] %>
<p class="notice">
<div class="flash notice">
<%= image_tag("notice.png", :class => "small_icon", :border => 0) %>
<%= raw flash[:notice] %>
</p>
<div class="message"><%= raw flash[:notice] %></div>
</div>
<% end %>

View file

@ -149,7 +149,7 @@ class MessageControllerTest < ActionController::TestCase
:message => { :title => "Test Message", :body => "Test message body" }
assert_response :success
assert_template "new"
assert_select "p.error", /wait a while/
assert_select ".error", /wait a while/
end
end
end