Skip to content

Commit 7ee3bd2

Browse files
authored
Revert "Add multiple body options to Overlay body slot (primer#2781)" (primer#2820)
1 parent b6b0d81 commit 7ee3bd2

File tree

10 files changed

+5
-108
lines changed

10 files changed

+5
-108
lines changed

.changeset/wild-knives-notice.md

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

app/components/primer/alpha/overlay.html.erb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,7 @@
66
<% if content.present? %>
77
<%= content %>
88
<% else %>
9-
<% if bodies.size > 1 %>
10-
<%= render(Primer::Alpha::TabPanels.new(label: "label", wrapper_arguments: { classes: "Overlay-tabPanels" })) do |component| %>
11-
<% bodies.each do |body| %>
12-
<% component.with_tab(**body.tab_arguments) do |tab| %>
13-
<% tab.with_panel(classes: "Overlay-tabPanel") do %>
14-
<%= body %>
15-
<% end %>
16-
<% tab.with_text { body.tab_label } %>
17-
<% end %>
18-
<% end %>
19-
<% end %>
20-
<% else %>
21-
<%= bodies.first %>
22-
<% end %>
9+
<%= body %>
2310
<%= footer %>
2411
<% end %>
2512
<% end %>

app/components/primer/alpha/overlay.pcss

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,3 @@ anchored-position.not-anchored::backdrop, dialog::backdrop {
2424
outline: solid 1px transparent;
2525
}
2626
}
27-
28-
.Overlay-tabPanels {
29-
display: flex;
30-
flex-direction: column;
31-
overflow-y: hidden;
32-
33-
&::part(tablist-wrapper) {
34-
margin: var(--base-size-8) 0;
35-
padding: 0 var(--base-size-8);
36-
}
37-
}
38-
39-
.Overlay-tabPanel {
40-
overflow: hidden;
41-
display: flex;
42-
}

app/components/primer/alpha/overlay.rb

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,10 @@ class Overlay < Primer::Component
106106
}
107107

108108
# Required body content.
109-
# when multiple bodies are passed, they will be rendered in a TabPanels component.
110109
#
111110
# @param padding [Symbol] The padding. <%= one_of(Primer::Alpha::Overlay::PADDING_OPTIONS) %>
112111
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
113-
renders_many :bodies, lambda { |padding: @padding, **system_arguments|
112+
renders_one :body, lambda { |padding: @padding, **system_arguments|
114113
Primer::Alpha::Overlay::Body.new(
115114
padding: padding,
116115
**system_arguments
@@ -186,16 +185,7 @@ def before_render
186185
@system_arguments[:aria][:label] = @title
187186
end
188187
end
189-
if bodies?
190-
if bodies.size > 1
191-
# confirm all bodies have tab_label
192-
bodies.each do |body|
193-
raise ArgumentError, "Multiple with_body slots require `tab_label` to be passed." unless body.tab_label.present?
194-
end
195-
end
196-
else
197-
with_body
198-
end
188+
with_body unless body?
199189
end
200190

201191
private

app/components/primer/alpha/overlay/body.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,15 @@ class Overlay
66
# A `Overlay::Body` is a compositional component, used to render the
77
# Body of an overlay. See <%= link_to_component(Primer::Alpha::Overlay) %>.
88
class Body < Primer::Component
9-
10-
attr_reader :tab_arguments, :tab_label
11-
12-
# @param tab_arguments [Hash] Arguments passed to TabPanels component
139
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
14-
def initialize(padding: DEFAULT_PADDING, tab_label: nil, tab_arguments: {}, **system_arguments)
10+
def initialize(padding: DEFAULT_PADDING, **system_arguments)
1511
@system_arguments = deny_tag_argument(**system_arguments)
1612
@system_arguments[:tag] = :div
1713
@system_arguments[:classes] = class_names(
1814
"Overlay-body",
1915
PADDING_MAPPINGS[fetch_or_fallback(PADDING_OPTIONS, padding, DEFAULT_PADDING)],
2016
system_arguments[:classes]
2117
)
22-
@tab_arguments = tab_arguments
23-
@tab_label = tab_label
2418
end
2519

2620
def call

app/components/primer/alpha/tab_panels.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TabPanels < Primer::Component
1919
# @param id [String] Unique ID of tab.
2020
# @param selected [Boolean] Whether the tab is selected.
2121
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
22-
renders_many :tabs, lambda { |id: self.class.generate_id, selected: false, **system_arguments|
22+
renders_many :tabs, lambda { |id:, selected: false, **system_arguments|
2323
system_arguments[:id] = id
2424
system_arguments[:classes] = tab_nav_tab_classes(system_arguments[:classes])
2525

previews/primer/alpha/overlay_preview.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,6 @@ def overlay_with_header_subtitle
195195
end
196196
end
197197

198-
def overlay_with_three_bodies
199-
render_with_template(locals: {})
200-
end
201-
202198
def in_a_sticky_container
203199
render_with_template(locals: {})
204200
end

previews/primer/alpha/overlay_preview/overlay_with_three_bodies.html.erb

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

static/classes.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,6 @@
408408
"Overlay-headerFilter": [
409409
"Primer::Alpha::Dialog"
410410
],
411-
"Overlay-tabPanel": [
412-
"Primer::Alpha::Overlay"
413-
],
414-
"Overlay-tabPanels": [
415-
"Primer::Alpha::Overlay"
416-
],
417411
"Popover": [
418412
"Primer::Beta::Popover"
419413
],

test/components/primer/alpha/overlay_test.rb

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -132,29 +132,4 @@ def test_renders_header_subtitle
132132

133133
assert_selector(".Overlay-header .Overlay-description")
134134
end
135-
136-
def test_renders_multiple_bodies_as_tabpanels
137-
render_inline(Primer::Alpha::Overlay.new(title: "Title", role: :dialog)) do |component|
138-
component.with_header
139-
component.with_body(tab_label: "Tab 1") { "Hello" }
140-
component.with_body(tab_label: "Tab 2") { "Hello" }
141-
end
142-
143-
assert_selector("tab-container.Overlay-tabPanels") do
144-
assert_selector(".tabnav-tab", count: 2)
145-
assert_selector(".Overlay-tabPanel", count: 2, visible: :all)
146-
end
147-
end
148-
149-
def test_raises_argument_error_when_tab_label_is_missing
150-
error = assert_raises(ArgumentError) do
151-
render_inline(Primer::Alpha::Overlay.new(title: "Title", role: :dialog)) do |component|
152-
component.with_header
153-
component.with_body { "Hello" }
154-
component.with_body { "Hello" }
155-
end
156-
end
157-
158-
assert_includes(error.message, "Multiple with_body slots require `tab_label` to be passed.")
159-
end
160135
end

0 commit comments

Comments
 (0)