Skip to content

Commit 841f449

Browse files
chore[#51013]: Add actions to playground and switch to template
1 parent ac78f51 commit 841f449

2 files changed

Lines changed: 48 additions & 9 deletions

File tree

previews/primer/open_project/page_header_preview.rb

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,32 @@ def default
2121
# @param with_back_button [Boolean]
2222
# @param back_button_size [Symbol] select [small, medium, large]
2323
# @param with_breadcrumbs [Boolean]
24-
# @param parent_link [Boolean]
24+
# @param with_actions [Boolean]
25+
# @param with_context_bar_actions [Boolean]
26+
# @param with_parent_link [Boolean]
2527
def playground(
2628
variant: :medium,
2729
title: "Hello",
2830
description: "Last updated 5 minutes ago by XYZ.",
2931
with_back_button: false,
3032
back_button_size: :medium,
3133
with_breadcrumbs: false,
32-
parent_link: false
34+
with_actions: false,
35+
with_context_bar_actions: false,
36+
with_parent_link: false
3337
)
3438
breadcrumb_items = [{ href: "/foo", text: "Foo" }, { href: "/bar", text: "Bar" }, "Baz"]
3539

36-
render(Primer::OpenProject::PageHeader.new) do |header|
37-
header.with_title(variant: variant) { title }
38-
header.with_description { description }
39-
header.with_back_button(href: "#", size: back_button_size, 'aria-label': "Back") if with_back_button
40-
header.with_breadcrumbs(breadcrumb_items) if with_breadcrumbs
41-
header.with_parent_link(href: "#") { "Parent link" } if parent_link
42-
end
40+
render_with_template(locals: { variant: variant,
41+
title: title,
42+
description: description,
43+
with_back_button: with_back_button,
44+
back_button_size: back_button_size,
45+
with_breadcrumbs: with_breadcrumbs,
46+
with_parent_link: with_parent_link,
47+
with_actions: with_actions,
48+
with_context_bar_actions: with_context_bar_actions,
49+
breadcrumb_items: breadcrumb_items })
4350
end
4451

4552
# @label Large
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<%= render Primer::OpenProject::PageHeader.new do |header| %>
2+
<%= header.with_title(variant: variant) { title } %>
3+
<%= header.with_description { description } %>
4+
<%= header.with_back_button(href: "#", size: back_button_size, 'aria-label': "Back") if with_back_button %>
5+
<%= header.with_breadcrumbs(breadcrumb_items) if with_breadcrumbs %>
6+
<%= header.with_parent_link(href: "#") { "Parent link" } if with_parent_link %>
7+
<% if with_actions %>
8+
<% header.with_actions do %>
9+
<%= render(Primer::Alpha::ActionMenu.new) do |component| %>
10+
<% component.with_show_button { "Menu" } %>
11+
<% component.with_item(label: "Item", tag: :button, value: "") %>
12+
<% component.with_item(
13+
label: "Show dialog",
14+
tag: :button,
15+
content_arguments: { "data-show-dialog-id": "my-dialog" },
16+
value: "",
17+
scheme: :danger
18+
) %>
19+
<% end %>
20+
<% end %>
21+
<% end %>
22+
<% if with_context_bar_actions %>
23+
<% header.with_context_bar_actions do %>
24+
<%= render(Primer::Beta::IconButton.new(
25+
scheme: :default,
26+
size: :small,
27+
icon: "pencil",
28+
"aria-label": "aria_label"
29+
)) %>
30+
<% end %>
31+
<% end %>
32+
<% end %>

0 commit comments

Comments
 (0)