Skip to content

Commit

Permalink
Support button_to on navigation item (#427)
Browse files Browse the repository at this point in the history
* feat: support button_to on navigation item

* fix: link_arguments
  • Loading branch information
remy727 authored Jul 8, 2024
1 parent 85df03a commit 8a6eef5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
42 changes: 30 additions & 12 deletions app/components/polaris/navigation/item_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
<%= render Polaris::BaseComponent.new(**system_arguments) do %>
<div class="Polaris-Navigation__ItemWrapper">
<div class="Polaris-Navigation__ItemInnerWrapper">
<%= link_to @url, **link_arguments do %>
<% if @icon.present? %>
<div class="Polaris-Navigation__Icon">
<%= polaris_icon(name: @icon) %>
</div>
<% if @action_type == :link %>
<%= link_to @url, **link_arguments do %>
<% if @icon.present? %>
<div class="Polaris-Navigation__Icon">
<%= polaris_icon(name: @icon) %>
</div>
<% end %>
<span class="Polaris-Navigation__Text">
<%= @label %>
</span>
<% if @badge.present? %>
<div class="Polaris-Navigation__Badge">
<%= polaris_badge { @badge } %>
</div>
<% end %>
<% end %>
<span class="Polaris-Navigation__Text">
<%= @label %>
</span>
<% if @badge.present? %>
<div class="Polaris-Navigation__Badge">
<%= polaris_badge { @badge } %>
</div>
<% else %>
<%= button_to @url, **link_arguments do %>
<% if @icon.present? %>
<div class="Polaris-Navigation__Icon">
<%= polaris_icon(name: @icon) %>
</div>
<% end %>
<span class="Polaris-Navigation__Text">
<%= @label %>
</span>
<% if @badge.present? %>
<div class="Polaris-Navigation__Badge">
<%= polaris_badge { @badge } %>
</div>
<% end %>
<% end %>
<% end %>
<% if secondary_actions.present? %>
Expand Down
2 changes: 2 additions & 0 deletions app/components/polaris/navigation/item_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def initialize(
selected: false,
disabled: false,
external: false,
action_type: :link,
link_arguments: {},
**system_arguments
)
Expand All @@ -23,6 +24,7 @@ def initialize(
@disabled = disabled
@external = external
@system_arguments = system_arguments
@action_type = action_type
@link_arguments = link_arguments
end

Expand Down

0 comments on commit 8a6eef5

Please sign in to comment.