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

Style bookmark actions as buttons, closes #2272 #2282

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<%= link_to label,
url,
id: @id,
class: 'nav-link',
class: @link_classes,
data: {}.merge(({ blacklight_modal: "trigger" } if @action.modal != false) || {}) %>
<% else %>
<%= @view_context.render(partial: @action.partial || @action.name.to_s, locals: { document: @document, document_action_config: @action }.merge(@options)) %>
Expand Down
3 changes: 2 additions & 1 deletion app/components/blacklight/document/action_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ class ActionComponent < ::ViewComponent::Base
with_collection_parameter :action

# @param [Blacklight::Document] document
def initialize(document:, action:, options: {}, url_opts: {}, id: nil)
def initialize(document:, action:, options: {}, url_opts: {}, id: nil, link_classes: 'nav-link')
@document = document
@action = action
@options = options
@url_opts = url_opts
@id = id || @action.fetch(:id, "#{@action.name}Link")
@link_classes = link_classes
end

def using_default_document_action?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= content_tag @tag, class: @classes do %>
<% @actions.each do |action| %>
<% result = capture { @view_context.render((action.component || Blacklight::Document::ActionComponent).new(action: action, document: @document, options: @options, url_opts: @url_opts)) } %>
<% result = capture { @view_context.render((action.component || Blacklight::Document::ActionComponent).new(action: action, document: @document, options: @options, url_opts: @url_opts, link_classes: @link_classes)) } %>

<% if @wrapping_tag %>
<%= content_tag(@wrapping_tag, class: Array(@wrapping_classes) + [action.key]) do %>
Expand Down
3 changes: 2 additions & 1 deletion app/components/blacklight/document/actions_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Document
class ActionsComponent < ::ViewComponent::Base
# @param [Blacklight::Document] document
# rubocop:disable Metrics/ParameterLists
def initialize(document: nil, actions: [], options: {}, url_opts: nil, tag: :div, classes: 'index-document-functions', wrapping_tag: nil, wrapping_classes: nil)
def initialize(document: nil, actions: [], options: {}, url_opts: nil, tag: :div, classes: 'index-document-functions', wrapping_tag: nil, wrapping_classes: nil, link_classes: 'nav-link')
@document = document
@actions = actions
@tag = tag
Expand All @@ -15,6 +15,7 @@ def initialize(document: nil, actions: [], options: {}, url_opts: nil, tag: :div
@url_opts = url_opts
@wrapping_tag = wrapping_tag
@wrapping_classes = wrapping_classes
@link_classes = link_classes
end
# rubocop:enable Metrics/ParameterLists

Expand Down
2 changes: 1 addition & 1 deletion app/views/bookmarks/_tools.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if render_show_doc_actions_method_from_blacklight? %>
<%= render(Blacklight::Document::ActionsComponent.new(document: nil, tag: 'ul', classes: "#{controller_name}Tools nav nav-pills", wrapping_tag: 'li', wrapping_classes: 'nav-item', actions: document_actions(document_list, options: { document: nil }), options: { document_list: @response.documents }, url_opts: Blacklight::Parameters.sanitize(params.to_unsafe_h))) %>
<%= render(Blacklight::Document::ActionsComponent.new(document: nil, tag: 'div', classes: "#{controller_name}Tools", wrapping_tag: 'span', wrapping_classes: 'btn btn-outline-primary', link_classes: '', actions: document_actions(document_list, options: { document: nil }), options: { document_list: @response.documents }, url_opts: Blacklight::Parameters.sanitize(params.to_unsafe_h))) %>
<% else %>
<% Deprecation.warn(self, '#render_show_doc_actions is deprecated; use ActionComponents instead') %>
<ul class="<%= controller_name %>Tools nav nav-pills">
Expand Down