primer_view_components 0.5.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +90 -0
- data/app/assets/javascripts/app/components/primer/alpha/action_menu/action_menu_element.d.ts +3 -2
- data/app/assets/javascripts/app/components/primer/alpha/x_banner.d.ts +3 -1
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/assets/styles/primer_view_components.css +1 -1
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_bar.rb +0 -8
- data/app/components/primer/alpha/action_list/item.rb +17 -6
- data/app/components/primer/alpha/action_list.css +1 -1
- data/app/components/primer/alpha/action_list.css.json +2 -0
- data/app/components/primer/alpha/action_list.css.map +1 -1
- data/app/components/primer/alpha/action_list.pcss +4 -2
- data/app/components/primer/alpha/action_list.rb +61 -6
- data/app/components/primer/alpha/action_menu/action_menu_element.d.ts +3 -2
- data/app/components/primer/alpha/action_menu/action_menu_element.js +17 -3
- data/app/components/primer/alpha/action_menu/action_menu_element.ts +20 -6
- data/app/components/primer/alpha/action_menu/list.rb +63 -34
- data/app/components/primer/alpha/action_menu.rb +12 -269
- data/app/components/primer/alpha/auto_complete/item.rb +0 -12
- data/app/components/primer/alpha/auto_complete.css +1 -1
- data/app/components/primer/alpha/auto_complete.css.map +1 -1
- data/app/components/primer/alpha/auto_complete.rb +0 -47
- data/app/components/primer/alpha/banner.css +1 -1
- data/app/components/primer/alpha/banner.css.map +1 -1
- data/app/components/primer/alpha/banner.html.erb +1 -1
- data/app/components/primer/alpha/banner.rb +12 -39
- data/app/components/primer/alpha/button_marketing.rb +0 -12
- data/app/components/primer/alpha/dialog.css +1 -1
- data/app/components/primer/alpha/dialog.css.map +1 -1
- data/app/components/primer/alpha/dialog.pcss +1 -1
- data/app/components/primer/alpha/dialog.rb +2 -18
- data/app/components/primer/alpha/dropdown.css +1 -1
- data/app/components/primer/alpha/dropdown.css.map +1 -1
- data/app/components/primer/alpha/dropdown.rb +0 -105
- data/app/components/primer/alpha/form_control.rb +0 -11
- data/app/components/primer/alpha/hellip_button.rb +0 -9
- data/app/components/primer/alpha/hidden_text_expander.rb +0 -9
- data/app/components/primer/alpha/image.rb +0 -16
- data/app/components/primer/alpha/image_crop.rb +0 -11
- data/app/components/primer/alpha/layout.css +1 -1
- data/app/components/primer/alpha/layout.css.map +1 -1
- data/app/components/primer/alpha/layout.pcss +1 -1
- data/app/components/primer/alpha/layout.rb +0 -118
- data/app/components/primer/alpha/menu.css +1 -1
- data/app/components/primer/alpha/menu.css.map +1 -1
- data/app/components/primer/alpha/menu.rb +0 -19
- data/app/components/primer/alpha/multi_input.rb +0 -33
- data/app/components/primer/alpha/nav_list/group.rb +12 -3
- data/app/components/primer/alpha/nav_list.rb +79 -84
- data/app/components/primer/alpha/navigation/tab.rb +0 -35
- data/app/components/primer/alpha/octicon_symbols.rb +0 -6
- data/app/components/primer/alpha/overlay.rb +0 -14
- data/app/components/primer/alpha/segmented_control.css +1 -1
- data/app/components/primer/alpha/segmented_control.css.map +1 -1
- data/app/components/primer/alpha/segmented_control.rb +0 -61
- data/app/components/primer/alpha/tab_container.rb +0 -18
- data/app/components/primer/alpha/tab_nav.css +1 -1
- data/app/components/primer/alpha/tab_nav.css.map +1 -1
- data/app/components/primer/alpha/tab_nav.rb +0 -63
- data/app/components/primer/alpha/tab_panels.rb +0 -16
- data/app/components/primer/alpha/text_field.css +1 -1
- data/app/components/primer/alpha/text_field.css.map +1 -1
- data/app/components/primer/alpha/text_field.rb +0 -68
- data/app/components/primer/alpha/toggle_switch.css +1 -1
- data/app/components/primer/alpha/toggle_switch.css.map +1 -1
- data/app/components/primer/alpha/toggle_switch.rb +0 -18
- data/app/components/primer/alpha/tool_tip.js +3 -3
- data/app/components/primer/alpha/tool_tip.ts +3 -3
- data/app/components/primer/alpha/tooltip.rb +1 -69
- data/app/components/primer/alpha/underline_nav.css +1 -1
- data/app/components/primer/alpha/underline_nav.css.map +1 -1
- data/app/components/primer/alpha/underline_nav.rb +0 -61
- data/app/components/primer/alpha/underline_panels.rb +0 -19
- data/app/components/primer/alpha/x_banner.d.ts +3 -1
- data/app/components/primer/alpha/x_banner.js +24 -10
- data/app/components/primer/alpha/x_banner.ts +14 -12
- data/app/components/primer/base_component.rb +1 -1
- data/app/components/primer/beta/auto_complete/item.rb +0 -8
- data/app/components/primer/beta/auto_complete.rb +0 -56
- data/app/components/primer/beta/avatar.css +1 -1
- data/app/components/primer/beta/avatar.css.map +1 -1
- data/app/components/primer/beta/avatar.rb +1 -19
- data/app/components/primer/beta/avatar_stack.css +1 -1
- data/app/components/primer/beta/avatar_stack.css.map +1 -1
- data/app/components/primer/beta/avatar_stack.rb +0 -21
- data/app/components/primer/beta/base_button.rb +0 -4
- data/app/components/primer/beta/blankslate.css +1 -1
- data/app/components/primer/beta/blankslate.css.map +1 -1
- data/app/components/primer/beta/blankslate.rb +0 -104
- data/app/components/primer/beta/border_box/header.rb +4 -11
- data/app/components/primer/beta/border_box.css +1 -1
- data/app/components/primer/beta/border_box.css.map +1 -1
- data/app/components/primer/beta/border_box.html.erb +2 -2
- data/app/components/primer/beta/border_box.rb +11 -55
- data/app/components/primer/beta/breadcrumbs.rb +0 -7
- data/app/components/primer/beta/button.css +1 -1
- data/app/components/primer/beta/button.css.map +1 -1
- data/app/components/primer/beta/button.pcss +3 -3
- data/app/components/primer/beta/button.rb +2 -43
- data/app/components/primer/beta/button_group.css +1 -1
- data/app/components/primer/beta/button_group.css.map +1 -1
- data/app/components/primer/beta/button_group.rb +0 -16
- data/app/components/primer/beta/clipboard_copy.rb +0 -12
- data/app/components/primer/beta/close_button.rb +0 -3
- data/app/components/primer/beta/counter.rb +0 -8
- data/app/components/primer/beta/details.rb +0 -11
- data/app/components/primer/beta/flash.css +1 -1
- data/app/components/primer/beta/flash.css.map +1 -1
- data/app/components/primer/beta/flash.rb +1 -23
- data/app/components/primer/beta/heading.rb +0 -8
- data/app/components/primer/beta/icon_button.rb +0 -21
- data/app/components/primer/beta/label.css +1 -1
- data/app/components/primer/beta/label.css.map +1 -1
- data/app/components/primer/beta/label.rb +0 -20
- data/app/components/primer/beta/link.rb +0 -22
- data/app/components/primer/beta/markdown.rb +1 -262
- data/app/components/primer/beta/octicon.rb +0 -10
- data/app/components/primer/beta/popover.css +1 -1
- data/app/components/primer/beta/popover.css.map +1 -1
- data/app/components/primer/beta/popover.rb +0 -43
- data/app/components/primer/beta/progress_bar.rb +1 -22
- data/app/components/primer/beta/relative_time.rb +0 -9
- data/app/components/primer/beta/spinner.rb +2 -10
- data/app/components/primer/beta/state.rb +0 -13
- data/app/components/primer/beta/subhead.rb +0 -55
- data/app/components/primer/beta/text.rb +0 -4
- data/app/components/primer/beta/timeline_item.css +1 -1
- data/app/components/primer/beta/timeline_item.css.map +1 -1
- data/app/components/primer/beta/timeline_item.rb +0 -9
- data/app/components/primer/beta/truncate.rb +0 -50
- data/app/components/primer/blankslate_component.rb +0 -76
- data/app/components/primer/box.rb +0 -6
- data/app/components/primer/button_component.rb +0 -49
- data/app/components/primer/conditional_wrapper.rb +2 -17
- data/app/components/primer/icon_button.rb +0 -30
- data/app/components/primer/layout_component.rb +0 -12
- data/app/components/primer/tooltip.rb +0 -27
- data/app/components/primer/truncate.rb +0 -19
- data/app/forms/submit_button_form.rb +1 -1
- data/lib/primer/accessibility.rb +1 -1
- data/lib/primer/classify/utilities.yml +2 -0
- data/lib/primer/deprecations.yml +3 -3
- data/lib/primer/forms/button.rb +0 -5
- data/lib/primer/forms/dsl/input.rb +3 -0
- data/lib/primer/static/generate_info_arch.rb +1 -0
- data/lib/primer/view_components/linters/details_menu_migration.rb +1 -1
- data/lib/primer/view_components/linters/migrations/truncate_component.rb +45 -0
- data/lib/primer/view_components/linters/tooltipped_migration.rb +1 -1
- data/lib/primer/view_components/linters.rb +1 -0
- data/lib/primer/view_components/version.rb +2 -2
- data/lib/primer/yard/lookbook_pages_backend.rb +31 -0
- data/lib/primer/yard.rb +8 -9
- data/lib/tasks/custom_utilities.yml +2 -0
- data/previews/primer/alpha/action_list_preview.rb +89 -17
- data/previews/primer/alpha/action_menu_preview.rb +79 -37
- data/previews/primer/alpha/banner_preview/with_action_button.html.erb +1 -1
- data/previews/primer/alpha/banner_preview/with_action_content.html.erb +1 -1
- data/previews/primer/alpha/banner_preview.rb +11 -14
- data/previews/primer/alpha/nav_list_preview.rb +17 -0
- data/previews/primer/alpha/tooltip_preview/with_multiple_on_a_page.html.erb +3 -3
- data/previews/primer/alpha/tooltip_preview.rb +11 -23
- data/static/arguments.json +18 -13
- data/static/constants.json +6 -0
- data/static/info_arch.json +493 -36
- data/static/previews.json +15 -15
- metadata +3 -3
- data/lib/primer/yard/legacy_gatsby_backend.rb +0 -233
@@ -13,8 +13,69 @@ module Primer
|
|
13
13
|
# Adds a new item to the list.
|
14
14
|
#
|
15
15
|
# @param data [Hash] When the menu is used as a form input (see the <%= link_to_component(Primer::Alpha::ActionMenu) %> docs), the label is submitted to the server by default. However, if the `data: { value: }` or `"data-value":` attribute is provided, it will be sent to the server instead.
|
16
|
-
# @param system_arguments [Hash]
|
16
|
+
# @param system_arguments [Hash] These arguments are forwarded to <%= link_to_component(Primer::Alpha::ActionList::Item) %>, or whatever class is passed as the `component_klass` argument.
|
17
17
|
def with_item(data: {}, **system_arguments, &block)
|
18
|
+
system_arguments = organize_arguments(data: data, **system_arguments)
|
19
|
+
|
20
|
+
super(**system_arguments) do |item|
|
21
|
+
evaluate_block(item, &block)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Adds an avatar item to the list. Avatar items are a convenient way to accessibly add an item with a leading avatar image.
|
26
|
+
#
|
27
|
+
# @param src [String] The source url of the avatar image.
|
28
|
+
# @param username [String] The username associated with the avatar.
|
29
|
+
# @param full_name [String] Optional. The user's full name.
|
30
|
+
# @param full_name_scheme [Symbol] Optional. How to display the user's full name. <%= one_of(Primer::Alpha::ActionList::Item::DESCRIPTION_SCHEME_OPTIONS) %>
|
31
|
+
# @param data [Hash] When the menu is used as a form input (see the <%= link_to_component(Primer::Alpha::ActionMenu) %> docs), the label is submitted to the server by default. However, if the `data: { value: }` or `"data-value":` attribute is provided, it will be sent to the server instead.
|
32
|
+
# @param avatar_arguments [Hash] Optional. The arguments accepted by <%= link_to_component(Primer::Beta::Avatar) %>.
|
33
|
+
# @param system_arguments [Hash] These arguments are forwarded to <%= link_to_component(Primer::Alpha::ActionList::Item) %>, or whatever class is passed as the `component_klass` argument.
|
34
|
+
def with_avatar_item(src:, username:, full_name: nil, full_name_scheme: Primer::Alpha::ActionList::Item::DEFAULT_DESCRIPTION_SCHEME, data: {}, avatar_arguments: {}, **system_arguments, &block)
|
35
|
+
system_arguments = organize_arguments(data: data, **system_arguments)
|
36
|
+
|
37
|
+
super(src: src, username: username, full_name: full_name, full_name_scheme: full_name_scheme, avatar_arguments: avatar_arguments, **system_arguments) do |item|
|
38
|
+
evaluate_block(item, &block)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# @param menu_id [String] ID of the parent menu.
|
43
|
+
# @param system_arguments [Hash] The arguments accepted by <%= link_to_component(Primer::Alpha::ActionList) %>
|
44
|
+
def initialize(menu_id:, **system_arguments, &block)
|
45
|
+
@menu_id = menu_id
|
46
|
+
|
47
|
+
system_arguments[:aria] = merge_aria(
|
48
|
+
system_arguments,
|
49
|
+
{ aria: { labelledby: "#{@menu_id}-button" } }
|
50
|
+
)
|
51
|
+
|
52
|
+
system_arguments[:role] = :menu
|
53
|
+
system_arguments[:scheme] = :inset
|
54
|
+
system_arguments[:id] = "#{@menu_id}-list"
|
55
|
+
|
56
|
+
super(**system_arguments, &block)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def evaluate_block(*args, &block)
|
62
|
+
# Prevent double renders by using the capture method on the component
|
63
|
+
# that originally received the block.
|
64
|
+
#
|
65
|
+
# Handle blocks that originate from C code such as `&:method` by checking
|
66
|
+
# source_location. Such blocks don't allow access to their receiver.
|
67
|
+
return unless block&.source_location
|
68
|
+
|
69
|
+
block_context = block.binding.receiver
|
70
|
+
|
71
|
+
if block_context.class < ActionView::Base
|
72
|
+
block_context.capture(*args, &block)
|
73
|
+
else
|
74
|
+
capture(*args, &block)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def organize_arguments(data: {}, **system_arguments)
|
18
79
|
content_arguments = system_arguments.delete(:content_arguments) || {}
|
19
80
|
|
20
81
|
# rubocop:disable Style/IfUnlessModifier
|
@@ -54,39 +115,7 @@ module Primer
|
|
54
115
|
content_arguments[:disabled] = "" if content_arguments[:tag] == :button
|
55
116
|
end
|
56
117
|
|
57
|
-
|
58
|
-
# Prevent double renders by using the capture method on the component
|
59
|
-
# that originally received the block.
|
60
|
-
#
|
61
|
-
# Handle blocks that originate from C code such as `&:method` by checking
|
62
|
-
# source_location. Such blocks don't allow access to their receiver.
|
63
|
-
if block&.source_location
|
64
|
-
block_context = block.binding.receiver
|
65
|
-
|
66
|
-
if block_context.class < ActionView::Base
|
67
|
-
block_context.capture(item, &block)
|
68
|
-
else
|
69
|
-
capture(item, &block)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# @param menu_id [String] ID of the parent menu.
|
76
|
-
# @param system_arguments [Hash] The arguments accepted by <%= link_to_component(Primer::Alpha::ActionList) %>
|
77
|
-
def initialize(menu_id:, **system_arguments, &block)
|
78
|
-
@menu_id = menu_id
|
79
|
-
|
80
|
-
system_arguments[:aria] = merge_aria(
|
81
|
-
system_arguments,
|
82
|
-
{ aria: { labelledby: "#{@menu_id}-button" } }
|
83
|
-
)
|
84
|
-
|
85
|
-
system_arguments[:role] = :menu
|
86
|
-
system_arguments[:scheme] = :inset
|
87
|
-
system_arguments[:id] = "#{@menu_id}-list"
|
88
|
-
|
89
|
-
super(**system_arguments, &block)
|
118
|
+
{ data: data, **system_arguments, content_arguments: content_arguments }
|
90
119
|
end
|
91
120
|
end
|
92
121
|
end
|
@@ -27,275 +27,6 @@ module Primer
|
|
27
27
|
|
28
28
|
alias preload? preload
|
29
29
|
|
30
|
-
# @example Default
|
31
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-0") do |c| %>
|
32
|
-
# <% c.with_show_button { "Menu" } %>
|
33
|
-
# <% c.with_item(tag: :a, href: "https://primer.style/design/") do %>
|
34
|
-
# Primer Design
|
35
|
-
# <% end %>
|
36
|
-
# <% c.with_item(tag: :button, type: "button", onclick: "() => {}") do %>
|
37
|
-
# Quote Reply
|
38
|
-
# <% end %>
|
39
|
-
# <% c.with_item(tag: :"clipboard-copy", value: "Text to copy") do %>
|
40
|
-
# Copy Text
|
41
|
-
# <% end %>
|
42
|
-
# <% c.with_item(href: "https://google.com", form_arguments: { name: "foo", value: "bar", method: :post }) do %>
|
43
|
-
# Submit form
|
44
|
-
# <% end %>
|
45
|
-
# <% end %>
|
46
|
-
#
|
47
|
-
# @example With caret
|
48
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-1") do |c| %>
|
49
|
-
# <% c.with_show_button do |button| %>
|
50
|
-
# <% button.with_trailing_action_icon(icon: "triangle-down") %>
|
51
|
-
# Menu
|
52
|
-
# <% end %>
|
53
|
-
# <% c.with_item(tag: :a, href: "https://primer.style/design/") do %>
|
54
|
-
# Primer Design
|
55
|
-
# <% end %>
|
56
|
-
# <% c.with_item(tag: :button, type: "button") do %>
|
57
|
-
# Quote Reply
|
58
|
-
# <% end %>
|
59
|
-
# <% c.with_item(tag: :"clipboard-copy", value: "Text to copy") do %>
|
60
|
-
# Copy Text
|
61
|
-
# <% end %>
|
62
|
-
# <% end %>
|
63
|
-
#
|
64
|
-
# @example With `IconButton` trigger
|
65
|
-
# @description
|
66
|
-
# Set `icon:` to the octicon you want to use. Always provide an accessible name for the menu by setting `aria-label`.
|
67
|
-
# @code
|
68
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-2") do |c| %>
|
69
|
-
# <% c.with_show_button(icon: :"kebab-horizontal", "aria-label": "Menu") %>
|
70
|
-
# <% c.with_item(tag: :a, href: "https://primer.style/design/") do %>
|
71
|
-
# Primer Design Link
|
72
|
-
# <% end %>
|
73
|
-
# <% c.with_item(tag: :button, type: "button") do %>
|
74
|
-
# Quote Reply
|
75
|
-
# <% end %>
|
76
|
-
# <% c.with_item(tag: :"clipboard-copy", value: "Text to copy") do %>
|
77
|
-
# Copy Text
|
78
|
-
# <% end %>
|
79
|
-
# <% end %>
|
80
|
-
#
|
81
|
-
# @example With divider
|
82
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-3") do |c| %>
|
83
|
-
# <% c.with_show_button(icon: :"kebab-horizontal", "aria-label": "Menu") %>
|
84
|
-
# <% c.with_item(tag: :a, href: "https://primer.style/design/") do %>
|
85
|
-
# Primer Design Link
|
86
|
-
# <% end %>
|
87
|
-
# <% c.with_item(tag: :button, type: "button") do %>
|
88
|
-
# Quote Reply
|
89
|
-
# <% end %>
|
90
|
-
# <% c.with_divider %>
|
91
|
-
# <% c.with_item(tag: :"clipboard-copy", value: "Text to copy") do %>
|
92
|
-
# Copy Text
|
93
|
-
# <% end %>
|
94
|
-
# <% end %>
|
95
|
-
#
|
96
|
-
# @example With danger item
|
97
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-4") do |c| %>
|
98
|
-
# <% c.with_show_button(icon: :"kebab-horizontal", "aria-label": "Menu") %>
|
99
|
-
# <% c.with_item(tag: :a, href: "https://primer.style/design/") do %>
|
100
|
-
# Primer Design Link
|
101
|
-
# <% end %>
|
102
|
-
# <% c.with_item(tag: :button, type: "button") do %>
|
103
|
-
# Quote Reply
|
104
|
-
# <% end %>
|
105
|
-
# <% c.with_item(tag: :"clipboard-copy", value: "Text to copy") do %>
|
106
|
-
# Copy Text
|
107
|
-
# <% end %>
|
108
|
-
# <% c.with_item(tag: :button, type: "button", scheme: :danger) do %>
|
109
|
-
# Delete
|
110
|
-
# <% end %>
|
111
|
-
# <% end %>
|
112
|
-
#
|
113
|
-
# @example With center align
|
114
|
-
# @description
|
115
|
-
# Align the menu to the center of the trigger button
|
116
|
-
# @code
|
117
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-5", anchor_align: :center, anchor_side: :outside_top) do |c| %>
|
118
|
-
# <% c.with_show_button do |button| %>
|
119
|
-
# <% button.with_trailing_action_icon(icon: "triangle-down") %>
|
120
|
-
# Outside top
|
121
|
-
# <% end %>
|
122
|
-
# <% c.with_item do %>
|
123
|
-
# Item 1 that does something
|
124
|
-
# <% end %>
|
125
|
-
# <% c.with_item do %>
|
126
|
-
# Item 2 that does another thing
|
127
|
-
# <% end %>
|
128
|
-
# <% end %>
|
129
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-6", anchor_align: :center, anchor_side: :outside_left) do |c| %>
|
130
|
-
# <% c.with_show_button do |button| %>
|
131
|
-
# <% button.with_trailing_action_icon(icon: "triangle-down") %>
|
132
|
-
# Outside left
|
133
|
-
# <% end %>
|
134
|
-
# <% c.with_item do %>
|
135
|
-
# Item 1 that does something
|
136
|
-
# <% end %>
|
137
|
-
# <% c.with_item do %>
|
138
|
-
# Item 2 that does another thing
|
139
|
-
# <% end %>
|
140
|
-
# <% end %>
|
141
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-7", anchor_align: :center, anchor_side: :outside_right) do |c| %>
|
142
|
-
# <% c.with_show_button do |button| %>
|
143
|
-
# <% button.with_trailing_action_icon(icon: "triangle-down") %>
|
144
|
-
# Outside right
|
145
|
-
# <% end %>
|
146
|
-
# <% c.with_item do %>
|
147
|
-
# Item 1 that does something
|
148
|
-
# <% end %>
|
149
|
-
# <% c.with_item do %>
|
150
|
-
# Item 2 that does another thing
|
151
|
-
# <% end %>
|
152
|
-
# <% end %>
|
153
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-8", anchor_align: :center, anchor_side: :outside_bottom) do |c| %>
|
154
|
-
# <% c.with_show_button do |button| %>
|
155
|
-
# <% button.with_trailing_action_icon(icon: "triangle-down") %>
|
156
|
-
# Outside bottom
|
157
|
-
# <% end %>
|
158
|
-
# <% c.with_item do %>
|
159
|
-
# Item 1 that does something
|
160
|
-
# <% end %>
|
161
|
-
# <% c.with_item do %>
|
162
|
-
# Item 2 that does another thing
|
163
|
-
# <% end %>
|
164
|
-
# <% end %>
|
165
|
-
#
|
166
|
-
# @example With start align
|
167
|
-
# @description
|
168
|
-
# Align the menu to the start of the trigger button
|
169
|
-
# @code
|
170
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-9", anchor_align: :start, anchor_side: :outside_top) do |c| %>
|
171
|
-
# <% c.with_show_button do |button| %>
|
172
|
-
# <% button.with_trailing_action_icon(icon: "triangle-down") %>
|
173
|
-
# Outside top
|
174
|
-
# <% end %>
|
175
|
-
# <% c.with_item do %>
|
176
|
-
# Item 1 that does something
|
177
|
-
# <% end %>
|
178
|
-
# <% c.with_item do %>
|
179
|
-
# Item 2 that does another thing
|
180
|
-
# <% end %>
|
181
|
-
# <% end %>
|
182
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-10", anchor_align: :start, anchor_side: :outside_left) do |c| %>
|
183
|
-
# <% c.with_show_button do |button| %>
|
184
|
-
# <% button.with_trailing_action_icon(icon: "triangle-down") %>
|
185
|
-
# Outside left
|
186
|
-
# <% end %>
|
187
|
-
# <% c.with_item do %>
|
188
|
-
# Item 1 that does something
|
189
|
-
# <% end %>
|
190
|
-
# <% c.with_item do %>
|
191
|
-
# Item 2 that does another thing
|
192
|
-
# <% end %>
|
193
|
-
# <% end %>
|
194
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-11", anchor_align: :start, anchor_side: :outside_right) do |c| %>
|
195
|
-
# <% c.with_show_button do |button| %>
|
196
|
-
# <% button.with_trailing_action_icon(icon: "triangle-down") %>
|
197
|
-
# Outside right
|
198
|
-
# <% end %>
|
199
|
-
# <% c.with_item do %>
|
200
|
-
# Item 1 that does something
|
201
|
-
# <% end %>
|
202
|
-
# <% c.with_item do %>
|
203
|
-
# Item 2 that does another thing
|
204
|
-
# <% end %>
|
205
|
-
# <% end %>
|
206
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-12", anchor_align: :start, anchor_side: :outside_bottom) do |c| %>
|
207
|
-
# <% c.with_show_button do |button| %>
|
208
|
-
# <% button.with_trailing_action_icon(icon: "triangle-down") %>
|
209
|
-
# Outside bottom
|
210
|
-
# <% end %>
|
211
|
-
# <% c.with_item do %>
|
212
|
-
# Item 1 that does something
|
213
|
-
# <% end %>
|
214
|
-
# <% c.with_item do %>
|
215
|
-
# Item 2 that does another thing
|
216
|
-
# <% end %>
|
217
|
-
# <% end %>
|
218
|
-
#
|
219
|
-
# @example With end align
|
220
|
-
# @description
|
221
|
-
# Align the menu to the end of the trigger button
|
222
|
-
# @code
|
223
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-13", anchor_align: :end, anchor_side: :outside_top) do |c| %>
|
224
|
-
# <% c.with_show_button do |button| %>
|
225
|
-
# <% button.with_trailing_action_icon(icon: "triangle-down") %>
|
226
|
-
# Outside top
|
227
|
-
# <% end %>
|
228
|
-
# <% c.with_item do %>
|
229
|
-
# Item 1 that does something
|
230
|
-
# <% end %>
|
231
|
-
# <% c.with_item do %>
|
232
|
-
# Item 2 that does another thing
|
233
|
-
# <% end %>
|
234
|
-
# <% end %>
|
235
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-14", anchor_align: :end, anchor_side: :outside_left) do |c| %>
|
236
|
-
# <% c.with_show_button do |button| %>
|
237
|
-
# <% button.with_trailing_action_icon(icon: "triangle-down") %>
|
238
|
-
# Outside left
|
239
|
-
# <% end %>
|
240
|
-
# <% c.with_item do %>
|
241
|
-
# Item 1 that does something
|
242
|
-
# <% end %>
|
243
|
-
# <% c.with_item do %>
|
244
|
-
# Item 2 that does another thing
|
245
|
-
# <% end %>
|
246
|
-
# <% end %>
|
247
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-15", anchor_align: :end, anchor_side: :outside_right) do |c| %>
|
248
|
-
# <% c.with_show_button do |button| %>
|
249
|
-
# <% button.with_trailing_action_icon(icon: "triangle-down") %>
|
250
|
-
# Outside right
|
251
|
-
# <% end %>
|
252
|
-
# <% c.with_item do %>
|
253
|
-
# Item 1 that does something
|
254
|
-
# <% end %>
|
255
|
-
# <% c.with_item do %>
|
256
|
-
# Item 2 that does another thing
|
257
|
-
# <% end %>
|
258
|
-
# <% end %>
|
259
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-16", anchor_align: :end, anchor_side: :outside_bottom) do |c| %>
|
260
|
-
# <% c.with_show_button do |button| %>
|
261
|
-
# <% button.with_trailing_action_icon(icon: "triangle-down") %>
|
262
|
-
# Outside bottom
|
263
|
-
# <% end %>
|
264
|
-
# <% c.with_item do %>
|
265
|
-
# Item 1 that does something
|
266
|
-
# <% end %>
|
267
|
-
# <% c.with_item do %>
|
268
|
-
# Item 2 that does another thing
|
269
|
-
# <% end %>
|
270
|
-
# <% end %>
|
271
|
-
#
|
272
|
-
# @example With deferred menu content loaded with an `include-fragment`
|
273
|
-
# <%= render Primer::Alpha::ActionMenu.new(menu_id: "my-action-menu-17", src: "/") do |c| %>
|
274
|
-
# <% c.with_show_button(icon: :"kebab-horizontal", "aria-label": "Menu") %>
|
275
|
-
# <% end %>
|
276
|
-
#
|
277
|
-
# @example Using a single-select ActionMenu as a form input
|
278
|
-
# <%= form_with(url: action_menu_form_action_path) do |f| %>
|
279
|
-
# <%= render(Primer::Alpha::ActionMenu.new(select_variant: :single, dynamic_label: true, dynamic_label_prefix: "Strategy", form_arguments: { builder: f, name: "foo" })) do |menu| %>
|
280
|
-
# <% menu.with_show_button { "Strategy" } %>
|
281
|
-
# <% menu.with_item(label: "Fast forward", data: { value: "fast_forward" }) %>
|
282
|
-
# <% menu.with_item(label: "Recursive", data: { value: "recursive" }) %>
|
283
|
-
# <% menu.with_item(label: "Ours", data: { value: "ours" }) %>
|
284
|
-
# <% menu.with_item(label: "Resolve", data: { value: "resolve" }) %>
|
285
|
-
# <% end %>
|
286
|
-
# <% end %>
|
287
|
-
#
|
288
|
-
# @example Using a multi-select ActionMenu as a form input
|
289
|
-
# <%= form_with(url: action_menu_form_action_path) do |f| %>
|
290
|
-
# <%= render(Primer::Alpha::ActionMenu.new(select_variant: :multiple, form_arguments: { builder: f, name: "foo" })) do |menu| %>
|
291
|
-
# <% menu.with_show_button { "Strategy" } %>
|
292
|
-
# <% menu.with_item(label: "Fast forward", data: { value: "fast_forward" }) %>
|
293
|
-
# <% menu.with_item(label: "Recursive", data: { value: "recursive" }) %>
|
294
|
-
# <% menu.with_item(label: "Ours", data: { value: "ours" }) %>
|
295
|
-
# <% menu.with_item(label: "Resolve", data: { value: "resolve" }) %>
|
296
|
-
# <% end %>
|
297
|
-
# <% end %>
|
298
|
-
#
|
299
30
|
# @param menu_id [String] Id of the menu.
|
300
31
|
# @param anchor_align [Symbol] <%= one_of(Primer::Alpha::Overlay::ANCHOR_ALIGN_OPTIONS) %>.
|
301
32
|
# @param anchor_side [Symbol] <%= one_of(Primer::Alpha::Overlay::ANCHOR_SIDE_OPTIONS) %>.
|
@@ -383,6 +114,18 @@ module Primer
|
|
383
114
|
@list.with_divider(**system_arguments, &block)
|
384
115
|
end
|
385
116
|
|
117
|
+
# Adds an avatar item to the list. Avatar items are a convenient way to accessibly add an item with a leading avatar image.
|
118
|
+
#
|
119
|
+
# @param src [String] The source url of the avatar image.
|
120
|
+
# @param username [String] The username associated with the avatar.
|
121
|
+
# @param full_name [String] Optional. The user's full name.
|
122
|
+
# @param full_name_scheme [Symbol] Optional. How to display the user's full name.
|
123
|
+
# @param avatar_arguments [Hash] Optional. The arguments accepted by <%= link_to_component(Primer::Beta::Avatar) %>.
|
124
|
+
# @param system_arguments [Hash] The arguments accepted by <%= link_to_component(Primer::Alpha::ActionList::Item) %>.
|
125
|
+
def with_avatar_item(**system_arguments, &block)
|
126
|
+
@list.with_avatar_item(**system_arguments, &block)
|
127
|
+
end
|
128
|
+
|
386
129
|
private
|
387
130
|
|
388
131
|
def before_render
|
@@ -7,18 +7,6 @@ module Primer
|
|
7
7
|
class Item < Primer::Component
|
8
8
|
status :deprecated
|
9
9
|
|
10
|
-
# @example Default
|
11
|
-
# <%= render(Primer::Alpha::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", input_id: "fruits-input--custom-results", list_id: "fruits-popup--custom-results")) do |component| %>
|
12
|
-
# <% component.results(classes: "custom-class") do %>
|
13
|
-
# <%= render(Primer::Alpha::AutoComplete::Item.new(selected: true, value: "apple")) do %>
|
14
|
-
# Apple
|
15
|
-
# <% end %>
|
16
|
-
# <%= render(Primer::Alpha::AutoComplete::Item.new(value: "orange")) do %>
|
17
|
-
# Orange
|
18
|
-
# <% end %>
|
19
|
-
# <% end %>
|
20
|
-
# <% end %>
|
21
|
-
#
|
22
10
|
# @param value [String] Value of the item.
|
23
11
|
# @param selected [Boolean] Whether the item is selected.
|
24
12
|
# @param disabled [Boolean] Whether the item is disabled.
|
@@ -1 +1 @@
|
|
1
|
-
.autocomplete-label-stacked{display:block;margin-bottom:6px}.autocomplete-label-inline{display:inline;margin-right:6px}@media (max-width:543.98px){.autocomplete-label-inline{display:block;margin-bottom:6px}}.autocomplete-body{display:inline;position:relative}.autocomplete-embedded-icon-wrap{align-items:center;display:inline-flex;padding:4px 8px}.autocomplete-embedded-icon-wrap:focus-within{border-color:var(--focus-outlineColor,var(--color-accent-fg));box-shadow:inset 0 0 0 1px var(--focus-outlineColor,var(--color-accent-fg));outline:none}.autocomplete-embedded-icon-wrap .form-control{border:none;box-shadow:none;margin-left:8px;padding:0}.autocomplete-embedded-icon-wrap .form-control:focus{box-shadow:none}.autocomplete-embedded-icon-wrap .form-control:focus-visible{box-shadow:none}.autocomplete-results{background:var(--overlay-bgColor,var(--color-canvas-overlay));border:var(--borderWidth-thin,max(1px,.0625rem)) solid var(--borderColor-default,var(--color-border-default));border-radius:var(--borderRadius-medium
|
1
|
+
.autocomplete-label-stacked{display:block;margin-bottom:6px}.autocomplete-label-inline{display:inline;margin-right:6px}@media (max-width:543.98px){.autocomplete-label-inline{display:block;margin-bottom:6px}}.autocomplete-body{display:inline;position:relative}.autocomplete-embedded-icon-wrap{align-items:center;display:inline-flex;padding:4px 8px}.autocomplete-embedded-icon-wrap:focus-within{border-color:var(--focus-outlineColor,var(--color-accent-fg));box-shadow:inset 0 0 0 1px var(--focus-outlineColor,var(--color-accent-fg));outline:none}.autocomplete-embedded-icon-wrap .form-control{border:none;box-shadow:none;margin-left:8px;padding:0}.autocomplete-embedded-icon-wrap .form-control:focus{box-shadow:none}.autocomplete-embedded-icon-wrap .form-control:focus-visible{box-shadow:none}.autocomplete-results{background:var(--overlay-bgColor,var(--color-canvas-overlay));border:var(--borderWidth-thin,max(1px,.0625rem)) solid var(--borderColor-default,var(--color-border-default));border-radius:var(--borderRadius-medium,.375rem);box-shadow:var(--shadow-resting-medium,var(--color-shadow-medium));font-size:13px;left:0;list-style:none;max-height:20em;min-width:100%;overflow-y:auto;position:absolute;width:max-content;z-index:99}.autocomplete-item{background-color:var(--overlay-bgColor,var(--color-canvas-overlay));border:0;color:var(--fgColor-default,var(--color-fg-default));cursor:pointer;display:block;font-weight:var(--base-text-weight-semibold,600);overflow:hidden;padding:4px 8px;text-align:left;text-decoration:none;text-overflow:ellipsis;white-space:nowrap;width:100%}.autocomplete-item:hover{background-color:var(--bgColor-accent-emphasis,var(--color-accent-emphasis));color:var(--fgColor-onEmphasis,var(--color-fg-on-emphasis));text-decoration:none}.autocomplete-item:hover *{color:inherit!important}.autocomplete-item.navigation-focus,.autocomplete-item.selected,.autocomplete-item[aria-selected=true]{background-color:var(--bgColor-accent-emphasis,var(--color-accent-emphasis));color:var(--fgColor-onEmphasis,var(--color-fg-on-emphasis));text-decoration:none}.autocomplete-item.navigation-focus *,.autocomplete-item.selected *,.autocomplete-item[aria-selected=true] *{color:inherit!important}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["auto_complete.pcss","../../../../lib/postcss_mixins/focusBoxShadowInset.pcss"],"names":[],"mappings":"AAMA,4BACE,aAAc,CACd,iBACF,CAGA,2BACE,cAAe,CACf,gBACF,CAGA,4BACE,2BACE,aAAc,CACd,iBACF,CACF,CAGA,mBAEE,cAAe,CADf,iBAEF,CAGA,iCAGE,kBAAmB,CAFnB,mBAAoB,CACpB,eAuBF,CApBE,8CCnCA,6DAAuC,CAEvC,2EAAmD,CADnD,YDsCA,CAEA,+CAGE,WAAY,CACZ,eAAgB,CAFhB,eAAgB,CADhB,SAYF,CAPE,qDACE,eACF,CAEA,6DACE,eACF,CAKJ,sBAUE,6DAAkC,CAClC,6GAAgE,CAChE,
|
1
|
+
{"version":3,"sources":["auto_complete.pcss","../../../../lib/postcss_mixins/focusBoxShadowInset.pcss"],"names":[],"mappings":"AAMA,4BACE,aAAc,CACd,iBACF,CAGA,2BACE,cAAe,CACf,gBACF,CAGA,4BACE,2BACE,aAAc,CACd,iBACF,CACF,CAGA,mBAEE,cAAe,CADf,iBAEF,CAGA,iCAGE,kBAAmB,CAFnB,mBAAoB,CACpB,eAuBF,CApBE,8CCnCA,6DAAuC,CAEvC,2EAAmD,CADnD,YDsCA,CAEA,+CAGE,WAAY,CACZ,eAAgB,CAFhB,eAAgB,CADhB,SAYF,CAPE,qDACE,eACF,CAEA,6DACE,eACF,CAKJ,sBAUE,6DAAkC,CAClC,6GAAgE,CAChE,gDAAyC,CACzC,kEAAwC,CALxC,cAAe,CANf,MAAO,CAOP,eAAgB,CAHhB,eAAgB,CADhB,cAAe,CAEf,eAAgB,CANhB,iBAAkB,CAGlB,iBAAkB,CADlB,UAWF,CAKA,mBAYE,mEAAwC,CACxC,QAAS,CAPT,oDAA6B,CAK7B,cAAe,CAVf,aAAc,CAId,gDAA6C,CAD7C,eAAgB,CADhB,eAAgB,CAIhB,eAAgB,CAChB,oBAAqB,CACrB,sBAAuB,CACvB,kBAAmB,CARnB,UAoCF,CAvBE,yBAGE,4EAAgD,CAFhD,2DAAgC,CAChC,oBAOF,CAHE,2BACE,uBACF,CAGF,uGAKE,4EAAgD,CAFhD,2DAAgC,CAChC,oBAOF,CAHE,6GACE,uBACF","file":"auto_complete.css","sourcesContent":["/* autocomplete */\n\n/* This file can be deprecated when AutoComplete is upstreamed to PVC + rolled out to dotcom https://github.com/github/primer/issues/796\n** AutoComplete relies on FormControl, Overlay and ActionList CSS */\n\n/* Stacked label (default) */\n.autocomplete-label-stacked {\n display: block;\n margin-bottom: 6px;\n}\n\n/* Inline label (non-default) */\n.autocomplete-label-inline {\n display: inline;\n margin-right: 6px;\n}\n\n/* Switch to stacked at smaller viewport */\n@media (max-width: 543.98px) {\n .autocomplete-label-inline {\n display: block;\n margin-bottom: 6px;\n }\n}\n\n/* Wrapper for the input and result elements to ensure alignment */\n.autocomplete-body {\n position: relative;\n display: inline;\n}\n\n/* Wrapper and conditional styles for when an icon is added */\n.autocomplete-embedded-icon-wrap {\n display: inline-flex;\n padding: 4px 8px;\n align-items: center;\n\n &:focus-within {\n border-color: var(--borderColor-accent-emphasis);\n\n @mixin focusBoxShadowInset;\n }\n\n & .form-control {\n padding: 0;\n margin-left: 8px;\n border: none;\n box-shadow: none;\n\n &:focus {\n box-shadow: none;\n }\n\n &:focus-visible {\n box-shadow: none;\n }\n }\n}\n\n/* A pop up list of items used to show autocompleted results */\n.autocomplete-results {\n position: absolute;\n left: 0;\n z-index: 99;\n width: max-content;\n min-width: 100%;\n max-height: 20em;\n overflow-y: auto;\n font-size: 13px;\n list-style: none;\n background: var(--overlay-bgColor);\n border: var(--borderWidth-thin) solid var(--borderColor-default);\n border-radius: var(--borderRadius-medium);\n box-shadow: var(--shadow-resting-medium);\n}\n\n/* One of the items that appears within an autocomplete group\n** Bold black text on white background */\n\n.autocomplete-item {\n display: block;\n width: 100%;\n padding: 4px 8px;\n overflow: hidden;\n font-weight: var(--base-text-weight-semibold);\n color: var(--fgColor-default);\n text-align: left;\n text-decoration: none;\n text-overflow: ellipsis;\n white-space: nowrap;\n cursor: pointer;\n background-color: var(--overlay-bgColor);\n border: 0;\n\n &:hover {\n color: var(--fgColor-onEmphasis);\n text-decoration: none;\n background-color: var(--bgColor-accent-emphasis);\n\n /* Inherit color on all child elements to ensure enough contrast */\n & * {\n color: inherit !important;\n }\n }\n\n &.selected,\n &[aria-selected='true'],\n &.navigation-focus {\n color: var(--fgColor-onEmphasis);\n text-decoration: none;\n background-color: var(--bgColor-accent-emphasis);\n\n /* Inherit color on all child elements to ensure enough contrast */\n & * {\n color: inherit !important;\n }\n }\n}\n","/* inset box-shadow for form controls */\n@define-mixin focusBoxShadowInset $outlineWidth: 1px, $outlineColor: var(--focus-outlineColor) {\n border-color: var(--focus-outlineColor);\n outline: none;\n box-shadow: inset 0 0 0 $outlineWidth $outlineColor;\n}\n"]}
|
@@ -62,53 +62,6 @@ module Primer
|
|
62
62
|
Primer::BaseComponent.new(**sanitized_args)
|
63
63
|
}
|
64
64
|
|
65
|
-
# @example Default
|
66
|
-
# @description
|
67
|
-
# Labels are stacked by default.
|
68
|
-
# @code
|
69
|
-
# <%= render(Primer::Alpha::AutoComplete.new(label_text: "Fruits", src: "/view-components/rails-app/auto_complete?version=alpha", input_id: "fruits-input--default", list_id: "fruits-popup--default")) %>
|
70
|
-
#
|
71
|
-
# @example With inline label
|
72
|
-
# @description
|
73
|
-
# Labels can be inline by setting `is_label_inline: true`. However, labels will always become stacked on smaller screen sizes.
|
74
|
-
# @code
|
75
|
-
# <%= render(Primer::Alpha::AutoComplete.new(label_text: "Fruits", src: "/view-components/rails-app/auto_complete?version=alpha", is_label_inline: true, input_id: "fruits-input--inline-label", list_id: "fruits-popup--inline-label")) %>
|
76
|
-
#
|
77
|
-
# @example With non-visible label
|
78
|
-
# @description
|
79
|
-
# A non-visible label may be rendered with `is_label_visible: false`, but it is highly discouraged. See <%= link_to_accessibility %>.
|
80
|
-
# @code
|
81
|
-
# <%= render(Primer::Alpha::AutoComplete.new(label_text: "Fruits", src: "/view-components/rails-app/auto_complete?version=alpha", input_id: "fruits-input--non-visible-label", list_id: "fruits-popup--non-visible-label", is_label_visible: false)) %>
|
82
|
-
#
|
83
|
-
# @example With icon
|
84
|
-
# @description
|
85
|
-
# To display a search icon, set `with_icon` to `true`.
|
86
|
-
# @code
|
87
|
-
# <%= render(Primer::Alpha::AutoComplete.new(label_text: "Fruits", src: "/view-components/rails-app/auto_complete?version=alpha", list_id: "fruits-popup--icon", input_id: "fruits-input--icon", with_icon: true)) %>
|
88
|
-
#
|
89
|
-
# @example With icon and non-visible label
|
90
|
-
# <%= render(Primer::Alpha::AutoComplete.new(label_text: "Fruits", src: "/view-components/rails-app/auto_complete?version=alpha", list_id: "fruits-popup--icon-no-label", input_id: "fruits-input--icon-no-label", with_icon: true, is_label_visible: false)) %>
|
91
|
-
#
|
92
|
-
# @example With clear button
|
93
|
-
# <%= render(Primer::Alpha::AutoComplete.new(label_text: "Fruits", src: "/view-components/rails-app/auto_complete?version=alpha", input_id: "fruits-input--clear", list_id: "fruits-popup--clear", is_clearable: true)) %>
|
94
|
-
#
|
95
|
-
# @example With custom classes for the input
|
96
|
-
# <%= render(Primer::Alpha::AutoComplete.new(label_text: "Fruits", src: "/view-components/rails-app/auto_complete?version=alpha", input_id: "fruits-input--custom-input", list_id: "fruits-popup--custom-input")) do |component| %>
|
97
|
-
# <% component.with_input(classes: "custom-class") %>
|
98
|
-
# <% end %>
|
99
|
-
#
|
100
|
-
# @example With custom classes for the results
|
101
|
-
# <%= render(Primer::Alpha::AutoComplete.new(label_text: "Fruits", src: "/view-components/rails-app/auto_complete?version=alpha", input_id: "fruits-input--custom-results", list_id: "fruits-popup--custom-results")) do |component| %>
|
102
|
-
# <% component.with_results(classes: "custom-class") do %>
|
103
|
-
# <%= render(Primer::Alpha::AutoComplete::Item.new(selected: true, value: "apple")) do %>
|
104
|
-
# Apple
|
105
|
-
# <% end %>
|
106
|
-
# <%= render(Primer::Alpha::AutoComplete::Item.new(value: "orange")) do %>
|
107
|
-
# Orange
|
108
|
-
# <% end %>
|
109
|
-
# <% end %>
|
110
|
-
# <% end %>
|
111
|
-
#
|
112
65
|
# @param label_text [String] The label of the input.
|
113
66
|
# @param src [String] The route to query.
|
114
67
|
# @param input_id [String] Id of the input element.
|
@@ -1 +1 @@
|
|
1
|
-
.Banner{background-image:linear-gradient(var(--bgColor-accent-muted,var(--color-accent-subtle)),var(--bgColor-accent-muted,var(--color-accent-subtle)));border:var(--borderWidth-thin,max(1px,.0625rem)) solid var(--borderColor-accent-muted,var(--color-accent-muted));border-radius:var(--borderRadius-medium
|
1
|
+
.Banner{background-image:linear-gradient(var(--bgColor-accent-muted,var(--color-accent-subtle)),var(--bgColor-accent-muted,var(--color-accent-subtle)));border:var(--borderWidth-thin,max(1px,.0625rem)) solid var(--borderColor-accent-muted,var(--color-accent-muted));border-radius:var(--borderRadius-medium,.375rem);color:var(--fgColor-default,var(--color-fg-default));display:grid;grid-auto-flow:column;grid-template-areas:"visual message actions close";grid-template-columns:min-content 1fr minmax(0,auto) min-content;grid-template-rows:min-content;padding:var(--base-size-8,.5rem);position:relative}@media (max-width:543.98px){.Banner{grid-template-areas:"visual message close" ". actions actions";grid-template-columns:min-content 1fr min-content;grid-template-rows:min-content min-content}.Banner .Banner-actions{margin:var(--base-size-8,.5rem) 0 0 var(--base-size-8,.5rem)}}.Banner .Banner-visual{align-self:start;display:grid;grid-area:visual;padding:.375rem var(--base-size-8,.5rem)}.Banner .Banner-visual>.octicon{margin-block:calc(var(--base-size-4,.25rem)/2)}.Banner .Banner-visual>*{align-self:center}.Banner .Banner-message{align-self:center;grid-area:message;padding:.375rem var(--base-size-8,.5rem)}.Banner .Banner-message p:last-child{margin-bottom:0}.Banner .Banner-message .Banner-title:not(:only-child){font-weight:var(--base-text-weight-semibold,600);margin-bottom:0}.Banner .Banner-actions{grid-area:actions}.Banner .Banner-actions:last-child{align-self:center}.Banner .Banner-close{grid-area:close;margin-left:var(--controlStack-medium-gap-condensed,.5rem)}.Banner .Banner-visual .octicon{color:var(--fgColor-accent,var(--color-accent-fg))}.Banner.Banner--warning{background-image:linear-gradient(var(--bgColor-attention-muted,var(--color-attention-subtle)),var(--bgColor-attention-muted,var(--color-attention-subtle)));border-color:var(--borderColor-attention-muted,var(--color-attention-muted));color:var(--fgColor-default,var(--color-fg-default))}.Banner.Banner--warning .Banner-visual .octicon{color:var(--fgColor-attention,var(--color-attention-fg))}.Banner.Banner--error{background-image:linear-gradient(var(--bgColor-danger-muted,var(--color-danger-subtle)),var(--bgColor-danger-muted,var(--color-danger-subtle)));border-color:var(--borderColor-danger-muted,var(--color-danger-muted));color:var(--fgColor-default,var(--color-fg-default))}.Banner.Banner--error .Banner-visual .octicon{color:var(--fgColor-danger,var(--color-danger-fg))}.Banner.Banner--success{background-image:linear-gradient(var(--bgColor-success-muted,var(--color-success-subtle)),var(--bgColor-success-muted,var(--color-success-subtle)));border-color:var(--borderColor-success-muted,var(--color-success-muted));color:var(--fgColor-default,var(--color-fg-default))}.Banner.Banner--success .Banner-visual .octicon{color:var(--fgColor-success,var(--color-success-fg))}.Banner.Banner--full{border-left:0;border-radius:0;border-right:0;margin-top:calc(var(--borderWidth-thin,max(1px, .0625rem))*-1)}@media (max-width:767.98px){.Banner.Banner--full-whenNarrow{border-left:0;border-radius:0;border-right:0;margin-top:calc(var(--borderWidth-thin,max(1px, .0625rem))*-1)}}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["banner.pcss"],"names":[],"mappings":"AAEA,QAKE,+IAA2F,CAC3F,gHAAqE,CACrE,
|
1
|
+
{"version":3,"sources":["banner.pcss"],"names":[],"mappings":"AAEA,QAKE,+IAA2F,CAC3F,gHAAqE,CACrE,gDAAyC,CAHzC,oDAA6B,CAF7B,YAAa,CAMb,qBAAsB,CACtB,kDAAmD,CACnD,gEAAkE,CAClE,8BAA+B,CAR/B,gCAA2B,CAF3B,iBA0HF,CA7GE,4BAdF,QAeI,8DAEqB,CACrB,iDAAkD,CAClD,0CAwGJ,CAtGI,wBACE,4DACF,CACF,CAIA,uBAIE,gBAAiB,CAHjB,YAAa,CAEb,gBAAiB,CADjB,wCAWF,CAPE,gCACE,8CACF,CAEA,yBACE,iBACF,CAGF,wBAGE,iBAAkB,CADlB,iBAAkB,CADlB,wCAYF,CARE,qCACE,eACF,CAEA,uDAEE,gDAA6C,CAD7C,eAEF,CAGF,wBACE,iBAKF,CAHE,mCACE,iBACF,CAIF,sBACE,eAAgB,CAChB,0DACF,CAEA,gCACE,kDACF,CAEA,wBAEE,2JAAiG,CACjG,4EAAgD,CAFhD,oDAOF,CAHE,gDACE,wDACF,CAGF,sBAEE,+IAA2F,CAC3F,sEAA6C,CAF7C,oDAOF,CAHE,8CACE,kDACF,CAGF,wBAEE,mJAA6F,CAC7F,wEAA8C,CAF9C,oDAOF,CAHE,gDACE,oDACF,CAKF,qBAGE,aAAc,CACd,eAAgB,CAFhB,cAAe,CADf,8DAIF,CAEA,4BACE,gCAGE,aAAc,CACd,eAAgB,CAFhB,cAAe,CADf,8DAIF,CACF","file":"banner.css","sourcesContent":["/* Banner alert */\n\n.Banner {\n position: relative;\n display: grid;\n padding: var(--base-size-8);\n color: var(--fgColor-default);\n background-image: linear-gradient(var(--bgColor-accent-muted), var(--bgColor-accent-muted));\n border: var(--borderWidth-thin) solid var(--borderColor-accent-muted);\n border-radius: var(--borderRadius-medium);\n grid-auto-flow: column;\n grid-template-areas: 'visual message actions close';\n grid-template-columns: min-content 1fr minmax(0, auto) min-content;\n grid-template-rows: min-content;\n\n /* `sm` breakpoint variantion */\n @media (max-width: 543.98px) {\n grid-template-areas:\n 'visual message close'\n '. actions actions';\n grid-template-columns: min-content 1fr min-content;\n grid-template-rows: min-content min-content;\n\n & .Banner-actions {\n margin: var(--base-size-8) 0 0 var(--base-size-8);\n }\n }\n\n /* Elements */\n\n & .Banner-visual {\n display: grid;\n padding: 0.375rem var(--base-size-8);\n grid-area: visual;\n align-self: start;\n\n & > .octicon {\n margin-block: calc(var(--base-size-4) / 2);\n }\n\n & > * {\n align-self: center;\n }\n }\n\n & .Banner-message {\n padding: 0.375rem var(--base-size-8);\n grid-area: message;\n align-self: center;\n\n & p:last-child {\n margin-bottom: 0;\n }\n\n & .Banner-title:not(:only-child) {\n margin-bottom: 0;\n font-weight: var(--base-text-weight-semibold);\n }\n }\n\n & .Banner-actions {\n grid-area: actions;\n\n &:last-child {\n align-self: center;\n }\n }\n\n /* is this used anywhere? could not find any use, but unsure */\n & .Banner-close {\n grid-area: close;\n margin-left: var(--controlStack-medium-gap-condensed);\n }\n\n & .Banner-visual .octicon {\n color: var(--fgColor-accent);\n }\n\n &.Banner--warning {\n color: var(--fgColor-default);\n background-image: linear-gradient(var(--bgColor-attention-muted), var(--bgColor-attention-muted));\n border-color: var(--borderColor-attention-muted);\n\n & .Banner-visual .octicon {\n color: var(--fgColor-attention);\n }\n }\n\n &.Banner--error {\n color: var(--fgColor-default);\n background-image: linear-gradient(var(--bgColor-danger-muted), var(--bgColor-danger-muted));\n border-color: var(--borderColor-danger-muted);\n\n & .Banner-visual .octicon {\n color: var(--fgColor-danger);\n }\n }\n\n &.Banner--success {\n color: var(--fgColor-default);\n background-image: linear-gradient(var(--bgColor-success-muted), var(--bgColor-success-muted));\n border-color: var(--borderColor-success-muted);\n\n & .Banner-visual .octicon {\n color: var(--fgColor-success);\n }\n }\n\n /* Full-width */\n\n &.Banner--full {\n margin-top: calc(var(--borderWidth-thin) * -1);\n border-right: 0;\n border-left: 0;\n border-radius: 0;\n }\n\n @media (max-width: 767.98px) {\n &.Banner--full-whenNarrow {\n margin-top: calc(var(--borderWidth-thin) * -1);\n border-right: 0;\n border-left: 0;\n border-radius: 0;\n }\n }\n}\n"]}
|
@@ -48,51 +48,25 @@ module Primer
|
|
48
48
|
success: :"check-circle"
|
49
49
|
}.freeze
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
#
|
59
|
-
# @example Full width
|
60
|
-
# <%= render(Primer::Alpha::Banner.new(full: true)) { "This is a full width banner!" } %>
|
61
|
-
#
|
62
|
-
# @example Dismissible
|
63
|
-
# <%= render(Primer::Alpha::Banner.new(dismissible: true, reappear: true)) { "This is a dismissible banner!" } %>
|
64
|
-
#
|
65
|
-
# @example Custom icon
|
66
|
-
# <%= render(Primer::Alpha::Banner.new(icon: :people)) { "This is a banner with a custom icon!" } %>
|
67
|
-
#
|
68
|
-
# @example With action button
|
69
|
-
# <%= render(Primer::Alpha::Banner.new) do |component| %>
|
70
|
-
# This is a banner with an action button!
|
71
|
-
# <% component.with_action_button(size: :small) { "Take action" } %>
|
72
|
-
# <% end %>
|
73
|
-
#
|
74
|
-
# @example With custom action
|
75
|
-
# <%= render(Primer::Alpha::Banner.new) do |component| %>
|
76
|
-
# Comment saved!
|
77
|
-
# <% component.with_action_content do %>
|
78
|
-
# <%= render(Primer::IconButton.new(icon: :pencil, mr: 1, "aria-label": "Edit")) %>
|
79
|
-
# <% end %>
|
80
|
-
# <% end %>
|
81
|
-
#
|
51
|
+
DEFAULT_DISMISS_SCHEME = :none
|
52
|
+
DISMISS_SCHEMES = [
|
53
|
+
DEFAULT_DISMISS_SCHEME,
|
54
|
+
:remove,
|
55
|
+
:hide
|
56
|
+
].freeze
|
57
|
+
|
82
58
|
# @param full [Boolean] Whether the component should take up the full width of the screen.
|
83
59
|
# @param full_when_narrow [Boolean] Whether the component should take up the full width of the screen when rendered inside smaller viewports.
|
84
|
-
# @param
|
60
|
+
# @param dismiss_scheme [Symbol] Whether the component can be dismissed with an "x" button. <%= one_of(Primer::Alpha::Banner::DISMISS_SCHEMES) %>
|
85
61
|
# @param description [String] Description text rendered underneath the message.
|
86
62
|
# @param icon [Symbol] The name of an <%= link_to_octicons %> icon to use. If no icon is provided, a default one will be chosen based on the scheme.
|
87
63
|
# @param scheme [Symbol] <%= one_of(Primer::Alpha::Banner::SCHEME_MAPPINGS.keys) %>
|
88
|
-
# @param reappear [Boolean] Whether or not the flash banner should reappear after being dismissed. Only for use in test and preview environments.
|
89
64
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
90
|
-
def initialize(full: false, full_when_narrow: false,
|
65
|
+
def initialize(full: false, full_when_narrow: false, dismiss_scheme: DEFAULT_DISMISS_SCHEME, description: nil, icon: nil, scheme: DEFAULT_SCHEME, **system_arguments)
|
91
66
|
@scheme = fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, DEFAULT_SCHEME)
|
92
67
|
@icon = icon || DEFAULT_ICONS[@scheme]
|
93
|
-
@
|
68
|
+
@dismiss_scheme = dismiss_scheme
|
94
69
|
@description = description
|
95
|
-
@reappear = reappear
|
96
70
|
|
97
71
|
@system_arguments = deny_tag_argument(**system_arguments)
|
98
72
|
@system_arguments[:tag] = :div
|
@@ -113,10 +87,9 @@ module Primer
|
|
113
87
|
}
|
114
88
|
|
115
89
|
@wrapper_arguments = {
|
116
|
-
tag: custom_element_name
|
90
|
+
tag: custom_element_name,
|
91
|
+
data: { dismiss_scheme: @dismiss_scheme }
|
117
92
|
}
|
118
|
-
|
119
|
-
@wrapper_arguments[:data] = { reappear: @reappear } if @reappear
|
120
93
|
end
|
121
94
|
|
122
95
|
private
|