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

Create custom shared header view #163

Merged
merged 1 commit into from
Apr 10, 2024
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
27 changes: 27 additions & 0 deletions app/views/custom/shared/_header.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<% if header.present? %>
<% if header.image.present? && header.background_image? %>
<div id="header_background_image" class="jumbo highlight"
style="background-image: url(<%= polymorphic_path(header.image.attachment) %>)">

<%= render "shared/header_content", header: header %>
</div>
<% elsif header.image.present? %>
<div class="header-card jumbo highlight">
<div class="row">
<%= render "shared/header_content", header: header %>

<div id="header_image" class="small-12 medium-6 column">
<%= image_tag(header.image.variant(:large),
class: "margin",
alt: header.image.title) %>
</div>
</div>
</div>
<% else %>
<div class="header-card jumbo highlight">
<div class="row">
<%= render "shared/header_content", header: header %>
</div>
</div>
<% end %>
<% end %>
36 changes: 18 additions & 18 deletions app/views/shared/_header.html.erb
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<% if header.present? %>
<% if header.image.present? && header.background_image? %>
<div id="header_background_image" class="jumbo highlight"
style="background-image: url(<%= polymorphic_path(header.image.attachment) %>)">
<div class="header-card jumbo highlight">
<div class="row">
<div class="small-12 medium-6 column <%= "medium-9 small-centered text-center" if header.image.blank? %>">
<span><%= header.label %></span>
<h1><%= header.title %></h1>

<%= render "shared/header_content", header: header %>
</div>
<% elsif header.image.present? %>
<div class="header-card jumbo highlight">
<div class="row">
<%= render "shared/header_content", header: header %>
<p class="lead"><%= header.description %></p>

<% if header.link_text.present? && header.link_url.present? %>
<div class="small-12 medium-6 large-4 <%= "small-centered" if header.image.blank? %>">
<%= link_to header.link_text, header.link_url, class: "button expanded large" %>
</div>
<% end %>
</div>

<div id="header_image" class="small-12 medium-6 column">
<% if header.image.present? %>
<div class="small-12 medium-6 column">
<%= image_tag(header.image.variant(:large),
class: "margin",
alt: header.image.title) %>
</div>
</div>
</div>
<% else %>
<div class="header-card jumbo highlight">
<div class="row">
<%= render "shared/header_content", header: header %>
</div>
<% end %>
</div>
<% end %>
</div>
<div class="background-header"></div>
<% end %>
4 changes: 2 additions & 2 deletions app/views/shared/_header_content.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div class="small-12 medium-6 column <%= "medium-9 small-centered text-center" if header.image.blank? %>">
<div class="small-12 medium-6 column">
<span><%= header.label %></span>
<h1><%= header.title %></h1>

<%= auto_link_already_sanitized_html AdminWYSIWYGSanitizer.new.sanitize(header.description) %>

<% if header.link_text.present? && header.link_url.present? %>
<div class="small-12 medium-6 large-4 <%= "small-centered" if header.image.blank? %>">
<div class="small-12 medium-6">
<%= link_to header.link_text, header.link_url, class: "button expanded large margin-top" %>
</div>
<% end %>
Expand Down
Loading