Skip to content

Commit

Permalink
Add unsectioned content support in EmptyState component
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillplatonov committed Oct 8, 2021
1 parent 8e433e9 commit ab44358
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/components/polaris/empty_state_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@
<img src="<%= @image %>" role="presentation" alt="" class="Polaris-EmptyState__Image">
</div>
</div>
<% if unsectioned_content.present? %>
<%= unsectioned_content %>
<% end %>
<% end %>
1 change: 1 addition & 0 deletions app/components/polaris/empty_state_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class EmptyStateComponent < Polaris::NewComponent
end
renders_one :secondary_action, Polaris::ButtonComponent
renders_one :footer
renders_one :unsectioned_content

def initialize(
image:,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ def with_subdued_footer

def full_width
end

def unsectioned_content
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%= polaris_card do %>
<%= polaris_empty_state(
heading: "Manage your inventory transfers",
image: "https://cdn.shopify.com/s/files/1/0262/4071/2726/files/emptystate-files.png",
) do |state| %>
<p>Track and receive your incoming inventory from suppliers.</p>

<% state.unsectioned_content do %>
<p>Content outside of EmptyState Section.</p>
<% end %>
<% end %>
<% end %>
13 changes: 13 additions & 0 deletions test/components/polaris/empty_state_component_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,17 @@ def test_empty_state_without_actions

assert_no_selector ".Polaris-EmptyState__Details > .Polaris-EmptyState__Actions"
end

def test_unsectioned_content
render_inline(Polaris::EmptyStateComponent.new(
heading: "Title",
image: "/image.png",
)) do |state|
state.unsectioned_content do
tag.div id: "unsectioned"
end
end

assert_selector ".Polaris-EmptyState > #unsectioned"
end
end
1 change: 1 addition & 0 deletions test/test_helpers/component_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module Polaris
module ComponentTestHelpers
include ActionView::Helpers::TagHelper
include ViewComponent::TestHelpers
include Polaris::ViewHelper
include Polaris::ActionHelper
Expand Down

0 comments on commit ab44358

Please sign in to comment.