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

Use SkipLinkComponent for Blacklight 8 #3240

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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/components/spotlight/skip_link_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

module Spotlight
# Blacklight Skip Link Component with conditional search link for Spotlight
class SkipLinkComponent < Blacklight::SkipLinkComponent
def initialize(render_search_link: true)
@render_search_link = render_search_link

super
end

def link_to_search
super if @render_search_link
end
end
end
9 changes: 2 additions & 7 deletions app/views/layouts/spotlight/base.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,9 @@
</head>
<body class="<%= render_body_class %>">
<%= render partial: 'shared/body_preamble' %>
<div id="skip-link">
<% if should_render_spotlight_search_bar? %>
<%= link_to t('blacklight.skip_links.search_field'), '#search_field', class: 'btn btn-link bg-light sr-only sr-only-focusable visually-hidden-focusable' %>
<% end %>
<%= link_to t('blacklight.skip_links.main_content'), '#main-container', class: 'btn btn-link bg-light sr-only sr-only-focusable visually-hidden-focusable' %>
<%= render blacklight_config.skip_link_component.new(render_search_link: should_render_spotlight_search_bar?) do %>
<%= content_for(:skip_links) %>
</div>

<% end %>
<%= render partial: 'shared/header_navbar' %>
<%= render partial: 'shared/masthead' %>
<%= content_for?(:header_content) ? yield(:header_content) : "" %>
Expand Down
1 change: 1 addition & 0 deletions lib/spotlight/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def self.call(template, source = nil)

Blacklight::Configuration.default_values[:search_state_fields] ||= []
Blacklight::Configuration.default_values[:search_state_fields] += %i[id exhibit_id browse_category_id]
Blacklight::Configuration.default_values[:skip_link_component] = Spotlight::SkipLinkComponent
end
else
config.to_prepare do
Expand Down