Skip to content

Commit 4060de4

Browse files
committed
Add component preview
1 parent 2e0b79f commit 4060de4

File tree

6 files changed

+40
-21
lines changed

6 files changed

+40
-21
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
# @component "ui/modal"
4+
class SolidusAdmin::Layout::Confirm::ComponentPreview < ViewComponent::Preview
5+
include SolidusAdmin::Preview
6+
7+
# @param title text
8+
# @param body text
9+
# @param button text
10+
def overview(title: "Are you sure?", body: "You are about to delete something. This cannot be undone.", button: "Confirm")
11+
render_with_template(locals: { title:, body:, button: })
12+
end
13+
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<section>
2+
<div class="mb-8 text-lg">
3+
<form>
4+
<%= render component("ui/button").new(
5+
type: :submit,
6+
scheme: :secondary,
7+
text: "Summon confirmation modal",
8+
data: {
9+
"turbo-confirm": title,
10+
"confirm-details": body,
11+
"confirm-button": button
12+
}
13+
) %>
14+
</form>
15+
</div>
16+
17+
<%= render current_component.new %>
18+
</section>

admin/spec/components/previews/solidus_admin/ui/modal/component_preview.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,4 @@ def with_text
1111
def with_form
1212
render_with_template
1313
end
14-
15-
def with_actions
16-
render_with_template
17-
end
1814
end

admin/spec/components/previews/solidus_admin/ui/modal/component_preview/with_actions.html.erb

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
require "spec_helper"
4+
5+
RSpec.describe SolidusAdmin::Layout::Confirm::Component, type: :component do
6+
it "renders the overview preview" do
7+
render_preview(:overview)
8+
end
9+
end

admin/spec/components/solidus_admin/ui/modal/component_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
it "renders the overview preview" do
77
render_preview(:with_text)
88
render_preview(:with_form)
9-
render_preview(:with_actions)
109
end
1110
end

0 commit comments

Comments
 (0)