Skip to content

Commit 86f25c1

Browse files
committed
added a shared _notices partial (DRY)
1 parent cf2217f commit 86f25c1

4 files changed

Lines changed: 15 additions & 22 deletions

File tree

app/views/layouts/application.html.erb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@
1212
<div class="grid">
1313
<div class="grid--cell is-8-lg is-12">
1414
<div class="has-padding-4">
15-
<% {notice: :info, alert: :danger, danger: :danger, success: :success, info: :info, warning: :warning}.each do |mt, cc| %>
16-
<% if flash[mt].present? %>
17-
<div class="notice is-<%= cc.to_s %>">
18-
<%= flash[mt] %>
19-
</div>
20-
<% end %>
21-
<% end %>
15+
<%= render 'shared/notices' %>
2216

2317
<% if @first_visit_notice %>
2418
<% notice = SiteSetting['FirstVisitGuidance'] %>

app/views/layouts/stripe.html.erb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,7 @@
1414
<div class="grid">
1515
<div class="grid--cell is-12">
1616
<div class="has-padding-4">
17-
<% {notice: :info, alert: :danger, danger: :danger, success: :success, info: :info, warning: :warning}.each do |mt, cc| %>
18-
<% if flash[mt].present? %>
19-
<div class="notice is-<%= cc.to_s %>">
20-
<%= flash[mt] %>
21-
</div>
22-
<% end %>
23-
<% end %>
24-
17+
<%= render 'shared/notices' %>
2518

2619
<% if @first_visit_notice %>
2720
<% notice = SiteSetting['FirstVisitGuidance'] %>

app/views/layouts/without_sidebar.html.erb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@
1010
<div class="grid">
1111
<div class="grid--cell is-12">
1212
<div class="has-padding-4">
13-
<% {notice: :info, alert: :danger, danger: :danger, success: :success, info: :info, warning: :warning}.each do |mt, cc| %>
14-
<% if flash[mt].present? %>
15-
<div class="notice is-<%= cc.to_s %>">
16-
<%= flash[mt] %>
17-
</div>
18-
<% end %>
19-
<% end %>
13+
<%= render 'shared/notices' %>
2014

2115
<% if @first_visit_notice %>
2216
<% notice = SiteSetting['FirstVisitGuidance'] %>

app/views/shared/_notices.html.erb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<% { notice: :info,
2+
alert: :danger,
3+
danger: :danger,
4+
success: :success,
5+
info: :info,
6+
warning: :warning }.each do |type, content| %>
7+
<% if flash[type].present? %>
8+
<div class="notice is-<%= content.to_s %>">
9+
<%= flash[type] %>
10+
</div>
11+
<% end %>
12+
<% end %>

0 commit comments

Comments
 (0)