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
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Migrations
|
6
|
+
# Lint & autocorrect Truncate components
|
7
|
+
class TruncateComponent < RuboCop::Cop::Cop
|
8
|
+
INVALID_MESSAGE = <<~STR
|
9
|
+
`Primer::Truncate` is deprecated. Please use `Primer::Beta::Truncate` instead!
|
10
|
+
STR
|
11
|
+
|
12
|
+
def_node_matcher :truncate_component, <<~PATTERN
|
13
|
+
(send (const (const nil? :Primer) :Truncate) :new ...)
|
14
|
+
PATTERN
|
15
|
+
|
16
|
+
def_node_matcher :hash_with_inline_value?, <<~PATTERN
|
17
|
+
(hash ... (pair (sym :inline) (...)) ... )
|
18
|
+
PATTERN
|
19
|
+
|
20
|
+
def_node_matcher :truncate_with_tag?, <<~PATTERN
|
21
|
+
(hash ... (pair (sym :tag) (...)) ... )
|
22
|
+
PATTERN
|
23
|
+
|
24
|
+
def on_send(node)
|
25
|
+
return unless truncate_component(node)
|
26
|
+
|
27
|
+
add_offense(node, message: INVALID_MESSAGE)
|
28
|
+
end
|
29
|
+
|
30
|
+
def autocorrect(node)
|
31
|
+
return if hash_with_inline_value?(node.arguments.first)
|
32
|
+
|
33
|
+
lambda do |corrector|
|
34
|
+
if node.arguments.first.nil? == false
|
35
|
+
corrector.replace(node.children.first, "Primer::Beta::Truncate")
|
36
|
+
corrector.insert_after(node.arguments.first, ", tag: :div") unless truncate_with_tag?(node.arguments.first)
|
37
|
+
else
|
38
|
+
corrector.replace(node.loc.expression, "Primer::Beta::Truncate.new(tag: :div)")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -10,7 +10,7 @@ module ERBLint
|
|
10
10
|
include LinterRegistry
|
11
11
|
include Helpers::RuleHelpers
|
12
12
|
|
13
|
-
MIGRATE_TO_NEWER_TOOLTIP = ".tooltipped has been deprecated. There are major accessibility concerns with using this tooltip so please take action. See https://
|
13
|
+
MIGRATE_TO_NEWER_TOOLTIP = ".tooltipped has been deprecated. There are major accessibility concerns with using this tooltip so please take action. See https://primer.style/design/guides/development/rails/migration-guides/primer-css-tooltipped."
|
14
14
|
TOOLTIPPED_RUBY_PATTERN = /classes:.*tooltipped|class:.*tooltipped/.freeze
|
15
15
|
|
16
16
|
def run(processed_source)
|
@@ -176,6 +176,7 @@ module Primer
|
|
176
176
|
each_component do |component_ref|
|
177
177
|
page_for(component_ref).generate
|
178
178
|
end
|
179
|
+
generate_system_args_docs
|
179
180
|
end
|
180
181
|
|
181
182
|
def page_for(component_ref)
|
@@ -194,6 +195,36 @@ module Primer
|
|
194
195
|
def each_component(&block)
|
195
196
|
manifest.each(&block)
|
196
197
|
end
|
198
|
+
|
199
|
+
def generate_system_args_docs
|
200
|
+
docs = registry.find(Primer::BaseComponent)
|
201
|
+
|
202
|
+
path = File.expand_path(
|
203
|
+
File.join(
|
204
|
+
*%w[.. .. .. previews pages system-arguments.md.erb]
|
205
|
+
), __dir__
|
206
|
+
)
|
207
|
+
|
208
|
+
data = {
|
209
|
+
"description_md" => docs.base_docstring.to_s,
|
210
|
+
"args_md" => view_context.render(inline: docs.constructor.base_docstring)
|
211
|
+
}
|
212
|
+
|
213
|
+
frontmatter = {
|
214
|
+
"title" => "System arguments",
|
215
|
+
"id" => "system_arguments",
|
216
|
+
"data" => data
|
217
|
+
}
|
218
|
+
|
219
|
+
File.write(
|
220
|
+
path, <<~ERB
|
221
|
+
#{YAML.dump(frontmatter)}
|
222
|
+
---
|
223
|
+
<%= @page.data[:description_md] %>
|
224
|
+
<%= @page.data[:args_md] %>
|
225
|
+
ERB
|
226
|
+
)
|
227
|
+
end
|
197
228
|
end
|
198
229
|
end
|
199
230
|
end
|
data/lib/primer/yard.rb
CHANGED
@@ -5,15 +5,14 @@ require "yard"
|
|
5
5
|
module Primer
|
6
6
|
# :nodoc:
|
7
7
|
module Yard
|
8
|
-
autoload :Backend,
|
9
|
-
autoload :ComponentManifest,
|
10
|
-
autoload :ComponentRef,
|
11
|
-
autoload :DocsHelper,
|
12
|
-
autoload :InfoArchDocsHelper,
|
13
|
-
autoload :
|
14
|
-
autoload :
|
15
|
-
autoload :
|
16
|
-
autoload :RendersOneHandler, "primer/yard/renders_one_handler"
|
8
|
+
autoload :Backend, "primer/yard/backend"
|
9
|
+
autoload :ComponentManifest, "primer/yard/component_manifest"
|
10
|
+
autoload :ComponentRef, "primer/yard/component_ref"
|
11
|
+
autoload :DocsHelper, "primer/yard/docs_helper"
|
12
|
+
autoload :InfoArchDocsHelper, "primer/yard/info_arch_docs_helper"
|
13
|
+
autoload :Registry, "primer/yard/registry"
|
14
|
+
autoload :RendersManyHandler, "primer/yard/renders_many_handler"
|
15
|
+
autoload :RendersOneHandler, "primer/yard/renders_one_handler"
|
17
16
|
|
18
17
|
::YARD::Tags::Library.define_tag("Snapshot preview", :snapshot)
|
19
18
|
end
|
@@ -100,11 +100,13 @@ module Primer
|
|
100
100
|
scheme: Primer::Alpha::ActionList::DEFAULT_SCHEME,
|
101
101
|
show_dividers: false
|
102
102
|
)
|
103
|
-
render(
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
103
|
+
render(
|
104
|
+
Primer::Alpha::ActionList.new(
|
105
|
+
role: role,
|
106
|
+
scheme: scheme,
|
107
|
+
show_dividers: show_dividers
|
108
|
+
)
|
109
|
+
) do |component|
|
108
110
|
component.with_heading(title: "Action List")
|
109
111
|
component.with_item(label: "Item one", href: "/") do |item|
|
110
112
|
item.with_leading_visual_icon(icon: :gear)
|
@@ -145,9 +147,11 @@ module Primer
|
|
145
147
|
list_id: "unique-id",
|
146
148
|
subtitle: "This is a subtitle"
|
147
149
|
)
|
148
|
-
render(
|
149
|
-
|
150
|
-
|
150
|
+
render(
|
151
|
+
Primer::Alpha::ActionList::Heading.new(
|
152
|
+
scheme: scheme, list_id: list_id, title: title, subtitle: subtitle
|
153
|
+
)
|
154
|
+
)
|
151
155
|
end
|
152
156
|
|
153
157
|
# @label Item [playground]
|
@@ -162,7 +166,6 @@ module Primer
|
|
162
166
|
# @param description_scheme [Symbol] select [inline, block]
|
163
167
|
# @param active toggle
|
164
168
|
# @param leading_visual_icon [Symbol] octicon
|
165
|
-
# @param leading_visual_avatar_src text
|
166
169
|
# @param trailing_visual_icon [Symbol] octicon
|
167
170
|
# @param trailing_visual_label text
|
168
171
|
# @param trailing_visual_counter number
|
@@ -183,7 +186,6 @@ module Primer
|
|
183
186
|
active: false,
|
184
187
|
expanded: false,
|
185
188
|
leading_visual_icon: nil,
|
186
|
-
leading_visual_avatar_src: nil,
|
187
189
|
trailing_visual_icon: nil,
|
188
190
|
trailing_visual_label: nil,
|
189
191
|
trailing_visual_counter: nil,
|
@@ -206,11 +208,7 @@ module Primer
|
|
206
208
|
expanded: expanded,
|
207
209
|
id: "tooltip-test"
|
208
210
|
) do |item|
|
209
|
-
if leading_visual_icon && leading_visual_icon != :none
|
210
|
-
item.with_leading_visual_icon(icon: leading_visual_icon)
|
211
|
-
elsif leading_visual_avatar_src
|
212
|
-
item.with_leading_visual_avatar(src: leading_visual_avatar_src, alt: "An avatar")
|
213
|
-
end
|
211
|
+
item.with_leading_visual_icon(icon: leading_visual_icon) if leading_visual_icon && leading_visual_icon != :none
|
214
212
|
|
215
213
|
if trailing_visual_icon && trailing_visual_icon != :none
|
216
214
|
item.with_trailing_visual_icon(icon: trailing_visual_icon)
|
@@ -224,13 +222,87 @@ module Primer
|
|
224
222
|
|
225
223
|
if private_leading_action_icon && private_leading_action_icon != :none
|
226
224
|
item.with_private_leading_action_icon(icon: private_leading_action_icon)
|
227
|
-
elsif private_trailing_action_icon
|
225
|
+
elsif private_trailing_action_icon && private_trailing_action_icon != :none
|
228
226
|
item.with_private_trailing_action_icon(icon: private_trailing_action_icon)
|
229
227
|
end
|
230
228
|
|
231
229
|
item.with_trailing_action(icon: "plus", "aria-label": "Button tooltip", size: :medium) if trailing_action && trailing_action != :none
|
232
230
|
|
233
|
-
item.
|
231
|
+
item.with_description { description } if description
|
232
|
+
|
233
|
+
item.with_tooltip(text: "Tooltip text", for_id: "tooltip-test", type: :description) if tooltip
|
234
|
+
end
|
235
|
+
|
236
|
+
render(list)
|
237
|
+
end
|
238
|
+
|
239
|
+
# @label Avatar item [playground]
|
240
|
+
#
|
241
|
+
# @param username text
|
242
|
+
# @param truncate_label toggle
|
243
|
+
# @param src text
|
244
|
+
# @param shape [Symbol] select [circle, square]
|
245
|
+
# @param size [Symbol] select [medium, large, xlarge]
|
246
|
+
# @param scheme [Symbol] select [default, danger]
|
247
|
+
# @param disabled toggle
|
248
|
+
# @param full_name text
|
249
|
+
# @param full_name_scheme [Symbol] select [inline, block]
|
250
|
+
# @param active toggle
|
251
|
+
# @param trailing_visual_icon [Symbol] octicon
|
252
|
+
# @param trailing_visual_label text
|
253
|
+
# @param trailing_visual_counter number
|
254
|
+
# @param trailing_visual_text text
|
255
|
+
# @param private_trailing_action_icon [Symbol] octicon
|
256
|
+
# @param trailing_action toggle
|
257
|
+
# @param tooltip toggle
|
258
|
+
def avatar_item(
|
259
|
+
username: "hulk_smash",
|
260
|
+
truncate_label: false,
|
261
|
+
src: "https://avatars.githubusercontent.com/u/103004183?v=4",
|
262
|
+
shape: Primer::Beta::Avatar::DEFAULT_SHAPE,
|
263
|
+
size: Primer::Alpha::ActionList::Item::DEFAULT_SIZE,
|
264
|
+
scheme: Primer::Alpha::ActionList::Item::DEFAULT_SCHEME,
|
265
|
+
disabled: false,
|
266
|
+
full_name: "Bruce Banner",
|
267
|
+
full_name_scheme: Primer::Alpha::ActionList::Item::DEFAULT_DESCRIPTION_SCHEME,
|
268
|
+
active: false,
|
269
|
+
expanded: false,
|
270
|
+
trailing_visual_icon: nil,
|
271
|
+
trailing_visual_label: nil,
|
272
|
+
trailing_visual_counter: nil,
|
273
|
+
trailing_visual_text: nil,
|
274
|
+
private_trailing_action_icon: nil,
|
275
|
+
trailing_action: false,
|
276
|
+
tooltip: false
|
277
|
+
)
|
278
|
+
list = Primer::Alpha::ActionList.new(aria: { label: "Action List" })
|
279
|
+
list.with_avatar_item(
|
280
|
+
username: username,
|
281
|
+
truncate_label: truncate_label,
|
282
|
+
src: src,
|
283
|
+
size: size,
|
284
|
+
scheme: scheme,
|
285
|
+
disabled: disabled,
|
286
|
+
full_name: full_name,
|
287
|
+
full_name_scheme: full_name_scheme,
|
288
|
+
active: active,
|
289
|
+
expanded: expanded,
|
290
|
+
id: "tooltip-test",
|
291
|
+
avatar_arguments: { shape: shape }
|
292
|
+
) do |item|
|
293
|
+
if trailing_visual_icon && trailing_visual_icon != :none
|
294
|
+
item.with_trailing_visual_icon(icon: trailing_visual_icon)
|
295
|
+
elsif trailing_visual_label
|
296
|
+
item.with_trailing_visual_label { trailing_visual_label }
|
297
|
+
elsif trailing_visual_counter
|
298
|
+
item.with_trailing_visual_counter(count: trailing_visual_counter)
|
299
|
+
elsif trailing_visual_text
|
300
|
+
item.with_trailing_visual_text(trailing_visual_text)
|
301
|
+
end
|
302
|
+
|
303
|
+
item.with_private_trailing_action_icon(icon: private_trailing_action_icon) if private_trailing_action_icon && private_trailing_action_icon != :none
|
304
|
+
|
305
|
+
item.with_trailing_action(icon: "plus", "aria-label": "Button tooltip", size: :medium) if trailing_action && trailing_action != :none
|
234
306
|
|
235
307
|
item.with_tooltip(text: "Tooltip text", for_id: "tooltip-test", type: :description) if tooltip
|
236
308
|
end
|
@@ -27,15 +27,18 @@ module Primer
|
|
27
27
|
|
28
28
|
# @label Content labels
|
29
29
|
#
|
30
|
-
def content_labels
|
31
|
-
end
|
30
|
+
def content_labels; end
|
32
31
|
|
33
32
|
# @label Default
|
34
33
|
#
|
35
34
|
# @snapshot interactive
|
36
35
|
def default
|
37
36
|
render(Primer::Alpha::ActionMenu.new(menu_id: "menu-1")) do |menu|
|
38
|
-
menu.with_show_button
|
37
|
+
menu.with_show_button do |button|
|
38
|
+
button.with_trailing_action_icon(icon: :"triangle-down")
|
39
|
+
"Menu"
|
40
|
+
end
|
41
|
+
|
39
42
|
menu.with_item(label: "Copy link")
|
40
43
|
menu.with_item(label: "Quote reply")
|
41
44
|
menu.with_item(label: "Reference in new issue")
|
@@ -54,7 +57,10 @@ module Primer
|
|
54
57
|
# @snapshot interactive
|
55
58
|
def wide
|
56
59
|
render(Primer::Alpha::ActionMenu.new(select_variant: :single, size: :medium)) do |menu|
|
57
|
-
menu.with_show_button
|
60
|
+
menu.with_show_button do |button|
|
61
|
+
button.with_trailing_action_icon(icon: :"triangle-down")
|
62
|
+
"A wider menu"
|
63
|
+
end
|
58
64
|
|
59
65
|
menu.with_item(label: "Default", active: true, value: "default") do |item|
|
60
66
|
item.with_trailing_visual_label(scheme: :accent, inline: true).with_content("Recommended")
|
@@ -93,18 +99,30 @@ module Primer
|
|
93
99
|
def multiple_select
|
94
100
|
render(Primer::Alpha::ActionMenu.new(select_variant: :multiple)) do |menu|
|
95
101
|
menu.with_show_button { "Menu" }
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
102
|
+
|
103
|
+
menu.with_avatar_item(
|
104
|
+
src: "https://avatars.githubusercontent.com/u/18661030?v=4",
|
105
|
+
username: "langermank",
|
106
|
+
full_name: "Katie Langerman",
|
107
|
+
full_name_scheme: :inline,
|
108
|
+
avatar_arguments: { shape: :square }
|
109
|
+
)
|
110
|
+
|
111
|
+
menu.with_avatar_item(
|
112
|
+
src: "https://avatars.githubusercontent.com/u/54012?s=96&v=4",
|
113
|
+
username: "jonrohan",
|
114
|
+
full_name: "Jon Rohan",
|
115
|
+
full_name_scheme: :inline,
|
116
|
+
avatar_arguments: { shape: :square }
|
117
|
+
)
|
118
|
+
|
119
|
+
menu.with_avatar_item(
|
120
|
+
src: "https://avatars.githubusercontent.com/u/1446503?v=4",
|
121
|
+
username: "broccolinisoup",
|
122
|
+
full_name: "Armağan Ersöz",
|
123
|
+
full_name_scheme: :inline,
|
124
|
+
avatar_arguments: { shape: :square }
|
125
|
+
)
|
108
126
|
end
|
109
127
|
end
|
110
128
|
|
@@ -136,7 +154,10 @@ module Primer
|
|
136
154
|
# @snapshot interactive
|
137
155
|
def single_select_with_internal_label
|
138
156
|
render(Primer::Alpha::ActionMenu.new(select_variant: :single, dynamic_label: true, dynamic_label_prefix: "Menu")) do |menu|
|
139
|
-
menu.with_show_button
|
157
|
+
menu.with_show_button do |button|
|
158
|
+
button.with_trailing_action_icon(icon: :"triangle-down")
|
159
|
+
"Menu"
|
160
|
+
end
|
140
161
|
menu.with_item(label: "Copy link") do |item|
|
141
162
|
item.with_trailing_visual_label(scheme: :accent, inline: true).with_content("Recommended")
|
142
163
|
end
|
@@ -151,18 +172,29 @@ module Primer
|
|
151
172
|
def multiple_selected_items
|
152
173
|
render(Primer::Alpha::ActionMenu.new(select_variant: :multiple)) do |menu|
|
153
174
|
menu.with_show_button { "Menu" }
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
175
|
+
|
176
|
+
menu.with_avatar_item(
|
177
|
+
src: "https://avatars.githubusercontent.com/u/18661030?v=4",
|
178
|
+
username: "langermank",
|
179
|
+
full_name: "Katie Langerman",
|
180
|
+
full_name_scheme: :inline,
|
181
|
+
active: true
|
182
|
+
)
|
183
|
+
|
184
|
+
menu.with_avatar_item(
|
185
|
+
src: "https://avatars.githubusercontent.com/u/54012?s=96&v=4",
|
186
|
+
username: "jonrohan",
|
187
|
+
full_name: "Jon Rohan",
|
188
|
+
full_name_scheme: :inline
|
189
|
+
)
|
190
|
+
|
191
|
+
menu.with_avatar_item(
|
192
|
+
src: "https://avatars.githubusercontent.com/u/1446503?v=4",
|
193
|
+
username: "broccolinisoup",
|
194
|
+
full_name: "Armağan Ersöz",
|
195
|
+
full_name_scheme: :inline,
|
196
|
+
active: true
|
197
|
+
)
|
166
198
|
end
|
167
199
|
end
|
168
200
|
|
@@ -184,8 +216,7 @@ module Primer
|
|
184
216
|
|
185
217
|
# @label With actions
|
186
218
|
#
|
187
|
-
def with_actions
|
188
|
-
end
|
219
|
+
def with_actions; end
|
189
220
|
|
190
221
|
# @label Single select form
|
191
222
|
#
|
@@ -229,7 +260,10 @@ module Primer
|
|
229
260
|
#
|
230
261
|
def block_description
|
231
262
|
render(Primer::Alpha::ActionMenu.new(menu_id: "menu-1")) do |menu|
|
232
|
-
menu.with_show_button
|
263
|
+
menu.with_show_button do |button|
|
264
|
+
button.with_trailing_action_icon(icon: :"triangle-down")
|
265
|
+
"Menu"
|
266
|
+
end
|
233
267
|
menu.with_item(label: "Item label") do |item|
|
234
268
|
item.with_description.with_content("Block description")
|
235
269
|
end
|
@@ -246,7 +280,10 @@ module Primer
|
|
246
280
|
#
|
247
281
|
def inline_description
|
248
282
|
render(Primer::Alpha::ActionMenu.new(menu_id: "menu-1")) do |menu|
|
249
|
-
menu.with_show_button
|
283
|
+
menu.with_show_button do |button|
|
284
|
+
button.with_trailing_action_icon(icon: :"triangle-down")
|
285
|
+
"Menu"
|
286
|
+
end
|
250
287
|
menu.with_item(label: "Item label", description_scheme: :inline) do |item|
|
251
288
|
item.with_description.with_content("Inline description")
|
252
289
|
end
|
@@ -257,7 +294,10 @@ module Primer
|
|
257
294
|
#
|
258
295
|
def leading_visual
|
259
296
|
render(Primer::Alpha::ActionMenu.new(menu_id: "menu-1")) do |menu|
|
260
|
-
menu.with_show_button
|
297
|
+
menu.with_show_button do |button|
|
298
|
+
button.with_trailing_action_icon(icon: :"triangle-down")
|
299
|
+
"Menu"
|
300
|
+
end
|
261
301
|
menu.with_item(label: "Item label", description_scheme: :inline) do |item|
|
262
302
|
item.with_leading_visual_icon(icon: :gear)
|
263
303
|
item.with_description.with_content("Inline description")
|
@@ -269,7 +309,10 @@ module Primer
|
|
269
309
|
#
|
270
310
|
def leading_visual_single_select
|
271
311
|
render(Primer::Alpha::ActionMenu.new(menu_id: "menu-1", select_variant: :single)) do |menu|
|
272
|
-
menu.with_show_button
|
312
|
+
menu.with_show_button do |button|
|
313
|
+
button.with_trailing_action_icon(icon: :"triangle-down")
|
314
|
+
"Menu"
|
315
|
+
end
|
273
316
|
menu.with_item(label: "Item label", description_scheme: :inline) do |item|
|
274
317
|
item.with_leading_visual_icon(icon: :gear)
|
275
318
|
item.with_description.with_content("Inline description")
|
@@ -279,8 +322,7 @@ module Primer
|
|
279
322
|
|
280
323
|
# @label Two menus
|
281
324
|
#
|
282
|
-
def two_menus
|
283
|
-
end
|
325
|
+
def two_menus; end
|
284
326
|
end
|
285
327
|
end
|
286
328
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= render(Primer::Alpha::Banner.new(full: full,
|
1
|
+
<%= render(Primer::Alpha::Banner.new(full: full, dismiss_scheme: dismiss_scheme, icon: icon, scheme: scheme)) do |component| %>
|
2
2
|
<% component.with_action_button(size: :medium) { "Take action" } %>
|
3
3
|
<%= content %>
|
4
4
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= render(Primer::Alpha::Banner.new(full: full,
|
1
|
+
<%= render(Primer::Alpha::Banner.new(full: full, dismiss_scheme: dismiss_scheme, icon: icon, scheme: scheme)) do |component| %>
|
2
2
|
<% component.with_action_content do %>
|
3
3
|
<%= render(Primer::Beta::IconButton.new(icon: :pencil, mr: 1, "aria-label": "Edit")) %>
|
4
4
|
<% end %>
|
@@ -8,15 +8,14 @@ module Primer
|
|
8
8
|
#
|
9
9
|
# @param full toggle
|
10
10
|
# @param full_when_narrow toggle
|
11
|
-
# @param
|
11
|
+
# @param dismiss_scheme [Symbol] select [none, remove, hide]
|
12
12
|
# @param icon [Symbol] octicon
|
13
13
|
# @param scheme [Symbol] select [default, warning, danger, success]
|
14
14
|
# @param content text
|
15
15
|
# @param description text
|
16
|
-
|
17
|
-
def playground(full: false, full_when_narrow: false, dismissible: false, icon: :people, scheme: Primer::Alpha::Banner::DEFAULT_SCHEME, reappear: true, content: "This is a banner!", description: nil)
|
16
|
+
def playground(full: false, full_when_narrow: false, dismiss_scheme: Primer::Alpha::Banner::DEFAULT_DISMISS_SCHEME, icon: :people, scheme: Primer::Alpha::Banner::DEFAULT_SCHEME, content: "This is a banner!", description: nil)
|
18
17
|
icon = nil if icon == :none
|
19
|
-
render(Primer::Alpha::Banner.new(full: full, full_when_narrow: full_when_narrow,
|
18
|
+
render(Primer::Alpha::Banner.new(full: full, full_when_narrow: full_when_narrow, dismiss_scheme: dismiss_scheme, icon: icon == :none ? nil : icon, scheme: scheme, description: description)) { content }
|
20
19
|
end
|
21
20
|
|
22
21
|
# @label Default
|
@@ -54,8 +53,8 @@ module Primer
|
|
54
53
|
|
55
54
|
# @label Dismissable
|
56
55
|
# @snapshot
|
57
|
-
def
|
58
|
-
render(Primer::Alpha::Banner.new(
|
56
|
+
def dismissible
|
57
|
+
render(Primer::Alpha::Banner.new(dismiss_scheme: :hide, reappear: true)) { "This is a dismissable banner." }
|
59
58
|
end
|
60
59
|
|
61
60
|
# @!group Full Width
|
@@ -76,29 +75,27 @@ module Primer
|
|
76
75
|
# @label With action button
|
77
76
|
#
|
78
77
|
# @param full toggle
|
79
|
-
# @param
|
78
|
+
# @param dismiss_scheme [Symbol] select [none, remove, hide]
|
80
79
|
# @param icon [Symbol] octicon
|
81
80
|
# @param scheme [Symbol] select [default, warning, danger, success]
|
82
81
|
# @param content text
|
83
|
-
# @param reappear [Boolean]
|
84
82
|
# @snapshot
|
85
|
-
def with_action_button(full: false,
|
83
|
+
def with_action_button(full: false, dismiss_scheme: Primer::Alpha::Banner::DEFAULT_DISMISS_SCHEME, icon: :people, scheme: Primer::Alpha::Banner::DEFAULT_SCHEME, content: "This is a banner with an action!")
|
86
84
|
icon = nil if icon == :none
|
87
|
-
render_with_template(locals: { full: full,
|
85
|
+
render_with_template(locals: { full: full, dismiss_scheme: dismiss_scheme, icon: icon == :none ? nil : icon, scheme: scheme, content: content })
|
88
86
|
end
|
89
87
|
|
90
88
|
# @label With action content
|
91
89
|
#
|
92
90
|
# @param full toggle
|
93
|
-
# @param
|
91
|
+
# @param dismiss_scheme [Symbol] select [none, remove, hide]
|
94
92
|
# @param icon [Symbol] octicon
|
95
93
|
# @param scheme [Symbol] select [default, warning, danger, success]
|
96
94
|
# @param content text
|
97
|
-
# @param reappear [Boolean]
|
98
95
|
# @snapshot
|
99
|
-
def with_action_content(full: false,
|
96
|
+
def with_action_content(full: false, dismiss_scheme: Primer::Alpha::Banner::DEFAULT_DISMISS_SCHEME, icon: :people, scheme: Primer::Alpha::Banner::DEFAULT_SCHEME, content: "Did you know? Comments can be edited.")
|
100
97
|
icon = nil if icon == :none
|
101
|
-
render_with_template(locals: { full: full,
|
98
|
+
render_with_template(locals: { full: full, dismiss_scheme: dismiss_scheme, icon: icon == :none ? nil : icon, scheme: scheme, content: content })
|
102
99
|
end
|
103
100
|
end
|
104
101
|
end
|
@@ -50,6 +50,15 @@ module Primer
|
|
50
50
|
list.with_group do |group|
|
51
51
|
group.with_heading(title: "Access")
|
52
52
|
|
53
|
+
group.with_avatar_item(
|
54
|
+
src: "https://avatars.githubusercontent.com/u/103004183?v=4",
|
55
|
+
username: "hulk_smash",
|
56
|
+
full_name: "Bruce Banner",
|
57
|
+
full_name_scheme: :inline,
|
58
|
+
href: "/profile",
|
59
|
+
avatar_arguments: { shape: :square }
|
60
|
+
)
|
61
|
+
|
53
62
|
group.with_item(label: "Collaborators and teams", href: "/collaborators", selected_by_ids: :collaborators) do |item|
|
54
63
|
item.with_leading_visual_icon(icon: :people)
|
55
64
|
end
|
@@ -82,6 +91,14 @@ module Primer
|
|
82
91
|
list.with_item(label: "Change password", href: "/change_password") do |item|
|
83
92
|
item.with_leading_visual_icon(icon: :key)
|
84
93
|
end
|
94
|
+
|
95
|
+
list.with_avatar_item(
|
96
|
+
src: "https://avatars.githubusercontent.com/u/103004183?v=4",
|
97
|
+
username: "hulk_smash",
|
98
|
+
full_name: "Bruce Banner",
|
99
|
+
full_name_scheme: :inline,
|
100
|
+
href: "/profile"
|
101
|
+
)
|
85
102
|
end
|
86
103
|
end
|
87
104
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
<div>
|
2
2
|
<%= render(Primer::Beta::Button.new(id: "button-1")) do |component| %>
|
3
|
-
<% component.with_tooltip(text: tooltip_text,
|
3
|
+
<% component.with_tooltip(text: tooltip_text, direction: direction) %>
|
4
4
|
Button 1
|
5
5
|
<% end %>
|
6
6
|
<%= render(Primer::Beta::Button.new(id: "button-2")) do |component| %>
|
7
|
-
<% component.with_tooltip(text: tooltip_text,
|
7
|
+
<% component.with_tooltip(text: tooltip_text, direction: direction) %>
|
8
8
|
Button 2
|
9
9
|
<% end %>
|
10
10
|
<%= render(Primer::Beta::Button.new(id: "button-3")) do |component| %>
|
11
|
-
<% component.with_tooltip(text: tooltip_text,
|
11
|
+
<% component.with_tooltip(text: tooltip_text, direction: direction) %>
|
12
12
|
Button 3
|
13
13
|
<% end %>
|
14
14
|
</div>
|