-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Created empty search state (#770)
* chore: Created empty search state * chore: Updated empty state to new styles and used that if table search comes up empty * chore: Added previews and testing * chore: Fixed project samples test * chore: Better border styling * chore: Fixed samples test * chore: Fixed empty component test * chore: Fixed data export tests * chore: Fixed broken test
- Loading branch information
Showing
11 changed files
with
284 additions
and
202 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
<div class="flex justify-center py-20 mt-4"> | ||
<div class="flex items-center inline-block"> | ||
<%= viral_icon(name: icon_name, color: :primary, classes: "w-20 h-20 shrink mr-4") %> | ||
<div class="flex flex-col grow"> | ||
<p class="text-2xl font-bold dark:text-slate-300 text-slate-700"> | ||
<%= title %> | ||
<div | ||
class=" | ||
flex items-center p-4 space-x-4 border border-gray-200 rounded-lg | ||
dark:border-gray-800 | ||
" | ||
role="alert" | ||
> | ||
<span class="flex-shrink text-gray-500 dark:text-gray-400"> | ||
<%= viral_icon(name: icon_name, classes: "size-10") %> | ||
</span> | ||
<div> | ||
<h1 class="text-2xl font-bold tracking-tight text-gray-900 dark:text-white"> | ||
<%= title %> | ||
</h1> | ||
<% if description.present? %> | ||
<p class="font-normal text-gray-700 dark:text-gray-400"> | ||
<%= description %> | ||
</p> | ||
<% if description.present? %> | ||
<p class="text-slate-600 dark:text-slate-400"> | ||
<%= description %> | ||
</p> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<% if pagy.vars[:size].positive? && pagy.count.positive? %> | ||
<div class="flex items-center justify-between"> | ||
<%= render Viral::Pagy::LimitComponent.new(pagy, item: item) %> | ||
<%= render Viral::Pagy::PaginationComponent.new(pagy) %> | ||
</div> | ||
<% else %> | ||
<%= render Viral::EmptyStateComponent.new( | ||
icon_name: :magnifying_glass, | ||
title: t("components.viral.pagy.empty_state.title"), | ||
description: t("components.viral.pagy.empty_state.description"), | ||
) %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Viral | ||
module Pagy | ||
# FullComponent is a component that renders the full pagy pagination | ||
# including the limit and pagination components. | ||
class FullComponent < Viral::Component | ||
def initialize(pagy, item:) | ||
@pagy = pagy | ||
@item = item | ||
end | ||
|
||
private | ||
|
||
attr_reader :pagy, :item | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
test/components/previews/viral_pagy_full_component_preview.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
class ViralPagyFullComponentPreview < ViewComponent::Preview | ||
def default | ||
pagy = Pagy.new(count: 100, page: 1) | ||
render(Viral::Pagy::FullComponent.new(pagy, item: 'items')) | ||
end | ||
|
||
def empty_state | ||
pagy = Pagy.new(count: 0, page: 1) | ||
pagy.vars[:size] = 9 | ||
render(Viral::Pagy::FullComponent.new(pagy, item: 'items')) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'application_system_test_case' | ||
|
||
class PagyFullComponentPreviewTest < ApplicationSystemTestCase | ||
test 'renders default' do | ||
visit('/rails/view_components/viral_pagy_full_component/default') | ||
|
||
assert_selector 'nav.pagy.nav' | ||
assert_selector 'li button[disabled]', text: 'Previous' | ||
assert_selector 'li > a', text: 'Next' | ||
assert_selector 'li button[disabled]', text: '1' | ||
assert_selector 'li > a:not([data-aria-disabled="true"])', count: '5' | ||
end | ||
|
||
test 'renders empty state' do | ||
visit('/rails/view_components/viral_pagy_full_component/empty_state') | ||
|
||
assert_selector 'h1', text: I18n.t('components.viral.pagy.empty_state.title') | ||
assert_selector 'p', text: I18n.t('components.viral.pagy.empty_state.description') | ||
assert_no_selector 'nav.pagy.nav' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters