Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Admin] Add order/show/summary component #5512

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="<%= stimulus_id %>">
<ul class="text-sm">
<% @items.each do |item| %>
<li class="flex justify-between py-2 <%= item[:class] %>">
<span><%= item[:label] %></span>
<span><%= item[:value] %></span>
</li>
<% end %>
</ul>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class SolidusAdmin::UI::DetailsList::Component < SolidusAdmin::BaseComponent
def initialize(items:)
@items = items
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

# @component "ui/details_list"
class SolidusAdmin::UI::DetailsList::ComponentPreview < ViewComponent::Preview
include SolidusAdmin::Preview

def overview
render_with_template
end

# @param items select { choices: [[Order details, './data/example1.json'], [Product details, './data/example2.json'], [Account details, './data/example3.json']] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩

def playground(items: './data/example1.json')
parsed_items = JSON.parse(
File.read(File.join(__dir__, items)),
symbolize_names: true
)

render current_component.new(items: parsed_items)
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%= render current_component.new(
items: [
{ label: 'Subtotal', value: '€90.00', class: 'font-semibold' },
{ label: 'Taxes', value: '€0.00' },
{ label: 'Shipping', value: '€0.00' },
{ label: link_to('Add promo code', '#', class: "body-link"), value: '€0.00' },
{ label: link_to('Adjustments', '#', class: "body-link"), value: '€0.00' },
{ label: 'Total', value: '€90.00', class: 'font-semibold' }
]
) %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{ "label": "Subtotal", "value": "€120.00", "class": "font-semibold" },
{ "label": "Discount", "value": "€20.00", "class": "text-red-500" },
{ "label": "Shipping", "value": "€5.00" },
{ "label": "Total", "value": "€105.00", "class": "font-bold" }
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{ "label": "Weight", "value": "2kg" },
{ "label": "Dimensions", "value": "10x20x30 cm" },
{ "label": "Color", "value": "Red", "class": "text-red-500" },
{ "label": "Material", "value": "Aluminum" }
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{ "label": "Name", "value": "John Doe" },
{ "label": "Membership", "value": "Gold", "class": "font-semibold" },
{ "label": "Points", "value": "1500" },
{ "label": "Account Status", "value": "Deactivated", "class": "text-red-500" }
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require "spec_helper"

RSpec.describe SolidusAdmin::UI::DetailsList::Component, type: :component do
it "renders the overview preview" do
render_preview(:overview)
end
end