Skip to content

Commit

Permalink
Allow the button component to be rendered as a link
Browse files Browse the repository at this point in the history
  • Loading branch information
elia committed Jul 20, 2023
1 parent 046f119 commit c7fa524
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions admin/app/components/solidus_admin/ui/button/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class SolidusAdmin::UI::Button::Component < SolidusAdmin::BaseComponent
],
}

def initialize(text: nil, class_name: nil, size: :m, scheme: :primary, **attributes)
def initialize(tag: :button, text: nil, class_name: nil, size: :m, scheme: :primary, **attributes)
@tag = tag
@text = text
@attributes = attributes

Expand All @@ -53,6 +54,6 @@ def initialize(text: nil, class_name: nil, size: :m, scheme: :primary, **attribu
end

def call
content_tag(:button, @text, class: @class_name, **@attributes)
content_tag(@tag, @text, class: @class_name, **@attributes)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@

</div>
<% end %>

<div class="mb-8">
<h6 class="text-gray-500 mb-3 mt-0">
As a link
</h6>

<%= render current_component.new(tag: :a, href: "#", text: "I'm a link!") %>
</div>

0 comments on commit c7fa524

Please sign in to comment.