primer_view_components 0.0.97 → 0.0.98
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/app/components/primer/beta/avatar.rb +10 -10
- data/app/components/primer/beta/avatar_stack.rb +9 -9
- data/app/components/primer/beta/blankslate.rb +2 -2
- data/app/components/primer/button_component.rb +1 -1
- data/app/components/primer/image.rb +4 -4
- data/app/components/primer/image_crop.rb +3 -3
- data/app/components/primer/timeline_item_component.rb +1 -1
- data/lib/primer/deprecations.rb +0 -1
- data/lib/primer/example_image.rb +7 -0
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/tasks/docs.rake +4 -4
- data/lib/tasks/test.rake +1 -1
- data/previews/primer/alpha/action_list_preview/heading.html.erb +4 -0
- data/previews/primer/alpha/action_list_preview.rb +308 -0
- data/previews/primer/alpha/auto_complete_preview.rb +42 -0
- data/previews/primer/alpha/button_marketing_preview.rb +17 -0
- data/previews/primer/alpha/dialog_preview/custom_header.html.erb +7 -0
- data/previews/primer/alpha/dialog_preview/test.html.erb +7 -0
- data/previews/primer/alpha/dialog_preview/with_footer.html.erb +8 -0
- data/previews/primer/alpha/dialog_preview/with_form.html.erb +12 -0
- data/previews/primer/alpha/dialog_preview.rb +85 -0
- data/previews/primer/alpha/hidden_text_expander_preview.rb +15 -0
- data/previews/primer/alpha/layout_preview.rb +23 -0
- data/previews/primer/alpha/nav_list_preview.rb +64 -0
- data/previews/primer/alpha/tab_panels_preview.rb +23 -0
- data/previews/primer/alpha/text_field_preview.rb +66 -0
- data/previews/primer/alpha/toggle_switch_preview.rb +50 -0
- data/previews/primer/alpha/tooltip_preview/with_multiple_on_a_page.html.erb +14 -0
- data/previews/primer/alpha/tooltip_preview/with_right_most_position.html.erb +7 -0
- data/previews/primer/alpha/tooltip_preview.rb +83 -0
- data/previews/primer/alpha/underline_nav_preview/default.html.erb +8 -0
- data/previews/primer/alpha/underline_nav_preview.rb +41 -0
- data/previews/primer/alpha/underline_panels_preview.rb +23 -0
- data/previews/primer/beta/auto_complete_item_preview/default.html.erb +9 -0
- data/previews/primer/beta/auto_complete_item_preview/with_description.html.erb +11 -0
- data/previews/primer/beta/auto_complete_item_preview.rb +40 -0
- data/previews/primer/beta/auto_complete_preview/with_submit_button.html.erb +20 -0
- data/previews/primer/beta/auto_complete_preview.rb +245 -0
- data/previews/primer/beta/avatar_preview.rb +17 -0
- data/previews/primer/beta/avatar_stack_preview.rb +44 -0
- data/previews/primer/beta/base_button_preview.rb +17 -0
- data/previews/primer/beta/blankslate_preview.rb +94 -0
- data/previews/primer/beta/border_box_preview.rb +32 -0
- data/previews/primer/beta/breadcrumbs_preview.rb +19 -0
- data/previews/primer/beta/button_group_preview.rb +20 -0
- data/previews/primer/beta/button_preview/all_schemes.html.erb +26 -0
- data/previews/primer/beta/button_preview/leading_visual.html.erb +10 -0
- data/previews/primer/beta/button_preview/trailing_action.html.erb +10 -0
- data/previews/primer/beta/button_preview/trailing_visual.html.erb +11 -0
- data/previews/primer/beta/button_preview/with_tooltip.html.erb +10 -0
- data/previews/primer/beta/button_preview.rb +256 -0
- data/previews/primer/beta/close_button_preview.rb +15 -0
- data/previews/primer/beta/counter_preview.rb +24 -0
- data/previews/primer/beta/details_preview.rb +45 -0
- data/previews/primer/beta/flash_preview.rb +20 -0
- data/previews/primer/beta/heading_preview.rb +16 -0
- data/previews/primer/beta/icon_button_preview.rb +107 -0
- data/previews/primer/beta/text_preview.rb +16 -0
- data/previews/primer/beta/truncate_preview.rb +47 -0
- data/previews/primer/clipboard_copy_preview/element.html.erb +2 -0
- data/previews/primer/clipboard_copy_preview.rb +29 -0
- data/previews/primer/dropdown_preview.rb +39 -0
- data/previews/primer/forms/forms_preview/after_content_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/array_check_box_group_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/caption_template_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/check_box_group_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/composed_form.html.erb +4 -0
- data/previews/primer/forms/forms_preview/horizontal_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/invalid_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/multi_input_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/multi_text_field_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/radio_button_group_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/radio_button_with_nested_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/select_list_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/single_text_field_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/submit_button_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/text_field_and_checkbox_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview.rb +37 -0
- data/previews/primer/hellip_button_preview.rb +14 -0
- data/previews/primer/image_crop_preview.rb +22 -0
- data/previews/primer/label_component_preview.rb +15 -0
- data/previews/primer/layout_component_preview.rb +18 -0
- data/previews/primer/link_component_preview.rb +29 -0
- data/previews/primer/local_time_component_preview.rb +41 -0
- data/previews/primer/markdown_preview.rb +280 -0
- data/previews/primer/menu_component_preview/default.html.erb +17 -0
- data/previews/primer/menu_component_preview.rb +9 -0
- data/previews/primer/octicon_component_preview.rb +14 -0
- data/previews/primer/popover_component_preview.rb +20 -0
- data/previews/primer/progress_bar_component_preview.rb +17 -0
- data/previews/primer/spinner_component_preview.rb +13 -0
- data/previews/primer/state_component_preview.rb +16 -0
- data/previews/primer/subhead_component_preview.rb +23 -0
- data/previews/primer/time_ago_component_preview.rb +16 -0
- data/previews/primer/timeline_item_component_preview.rb +17 -0
- data/static/statuses.json +1 -1
- metadata +87 -3
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label AutoComplete
|
6
|
+
class AutoCompletePreview < ViewComponent::Preview
|
7
|
+
# @label Default Options
|
8
|
+
# @param label_text text
|
9
|
+
# @param is_label_visible toggle
|
10
|
+
# @param is_label_inline toggle
|
11
|
+
# @param with_icon toggle
|
12
|
+
# @param is_clearable toggle
|
13
|
+
def default(label_text: "Select a fruit", is_label_visible: true, is_label_inline: false, with_icon: false, is_clearable: false)
|
14
|
+
render(Primer::Alpha::AutoComplete.new(label_text: label_text, input_id: "input-id", list_id: "test-id", src: "/auto_complete?version=alpha", is_label_visible: is_label_visible, is_label_inline: is_label_inline, with_icon: with_icon, is_clearable: is_clearable))
|
15
|
+
end
|
16
|
+
|
17
|
+
# @!group More examples
|
18
|
+
|
19
|
+
# @label AutoComplete with non-visible label
|
20
|
+
def with_non_visible_label
|
21
|
+
render(Primer::Alpha::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id-1", list_id: "test-id-1", src: "/auto_complete?version=alpha", is_label_visible: false))
|
22
|
+
end
|
23
|
+
|
24
|
+
# @label AutoComplete with inline label
|
25
|
+
def with_inline_label
|
26
|
+
render(Primer::Alpha::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id-2", list_id: "test-id-2", src: "/auto_complete?version=alpha", is_label_inline: true))
|
27
|
+
end
|
28
|
+
|
29
|
+
# @label AutoComplete with search icon
|
30
|
+
def with_icon
|
31
|
+
render(Primer::Alpha::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id-3", list_id: "test-id-3", src: "/auto_complete?version=alpha", with_icon: true))
|
32
|
+
end
|
33
|
+
|
34
|
+
# @label AutoComplete with clear button
|
35
|
+
def with_clear_button
|
36
|
+
render(Primer::Alpha::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id-4", list_id: "test-id-4", src: "/auto_complete?version=alpha", is_clearable: true))
|
37
|
+
end
|
38
|
+
|
39
|
+
# @!endgroup
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label ButtonMarketing
|
6
|
+
class ButtonMarketingPreview < ViewComponent::Preview
|
7
|
+
# @label Default options
|
8
|
+
# @param scheme [Symbol] select [default, primary, outline, transparent]
|
9
|
+
# @param variant [Symbol] select [default, large]
|
10
|
+
# @param tag [Symbol] select [button, a]
|
11
|
+
# @param type [Symbol] select [button, submit]
|
12
|
+
def default(tag: :button, type: :button, scheme: :default, variant: :default)
|
13
|
+
render(Primer::Alpha::ButtonMarketing.new(tag: tag, type: type, scheme: scheme, variant: variant)) { "Default" }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<%= render(Primer::Alpha::Dialog.new(id: "my-dialog", title: title, subtitle: subtitle, visually_hide_title: false)) do |d| %>
|
2
|
+
<% d.header(show_divider: show_divider) do %>
|
3
|
+
<button class="btn">Custom Header Controls</button>
|
4
|
+
<% end %>
|
5
|
+
<% d.show_button { button_text } %>
|
6
|
+
<% d.body { "Hello World" } %>
|
7
|
+
<% end %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%= render(Primer::Alpha::Dialog.new(id: "my-dialog", title: title, subtitle: subtitle)) do |d| %>
|
2
|
+
<% d.show_button { button_text } %>
|
3
|
+
<% d.body { "Content" } %>
|
4
|
+
<% d.footer(show_divider: show_divider) do %>
|
5
|
+
<%= render(Primer::ButtonComponent.new(data: { "close-dialog-id": "my-dialog" })) { "Cancel" } %>
|
6
|
+
<%= render(Primer::ButtonComponent.new(scheme: :primary)) { "Submit" } %>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<%= render(Primer::Alpha::Dialog.new(id: "my-dialog", title: title, subtitle: subtitle)) do |d| %>
|
2
|
+
<% d.show_button { button_text } %>
|
3
|
+
<form class="pt-3">
|
4
|
+
<%= render(Primer::Alpha::Dialog::Body.new) do %>
|
5
|
+
This is a custom dialog with the body and footer wrapped in a form tag.
|
6
|
+
<% end %>
|
7
|
+
<%= render(Primer::Alpha::Dialog::Footer.new(show_divider: show_divider)) do %>
|
8
|
+
<%= render(Primer::ButtonComponent.new(data: { "close-dialog-id": "my-dialog" })) { "Cancel" } %>
|
9
|
+
<%= render(Primer::ButtonComponent.new(scheme: :primary)) { "Submit" } %>
|
10
|
+
<% end %>
|
11
|
+
</form>
|
12
|
+
<% end %>
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label Dialog
|
6
|
+
class DialogPreview < ViewComponent::Preview
|
7
|
+
# @label Default options
|
8
|
+
#
|
9
|
+
# @param title [String] text
|
10
|
+
# @param subtitle [String] text
|
11
|
+
# @param size [Symbol] select [small, medium, medium_portrait, large, xlarge]
|
12
|
+
# @param position [Symbol] select [center, left, right]
|
13
|
+
# @param position_narrow [Symbol] select [inherit, bottom, fullscreen, left, right]
|
14
|
+
# @param visually_hide_title [Boolean] toggle
|
15
|
+
# @param button_text [String] text
|
16
|
+
# @param body_text [String] text
|
17
|
+
def default(title: "Test Dialog", subtitle: nil, size: :medium, button_text: "Show Dialog", body_text: "Content", position: :center, position_narrow: :fullscreen, visually_hide_title: false)
|
18
|
+
render(Primer::Alpha::Dialog.new(title: title, subtitle: subtitle, size: size, position: position, position_narrow: position_narrow, visually_hide_title: visually_hide_title)) do |d|
|
19
|
+
d.with_show_button { button_text }
|
20
|
+
d.with_body { body_text }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# @label Long text
|
25
|
+
#
|
26
|
+
# @param title [String] text
|
27
|
+
# @param subtitle [String] text
|
28
|
+
# @param button_text [String] text
|
29
|
+
# @param size [Symbol] select [small, medium, medium_portrait, large, xlarge]
|
30
|
+
# @param position [Symbol] select [center, left, right]
|
31
|
+
# @param position_narrow [Symbol] select [inherit, bottom, fullscreen, left, right]
|
32
|
+
def long_text(title: "Test Dialog", subtitle: nil, size: :medium, button_text: "Show Dialog", position: :center, position_narrow: :fullscreen)
|
33
|
+
render(Primer::Alpha::Dialog.new(title: title, subtitle: subtitle, size: size, position: position, position_narrow: position_narrow)) do |d|
|
34
|
+
d.with_show_button { button_text }
|
35
|
+
d.with_body { "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?" }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# @label With Footer
|
40
|
+
#
|
41
|
+
# @param title [String] text
|
42
|
+
# @param subtitle [String] text
|
43
|
+
# @param button_text [String] text
|
44
|
+
# @param show_divider [Boolean] toggle
|
45
|
+
def with_footer(title: "Test Dialog", subtitle: nil, button_text: "Show Dialog", show_divider: true)
|
46
|
+
render_with_template(locals: {
|
47
|
+
title: title,
|
48
|
+
subtitle: subtitle,
|
49
|
+
button_text: button_text,
|
50
|
+
show_divider: show_divider
|
51
|
+
})
|
52
|
+
end
|
53
|
+
|
54
|
+
# @label With a Form
|
55
|
+
#
|
56
|
+
# @param title [String] text
|
57
|
+
# @param subtitle [String] text
|
58
|
+
# @param button_text [String] text
|
59
|
+
# @param show_divider [Boolean] toggle
|
60
|
+
def with_form(title: "Test Dialog", subtitle: nil, button_text: "Show Dialog", show_divider: true)
|
61
|
+
render_with_template(locals: {
|
62
|
+
title: title,
|
63
|
+
subtitle: subtitle,
|
64
|
+
button_text: button_text,
|
65
|
+
show_divider: show_divider
|
66
|
+
})
|
67
|
+
end
|
68
|
+
|
69
|
+
# @label Custom Header
|
70
|
+
#
|
71
|
+
# @param title [String] text
|
72
|
+
# @param subtitle [String] text
|
73
|
+
# @param button_text [String] text
|
74
|
+
# @param show_divider [Boolean] toggle
|
75
|
+
def custom_header(title: "Test Dialog", subtitle: nil, button_text: "Show Dialog", show_divider: true)
|
76
|
+
render_with_template(locals: {
|
77
|
+
title: title,
|
78
|
+
subtitle: subtitle,
|
79
|
+
button_text: button_text,
|
80
|
+
show_divider: show_divider
|
81
|
+
})
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label HiddenTextExpander
|
6
|
+
class HiddenTextExpanderPreview < ViewComponent::Preview
|
7
|
+
# @label Default options
|
8
|
+
# @param label [String] text
|
9
|
+
# @param inline [Boolean] toggle
|
10
|
+
def default(label: "No effect", inline: false)
|
11
|
+
render(Primer::Alpha::HiddenTextExpander.new(inline: inline, "aria-label": label))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label Layout
|
6
|
+
class LayoutPreview < ViewComponent::Preview
|
7
|
+
# @label Default options
|
8
|
+
# @param stacking_breakpoint [Symbol] select [sm, md, lg]
|
9
|
+
# @param first_in_source [Symbol] select [sidebar, main]
|
10
|
+
# @param gutter [Symbol] select [default, none, condensed, spacious]
|
11
|
+
def default(stacking_breakpoint: :sm, gutter: :default, first_in_source: :sidebar)
|
12
|
+
render(Primer::Alpha::Layout.new(stacking_breakpoint: stacking_breakpoint, gutter: gutter, first_in_source: first_in_source)) do |c|
|
13
|
+
c.with_main(bg: :attention, p: 6) do
|
14
|
+
"Main content"
|
15
|
+
end
|
16
|
+
c.with_sidebar(bg: :accent, p: 6) do
|
17
|
+
"Sidebar content"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label NavList
|
6
|
+
class NavListPreview < ViewComponent::Preview
|
7
|
+
# @label Default
|
8
|
+
def default
|
9
|
+
render(Primer::Alpha::NavList.new(selected_item_id: :code_review_limits)) do |list|
|
10
|
+
list.with_section(aria: { label: "Repository settings" }) do |section|
|
11
|
+
section.with_heading(title: "Repository settings")
|
12
|
+
|
13
|
+
section.with_item(label: "General", href: "/general") do |item|
|
14
|
+
item.with_leading_visual_icon(icon: :gear)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
list.with_section(aria: { label: "Access" }) do |section|
|
19
|
+
section.with_heading(title: "Access")
|
20
|
+
|
21
|
+
section.with_item(label: "Collaborators and teams", href: "/collaborators", selected_by_ids: :collaborators) do |item|
|
22
|
+
item.with_leading_visual_icon(icon: :people)
|
23
|
+
end
|
24
|
+
|
25
|
+
section.with_item(label: "Moderation options", href: "/moderation") do |item|
|
26
|
+
item.with_leading_visual_icon(icon: :"comment-discussion")
|
27
|
+
|
28
|
+
item.with_item(label: "Interaction limits", href: "/interaction-limits", selected_by_ids: :interaction_limits)
|
29
|
+
item.with_item(label: "Code review limits", href: "/review-limits", selected_by_ids: :code_review_limits)
|
30
|
+
item.with_item(label: "Reported content", href: "/reported-content", selected_by_ids: :reported_content)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# @label Show more item
|
37
|
+
def show_more_item
|
38
|
+
render(Primer::Alpha::NavList.new) do |list|
|
39
|
+
list.with_section(aria: { label: "List of foods" }) do |section|
|
40
|
+
section.with_heading(title: "My favorite foods")
|
41
|
+
section.with_item(label: "Popplers", href: "/foods/popplers")
|
42
|
+
section.with_item(label: "Slurm", href: "/foods/slurm")
|
43
|
+
section.with_show_more_item(label: "Show more", src: "/nav_list_items", pages: 2)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# @label Trailing action
|
49
|
+
def trailing_action
|
50
|
+
render(Primer::Alpha::NavList.new) do |list|
|
51
|
+
list.with_section(aria: { label: "List of items to buy" }) do |section|
|
52
|
+
section.with_heading(title: "Shopping list")
|
53
|
+
section.with_item(label: "Bread", href: "/list/1") do |item|
|
54
|
+
item.with_trailing_action(show_on_hover: true, icon: :plus, aria: { label: "Button tooltip" })
|
55
|
+
end
|
56
|
+
section.with_item(label: "Cheese", href: "/list/2") do |item|
|
57
|
+
item.with_trailing_action(icon: :plus, aria: { label: "Button tooltip" })
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label TabPanels
|
6
|
+
class TabPanelsPreview < ViewComponent::Preview
|
7
|
+
# @label Default options
|
8
|
+
#
|
9
|
+
# @param number_of_panels [Integer] number
|
10
|
+
# @param align [Symbol] select [left, right]
|
11
|
+
def default(number_of_panels: 3, align: :left)
|
12
|
+
render(Primer::Alpha::TabPanels.new(label: "label", align: align)) do |c|
|
13
|
+
Array.new(number_of_panels || 3) do |i|
|
14
|
+
c.tab(selected: i.zero?, id: "tab-#{i + 1}") do |t|
|
15
|
+
t.panel { "Panel #{i + 1}" }
|
16
|
+
t.text { "Tab #{i + 1}" }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label TextField
|
6
|
+
class TextFieldPreview < ViewComponent::Preview
|
7
|
+
# @label Default
|
8
|
+
#
|
9
|
+
# @param name text
|
10
|
+
# @param id text
|
11
|
+
# @param label text
|
12
|
+
# @param visually_hide_label toggle
|
13
|
+
# @param size [Symbol] select [small, medium, large]
|
14
|
+
# @param show_clear_button toggle
|
15
|
+
# @param clear_button_id text
|
16
|
+
# @param full_width toggle
|
17
|
+
# @param disabled toggle
|
18
|
+
# @param invalid toggle
|
19
|
+
# @param placeholder text
|
20
|
+
# @param inset toggle
|
21
|
+
# @param monospace toggle
|
22
|
+
# @param leading_visual_icon text
|
23
|
+
def default(
|
24
|
+
name: "my-text-field",
|
25
|
+
id: "my-text-field",
|
26
|
+
label: "My text field",
|
27
|
+
visually_hide_label: false,
|
28
|
+
size: Primer::Forms::Dsl::Input::DEFAULT_SIZE.to_s,
|
29
|
+
show_clear_button: false,
|
30
|
+
clear_button_id: "my-text-field-clear-button",
|
31
|
+
full_width: false,
|
32
|
+
disabled: false,
|
33
|
+
invalid: false,
|
34
|
+
placeholder: nil,
|
35
|
+
inset: false,
|
36
|
+
monospace: false,
|
37
|
+
leading_visual_icon: nil
|
38
|
+
)
|
39
|
+
system_arguments = {
|
40
|
+
name: name,
|
41
|
+
id: id,
|
42
|
+
label: label,
|
43
|
+
visually_hide_label: visually_hide_label,
|
44
|
+
size: size,
|
45
|
+
show_clear_button: show_clear_button,
|
46
|
+
clear_button_id: clear_button_id,
|
47
|
+
full_width: full_width,
|
48
|
+
disabled: disabled,
|
49
|
+
invalid: invalid,
|
50
|
+
placeholder: placeholder,
|
51
|
+
inset: inset,
|
52
|
+
monospace: monospace
|
53
|
+
}
|
54
|
+
|
55
|
+
if leading_visual_icon
|
56
|
+
system_arguments[:leading_visual] = {
|
57
|
+
icon: leading_visual_icon,
|
58
|
+
size: :small
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
render(Primer::Alpha::TextField.new(**system_arguments))
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label Toggle Switch
|
6
|
+
class ToggleSwitchPreview < ViewComponent::Preview
|
7
|
+
include ActionView::Helpers::FormTagHelper
|
8
|
+
|
9
|
+
def default
|
10
|
+
render(ToggleSwitch.new(src: "/toggle_switch"))
|
11
|
+
end
|
12
|
+
|
13
|
+
def checked
|
14
|
+
render(ToggleSwitch.new(src: "/toggle_switch", checked: true))
|
15
|
+
end
|
16
|
+
|
17
|
+
def disabled
|
18
|
+
render(ToggleSwitch.new(src: "/toggle_switch", enabled: false))
|
19
|
+
end
|
20
|
+
|
21
|
+
def checked_disabled
|
22
|
+
render(ToggleSwitch.new(src: "/toggle_switch", checked: true, enabled: false))
|
23
|
+
end
|
24
|
+
|
25
|
+
def small
|
26
|
+
render(ToggleSwitch.new(src: "/toggle_switch", size: :small))
|
27
|
+
end
|
28
|
+
|
29
|
+
def with_status_label_position_end
|
30
|
+
render(ToggleSwitch.new(src: "/toggle_switch", status_label_position: :end))
|
31
|
+
end
|
32
|
+
|
33
|
+
def with_a_bad_src
|
34
|
+
render(ToggleSwitch.new(src: "/foo"))
|
35
|
+
end
|
36
|
+
|
37
|
+
def with_no_src
|
38
|
+
render(ToggleSwitch.new)
|
39
|
+
end
|
40
|
+
|
41
|
+
def with_csrf_token
|
42
|
+
render(ToggleSwitch.new(src: "/toggle_switch", csrf_token: "let_me_in"))
|
43
|
+
end
|
44
|
+
|
45
|
+
def with_bad_csrf_token
|
46
|
+
render(ToggleSwitch.new(src: "/toggle_switch", csrf_token: "i_am_a_criminal"))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<div>
|
2
|
+
<%= render(Primer::Beta::Button.new(id: "button-1")) do |c| %>
|
3
|
+
<% c.with_tooltip(text: tooltip_text, type: type, direction: direction) %>
|
4
|
+
Button 1
|
5
|
+
<% end %>
|
6
|
+
<%= render(Primer::Beta::Button.new(id: "button-2")) do |c| %>
|
7
|
+
<% c.with_tooltip(text: tooltip_text, type: type, direction: direction) %>
|
8
|
+
Button 2
|
9
|
+
<% end %>
|
10
|
+
<%= render(Primer::Beta::Button.new(id: "button-3")) do |c| %>
|
11
|
+
<% c.with_tooltip(text: tooltip_text, type: type, direction: direction) %>
|
12
|
+
Button 3
|
13
|
+
<% end %>
|
14
|
+
</div>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<div>
|
2
|
+
<p>There should be no horizontal overflow and scrollbar caused by tooltip (assuming there is at least 1px of padding to the right of where the associated control is placed).</p>
|
3
|
+
<div style="float: right;">
|
4
|
+
<button id="some-button">Button with tooltip positioned to right of the page</button>
|
5
|
+
<%= render(Primer::Alpha::Tooltip.new(for_id: "some-button", type: type, text: tooltip_text, direction: direction)) %>
|
6
|
+
</div>
|
7
|
+
</div>
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label Tooltip
|
6
|
+
class TooltipPreview < ViewComponent::Preview
|
7
|
+
# @param type [Symbol] select [["Description", description], ["Label", label]]
|
8
|
+
# @param direction select [s, n, e, w, ne, nw, se, sw]
|
9
|
+
# @param tooltip_text text
|
10
|
+
def default(type: :description, direction: :s, tooltip_text: "Tooltip text")
|
11
|
+
render(Primer::Beta::Button.new(id: "button-with-tooltip")) do |c|
|
12
|
+
c.tooltip(text: tooltip_text, type: type, direction: direction)
|
13
|
+
"Button"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# @param direction select [s, n, e, w, ne, nw, se, sw]
|
18
|
+
# @param tooltip_text text
|
19
|
+
def label_tooltip_on_button_with_existing_labelledby(type: :label, direction: :s, tooltip_text: "Tooltip text")
|
20
|
+
render(Primer::Beta::Button.new(id: "button-with-existing-label", "aria-labelledby": "existing-label-id")) do |c|
|
21
|
+
c.tooltip(text: tooltip_text, type: type, direction: direction)
|
22
|
+
"Button"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param direction select [s, n, e, w, ne, nw, se, sw]
|
27
|
+
# @param tooltip_text text
|
28
|
+
def description_tooltip_on_button_with_existing_describedby(type: :description, direction: :s, tooltip_text: "Tooltip text")
|
29
|
+
render(Primer::Beta::Button.new(id: "button-with-existing-description", "aria-describedby": "existing-description-id")) do |c|
|
30
|
+
c.tooltip(text: tooltip_text, type: type, direction: direction)
|
31
|
+
"Button"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# @param direction select [s, n, e, w, ne, nw, se, sw]
|
36
|
+
# @param tooltip_text text
|
37
|
+
def with_right_most_position(type: :description, direction: :s, tooltip_text: "A tooltip with very very very very long description that is not very concise...")
|
38
|
+
render_with_template(
|
39
|
+
locals: {
|
40
|
+
type: type,
|
41
|
+
direction: direction,
|
42
|
+
tooltip_text: tooltip_text
|
43
|
+
}
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
# @param direction select [s, n, e, w, ne, nw, se, sw]
|
48
|
+
# @param tooltip_text text
|
49
|
+
def with_multiple_on_a_page(type: :description, direction: :s, tooltip_text: "Tooltip text")
|
50
|
+
render_with_template(
|
51
|
+
locals: {
|
52
|
+
type: type,
|
53
|
+
direction: direction,
|
54
|
+
tooltip_text: tooltip_text
|
55
|
+
}
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
# @!group Tooltip enabled elements
|
60
|
+
# @label Tooltip with Primer::Beta::Button
|
61
|
+
def tooltip_with_button(type: :description, direction: :s, tooltip_text: "Tooltip text")
|
62
|
+
render(Primer::Beta::Button.new(id: "button-with-tooltip")) do |c|
|
63
|
+
c.tooltip(text: tooltip_text, type: type, direction: direction)
|
64
|
+
"Button"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# @label Tooltip with Primer::LinkComponent
|
69
|
+
def tooltip_with_link(type: :description, direction: :s, tooltip_text: "Tooltip text")
|
70
|
+
render(Primer::LinkComponent.new(href: "#link-with-tooltip", id: "link-with-tooltip")) do |c|
|
71
|
+
c.tooltip(text: tooltip_text, type: type, direction: direction)
|
72
|
+
"Button"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# @label Tooltip with Primer::IconButton
|
77
|
+
def tooltip_with_icon_button(direction: :s, tooltip_text: "Tooltip text")
|
78
|
+
render(Primer::IconButton.new(icon: :search, "aria-label": tooltip_text, tooltip_direction: direction))
|
79
|
+
end
|
80
|
+
# @!endgroup
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%= render(Primer::Alpha::UnderlineNav.new(label: label, tag: tag, align: align)) do |component| %>
|
2
|
+
<% Array.new(number_of_panels || 3) do |i| %>
|
3
|
+
<% component.with_tab(href: "#", selected: i.zero?) { "Item #{i + 1}" } %>
|
4
|
+
<% end %>
|
5
|
+
<% component.with_actions do %>
|
6
|
+
<%= render(Primer::ButtonComponent.new) { "Button" } %>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label UnderlineNav
|
6
|
+
class UnderlineNavPreview < ViewComponent::Preview
|
7
|
+
# @label Default options
|
8
|
+
#
|
9
|
+
# @param label [String] text
|
10
|
+
# @param tag [Symbol] select [div, nav]
|
11
|
+
# @param align [Symbol] select [left, right]
|
12
|
+
# @param number_of_panels [Integer] number
|
13
|
+
def default(label: "Default with nav element", tag: :nav, align: :left, number_of_panels: 3)
|
14
|
+
render_with_template(locals: {
|
15
|
+
label: label,
|
16
|
+
tag: tag,
|
17
|
+
align: align,
|
18
|
+
number_of_panels: number_of_panels
|
19
|
+
})
|
20
|
+
end
|
21
|
+
|
22
|
+
# @label With icons and counters
|
23
|
+
#
|
24
|
+
# @param label [String] text
|
25
|
+
# @param tag [Symbol] select [div, nav]
|
26
|
+
# @param align [Symbol] select [left, right]
|
27
|
+
# @param number_of_panels [Integer] number
|
28
|
+
def with_icons_and_counters(label: "With icons and counters", number_of_panels: 3, align: :left, tag: :nav)
|
29
|
+
render(Primer::Alpha::UnderlineNav.new(label: label, tag: tag, align: align)) do |component|
|
30
|
+
Array.new(number_of_panels || 3) do |i|
|
31
|
+
component.with_tab(href: "#", selected: i.zero?) do |t|
|
32
|
+
t.icon(icon: :star)
|
33
|
+
t.text { "Item #{i + 1}" }
|
34
|
+
t.counter(count: rand(1..10))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label UnderlinePanels
|
6
|
+
class UnderlinePanelsPreview < ViewComponent::Preview
|
7
|
+
# @label Default options
|
8
|
+
#
|
9
|
+
# @param number_of_panels [Integer] number
|
10
|
+
# @param align [Symbol] select [left, right]
|
11
|
+
def default(number_of_panels: 3, align: :left)
|
12
|
+
render(Primer::Alpha::UnderlinePanels.new(label: "Test navigation", align: align)) do |c|
|
13
|
+
Array.new(number_of_panels || 3) do |i|
|
14
|
+
c.tab(selected: i.zero?, id: "tab-#{i + 1}") do |t|
|
15
|
+
t.panel { "Panel #{i + 1}" }
|
16
|
+
t.text { "Tab #{i + 1}" }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= render(
|
2
|
+
Primer::Beta::AutoComplete::Item.new(
|
3
|
+
description_variant: description_variant,
|
4
|
+
selected: selected,
|
5
|
+
disabled: disabled,
|
6
|
+
value: ''
|
7
|
+
)) do |c| %>
|
8
|
+
<% c.leading_visual_icon(icon: :search) %>
|
9
|
+
<% c.description { "Description" } %>
|
10
|
+
Label text
|
11
|
+
<% end %>
|