-
-
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.
Merge pull request #5445 from solidusio/elia/admin/page-helpers
SolidusAdmin: Extract page layout helpers
- Loading branch information
Showing
9 changed files
with
118 additions
and
68 deletions.
There are no files selected for viewing
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,55 @@ | ||
# frozen_string_literal: true | ||
|
||
module SolidusAdmin::Layout::PageHelpers | ||
def page(&block) | ||
tag.div(capture(&block), class: "px-4 relative", "data-controller": stimulus_id) | ||
end | ||
|
||
def page_header_actions(&block) | ||
tag.div(safe_join([ | ||
render(component("feedback").new), | ||
capture(&block), | ||
]), class: "flex gap-2 items-center") | ||
end | ||
|
||
def page_header_back(back_path) | ||
render component("ui/button").new( | ||
tag: :a, | ||
title: t(".back"), | ||
icon: "arrow-left-line", | ||
scheme: :secondary, | ||
href: back_path | ||
) | ||
end | ||
|
||
def page_header_title(title, &block) | ||
tag.h1(safe_join([ | ||
tag.span(title, class: "body-title"), | ||
(capture(&block) if block_given?) || "", | ||
]), class: "flex-1 text-2xl font-bold") | ||
end | ||
|
||
def page_header(&block) | ||
tag.header(capture(&block), class: "py-6 flex items-center gap-4") | ||
end | ||
|
||
def page_with_sidebar(&block) | ||
tag.div(capture(&block), class: "flex gap-4 items-start pb-4") | ||
end | ||
|
||
def page_with_sidebar_main(&block) | ||
tag.div(capture(&block), class: "justify-center items-start gap-4 flex flex-col w-full") | ||
end | ||
|
||
def page_with_sidebar_aside(&block) | ||
tag.aside(capture(&block), class: "justify-center items-start gap-4 flex flex-col w-full max-w-sm") | ||
end | ||
|
||
def page_footer(&block) | ||
tag.div(capture(&block), class: "mt-4 py-4 px-2 pb-8 border-t border-gray-100 flex") | ||
end | ||
|
||
def page_footer_actions(&block) | ||
tag.div(capture(&block), class: "flex gap-2 grow") | ||
end | ||
end |
25 changes: 9 additions & 16 deletions
25
admin/app/components/solidus_admin/orders/new/component.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 |
---|---|---|
@@ -1,20 +1,13 @@ | ||
<div class="px-4 relative" data-controller="<%= stimulus_id %>"> | ||
<header class="py-6 flex items-center gap-4"> | ||
<%= render component("ui/button").new( | ||
tag: :a, | ||
title: t(".back"), | ||
icon: "arrow-left-line", | ||
scheme: :secondary, | ||
href: solidus_admin.orders_path | ||
) %> | ||
<h1 class="flex items-center gap-2"> | ||
<span class="body-title"><%= t(".create_order") %></span> | ||
</h1> | ||
<%= page do %> | ||
<%= page_header do %> | ||
<%= page_header_back solidus_admin.orders_path %> | ||
|
||
<div class="ml-auto flex gap-2 items-center"> | ||
<%= page_header_title t(".create_order") %> | ||
|
||
<%= page_header_actions do %> | ||
<%= render component("feedback").new %> | ||
<%= render component("ui/button").new(tag: :button, scheme: :secondary, text: t(".discard"), form: form_id) %> | ||
<%= render component("ui/button").new(tag: :button, text: t(".save"), form: form_id) %> | ||
</div> | ||
</header> | ||
</div> | ||
<% 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
2 changes: 2 additions & 0 deletions
2
admin/app/components/solidus_admin/products/index/component.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
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
2 changes: 2 additions & 0 deletions
2
admin/app/components/solidus_admin/products/show/component.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
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
admin/app/components/solidus_admin/ui/table/toolbar/component.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 SolidusAdmin::UI::Table::Toolbar::Component < SolidusAdmin::BaseComponent | ||
erb_template <<~ERB | ||
<div class=" | ||
h-14 p-2 bg-white border-b border-gray-100 | ||
justify-start items-center gap-2 | ||
visible:flex hidden:hidden | ||
rounded-t-lg | ||
"> | ||
<%= content %> | ||
</div> | ||
ERB | ||
end |