-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the preview for the sidebar admin component
We inject a tweaked item component to avoid rendering actual links in the embedded preview. We'll leave the preview of active state of the main navigation to the item component preview. Ref. #5221
- Loading branch information
1 parent
4b69036
commit 7fa58b8
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
admin/spec/components/previews/solidus_admin/sidebar/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,33 @@ | ||
# frozen_string_literal: true | ||
|
||
require "solidus_admin/main_nav_item" | ||
|
||
# @component "sidebar" | ||
class SolidusAdmin::Sidebar::ComponentPreview < ViewComponent::Preview | ||
include SolidusAdmin::Preview | ||
|
||
class ItemComponent < SolidusAdmin::Sidebar::Item::Component | ||
def path | ||
"#" | ||
end | ||
|
||
def active? | ||
false | ||
end | ||
end | ||
|
||
# @param store_name text | ||
# @param store_url url | ||
# @param logo_path text { description: "Asset path to the store logo" } | ||
def overview(store_name: "Solidus store", store_url: "https://example.com", logo_path: SolidusAdmin::Config.logo_path) | ||
store = Struct.new(:name, :url).new(store_name, store_url) | ||
|
||
render_with_template( | ||
locals: { | ||
logo_path: logo_path, | ||
store: store, | ||
item_component: ItemComponent | ||
} | ||
) | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
admin/spec/components/previews/solidus_admin/sidebar/component_preview/overview.html.erb
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,7 @@ | ||
<div class="w-[17.78rem]"> | ||
<%= render current_component.new( | ||
store: store, | ||
logo_path: logo_path, | ||
item_component: item_component | ||
) %> | ||
</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