Skip to content

Commit e1f3434

Browse files
jonrohandependabot[bot]camertronlangermankthesnowrose
authored
Add a slot to Overlay for a filter (#2651)
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Cameron Dutro <[email protected]> Co-authored-by: Katie Langerman <[email protected]> Co-authored-by: Isaac Shalom <[email protected]> Co-authored-by: thesnowrose <[email protected]> Co-authored-by: primer-css <[email protected]> Co-authored-by: Tyler Benning <[email protected]> Co-authored-by: tbenning <[email protected]> Co-authored-by: Keith Cirkel <[email protected]> Co-authored-by: langermank <[email protected]> Co-authored-by: camertron <[email protected]> Co-authored-by: jonrohan <[email protected]> Co-authored-by: Orhan Toy <[email protected]> Co-authored-by: dependabot[bot] <dependabot[bot]@users.noreply.github.com> Co-authored-by: primer[bot] <119360173+primer[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: primer[bot] <primer[bot]@users.noreply.github.com>
1 parent 507a743 commit e1f3434

File tree

8 files changed

+53
-0
lines changed

8 files changed

+53
-0
lines changed

.changeset/seven-pillows-explode.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/view-components": minor
3+
---
4+
5+
Add a slot to `Overlay::Header` called `filter` for a filter input.

app/components/primer/alpha/dialog.pcss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ dialog.Overlay:not([open]) {
265265
}
266266
}
267267

268+
.Overlay-headerFilter {
269+
padding: var(--stack-gap-condensed) var(--stack-gap-condensed) 0 var(--stack-gap-condensed);
270+
}
271+
268272
/* generic body content slot */
269273
.Overlay-body {
270274
padding: var(--stack-padding-normal);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
</div>
1515
<% end %>
1616
</div>
17+
<%= filter %>
1718
<% end %>

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ class Header < Primer::Component
1313
}.freeze
1414
SIZE_OPTIONS = SIZE_MAPPINGS.keys
1515

16+
# Optional filter slot for adding a filter input to the header.
17+
#
18+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
19+
renders_one :filter, lambda { |**system_arguments|
20+
system_arguments[:tag] = :div
21+
system_arguments[:classes] = class_names(
22+
"Overlay-headerFilter",
23+
system_arguments[:classes]
24+
)
25+
Primer::BaseComponent.new(**system_arguments)
26+
}
27+
1628
# @param title [String] Describes the content of the Overlay.
1729
# @param subtitle [String] Provides additional context for the Overlay, also setting the `aria-describedby` attribute.
1830
# @param overlay_id [String] Provides the id of the overlay element so the close button can close it

previews/primer/alpha/overlay_preview.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ def dialog_with_header_footer
179179
d.with_body { "This is a long body for the overlay dialog. <br>".html_safe * 20 }
180180
end
181181
end
182+
183+
def overlay_with_header_filter
184+
render_with_template(locals: {})
185+
end
182186
end
183187
end
184188
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<%= render(Primer::Alpha::Overlay.new(title: "Dialog", role: :dialog, size: :large, padding: :condensed)) do |d| %>
2+
<% d.with_header(title: "Large Dialog Header", divider: true) do |header| %>
3+
<% header.with_filter do %>
4+
<%= render Primer::Alpha::TextField.new(
5+
autofocus: true,
6+
visually_hide_label:
7+
true,
8+
name: "filter",
9+
label: "Filter Overlay"
10+
) %>
11+
<% end %>
12+
<% end %>
13+
<% d.with_show_button { "Show Overlay" } %>
14+
<% d.with_footer { "Large Dialog Footer" } %>
15+
<% d.with_body { "This is a long body for the overlay dialog. <br>".html_safe * 20 } %>
16+
<% end %>

static/classes.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@
402402
"Overlay-header": [
403403
"Primer::Alpha::Dialog"
404404
],
405+
"Overlay-headerFilter": [
406+
"Primer::Alpha::Dialog"
407+
],
405408
"Popover": [
406409
"Primer::Beta::Popover"
407410
],

test/components/primer/alpha/overlay_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,12 @@ def test_footer_align
116116

117117
assert_selector(".Overlay-footer.Overlay-footer--alignStart")
118118
end
119+
120+
def test_renders_header_filter
121+
render_inline(Primer::Alpha::Overlay::Header.new(id: "1", title: "Header")) do |component|
122+
component.with_filter { "content" }
123+
end
124+
125+
assert_selector(".Overlay-header .Overlay-headerContentWrap + .Overlay-headerFilter")
126+
end
119127
end

0 commit comments

Comments
 (0)