Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix banner overlapping with other content #4080

Merged
merged 4 commits into from
Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/assets/stylesheets/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2287,6 +2287,22 @@ table {
// 18. Banners
// -----------

.banner {

a > * {
@include grid-row;
padding: 0 rem-calc(16);

&:empty {
display: none;
}
}

+ .budget.expanded,
+ .jumbo {
margin-top: 0;
}
}

// 19. Recommendations
// -------------------
Expand Down
3 changes: 3 additions & 0 deletions app/assets/stylesheets/participation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,8 @@
.help-header {
background: #fafafa;
border-bottom: 1px solid #eee;
margin-top: -$line-height;
margin-bottom: $line-height;
padding-bottom: $line-height / 2;
padding-top: $line-height;

Expand Down Expand Up @@ -1142,6 +1144,7 @@

&.budget {
background: $budget;
margin-top: -$line-height;

h1,
h2,
Expand Down
16 changes: 0 additions & 16 deletions app/helpers/banners_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,6 @@ def has_banners?
@banners.present? && @banners.count > 0
end

def banner_default_bg_color
"#e7f2fc"
end

def banner_default_font_color
"#222222"
end

def banner_bg_color_or_default
@banner.background_color.presence || banner_default_bg_color
end

def banner_font_color_or_default
@banner.font_color.presence || banner_default_font_color
end

def banner_target_link(banner)
link_to banner.target_url do
tag.h2(banner.title, style: "color:#{banner.font_color}") +
Expand Down
3 changes: 3 additions & 0 deletions app/models/banner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ class Banner < ApplicationRecord
acts_as_paranoid column: :hidden_at
include ActsAsParanoidAliases

attribute :background_color, default: "#e7f2fc"
attribute :font_color, default: "#222222"

translates :title, touch: true
translates :description, touch: true
include Globalizable
Expand Down
6 changes: 2 additions & 4 deletions app/views/admin/banners/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
<p class="help-text"><%= t("admin.shared.color_help") %></p>
<div class="row collapse">
<div class="small-12 medium-6 column">
<%= f.text_field :background_color, label: false, type: :color,
value: banner_bg_color_or_default %>
<%= f.text_field :background_color, label: false, type: :color %>
</div>
<div class="small-12 medium-6 column">
<%= f.text_field :background_color, label: false, id: "background_color_input" %>
Expand All @@ -70,8 +69,7 @@
<p class="help-text"><%= t("admin.shared.color_help") %></p>
<div class="row collapse">
<div class="small-12 medium-6 column">
<%= f.text_field :font_color, label: false, type: :color,
value: banner_font_color_or_default %>
<%= f.text_field :font_color, label: false, type: :color %>
</div>
<div class="small-12 medium-6 column">
<%= f.text_field :font_color, label: false, id: "font_color_input" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/budgets/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<% end %>

<% if current_budget.present? %>
<div id="budget_heading" class="expanded budget no-margin-top">
<div id="budget_heading" class="expanded budget">
<div class="row" data-equalizer data-equalizer-on="medium">
<div class="small-12 medium-9 column padding" data-equalizer-watch>

Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_section_header.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="help-header no-margin-top margin-bottom">
<div class="help-header">
<div class="row">
<div class="small-12 column" data-magellan>
<%= image_tag "help/help_icon_#{image}.png", alt: t("#{i18n_namespace}.icon_alt"), class: "align-top" %>
Expand Down
7 changes: 7 additions & 0 deletions spec/models/banner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@
it "is valid" do
expect(banner).to be_valid
end

it "assigns default values to new banners" do
banner = Banner.new

expect(banner.background_color).to be_present
expect(banner.font_color).to be_present
end
end