Skip to content

Commit d2d5a3c

Browse files
committed
Add component preview
1 parent e9b1425 commit d2d5a3c

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ def with_form
1212
render_with_template
1313
end
1414

15-
def with_actions
16-
render_with_template
15+
# @param title text
16+
# @param body text
17+
# @param button text
18+
def confirmation(title: "Are you sure?", body: "You are about to delete something. This cannot be undone.", button: "Confirm")
19+
render_with_template(locals: { title:, body:, button: })
1720
end
1821
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 component("ui/modal/confirm").new %>
18+
</section>

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

Lines changed: 0 additions & 16 deletions
This file was deleted.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
it "renders the overview preview" do
77
render_preview(:with_text)
88
render_preview(:with_form)
9-
render_preview(:with_actions)
9+
render_preview(:confirmation)
1010
end
1111
end

0 commit comments

Comments
 (0)