Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#60359] Harmonise FeedbackDialog slot naming
Browse files Browse the repository at this point in the history
Renames the `additional_content` slot to `additional_details` to make
Feedback Dialog consistent with the newly introduced Danger Confirmation
Dialog.

ViewComponent defines a `with_SLOT_NAME_content` method for given slots.
Using `additional_content` as a slot name results in a
`with_additonal_content_content` method being generated - this makes for
a poor API for component users.
myabc committed Jan 10, 2025

Verified

This commit was signed with the committer’s verified signature.
myabc Alexander Brandon Coles
1 parent d1f67d4 commit 3e38519
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/components/primer/open_project/feedback_dialog.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<%= render @dialog do |dialog| %>
<% dialog.with_body do %>
<%= feedback_message %>
<% if additional_content.present? %>
<%= additional_content %>
<% if additional_details.present? %>
<%= additional_details %>
<% end %>
<% end %>
<% dialog.with_footer do %>
6 changes: 3 additions & 3 deletions app/components/primer/open_project/feedback_dialog.rb
Original file line number Diff line number Diff line change
@@ -17,15 +17,15 @@ class FeedbackDialog < Primer::Component
Primer::OpenProject::FeedbackMessage.new(icon_arguments: icon_arguments, **system_arguments)
}

# Optional additional_content like a form input or toast.
# Optional additional_details like a form input or toast.
#
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
renders_one :additional_content, lambda { |**system_arguments|
renders_one :additional_details, lambda { |**system_arguments|
deny_tag_argument(**system_arguments)
system_arguments[:tag] = :div
system_arguments[:classes] = class_names(
system_arguments[:classes],
"FeedbackDialog-additionalContent"
"FeedbackDialog-additionalDetails"
)

system_arguments[:display] ||= :flex
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
<% end %>
<% if show_additional_details %>
<% dialog.with_additional_details do %>
<%= render(Primer::Alpha::Banner.new) { "Some additional content below" } %>
<%= render(Primer::Alpha::Banner.new) { "Some additional details below" } %>
<% end %>
<% end %>
<% dialog.with_confirmation_check_box_content(check_box_text) %>
10 changes: 5 additions & 5 deletions previews/primer/open_project/feedback_dialog_preview.rb
Original file line number Diff line number Diff line change
@@ -24,19 +24,19 @@ def default
# @param icon_color [Symbol] select [default, muted, subtle, accent, success, attention, severe, danger, open, closed, done, sponsors, on_emphasis, inherit]
# @param loading_state [Boolean] toggle
# @param show_description toggle
# @param show_additional_content toggle
# @param show_additional_details toggle
# @param custom_footer toggle
def playground(icon: :"check-circle", icon_color: :success, loading_state: false, show_description: true, show_additional_content: false, custom_footer: false)
def playground(icon: :"check-circle", icon_color: :success, loading_state: false, show_description: true, show_additional_details: false, custom_footer: false)
render_with_template(locals: { icon: icon,
icon_color: icon_color,
loading_state: loading_state,
show_description: show_description,
show_additional_content: show_additional_content,
show_additional_details: show_additional_details,
custom_footer: custom_footer })
end

# @label With additional content
def additional_content
# @label With additional details
def additional_details
render_with_template(locals: {})
end

Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
<% dialog.with_feedback_message do |message| %>
<% message.with_heading(tag: :h2).with_content("Action successful") %>
<% end %>
<% dialog.with_additional_content do %>
<% dialog.with_additional_details do %>
<% render(Primer::Beta::Text.new) { "You can render whatever component you want here." } %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@
<% message.with_heading(tag: :h2).with_content("Awesome!") %>
<% message.with_description { "Great! Everything worked well." } if show_description %>
<% end %>
<% if show_additional_content %>
<% dialog.with_additional_content(display: :inline) do %>
<%= render(Primer::Alpha::Banner.new) { "Some additional content below" } %>
<% if show_additional_details %>
<% dialog.with_additional_details(display: :inline) do %>
<%= render(Primer::Alpha::Banner.new) { "Some additional details below" } %>
<% end %>
<% end %>
<% if custom_footer %>
6 changes: 3 additions & 3 deletions test/components/primer/open_project/feedback_dialog_test.rb
Original file line number Diff line number Diff line change
@@ -19,16 +19,16 @@ def test_renders
end
end

def test_renders_additional_content
def test_renders_additional_details
render_inline(Primer::OpenProject::FeedbackDialog.new) do |dialog|
dialog.with_feedback_message do |message|
message.with_heading(tag: :h2) { "Success" }
end
dialog.with_additional_content { "Some additional content" }
dialog.with_additional_details { "Some additional details" }
end

assert_selector("dialog.FeedbackDialog") do
assert_selector(".FeedbackDialog-additionalContent", text: "Some additional content")
assert_selector(".FeedbackDialog-additionalDetails", text: "Some additional details")
end
end

0 comments on commit 3e38519

Please sign in to comment.