primer_view_components 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/app/assets/javascripts/primer_view_components.js +1 -1
  4. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  5. data/app/assets/styles/primer_view_components.css +2 -2
  6. data/app/assets/styles/primer_view_components.css.map +1 -1
  7. data/app/components/primer/alpha/action_list/heading.html.erb +1 -1
  8. data/app/components/primer/alpha/action_list/heading.rb +5 -3
  9. data/app/components/primer/alpha/action_list/item.html.erb +9 -0
  10. data/app/components/primer/alpha/action_list/item.rb +32 -11
  11. data/app/components/primer/alpha/action_list.css +1 -1
  12. data/app/components/primer/alpha/action_list.css.json +4 -41
  13. data/app/components/primer/alpha/action_list.css.map +1 -1
  14. data/app/components/primer/alpha/action_list.pcss +19 -20
  15. data/app/components/primer/alpha/action_list.rb +54 -6
  16. data/app/components/primer/alpha/action_menu/action_menu_element.d.ts +23 -0
  17. data/app/components/primer/alpha/action_menu/action_menu_element.js +165 -0
  18. data/app/components/primer/alpha/action_menu/action_menu_element.ts +168 -0
  19. data/app/components/primer/alpha/action_menu/list.rb +91 -0
  20. data/app/components/primer/alpha/action_menu.html.erb +26 -0
  21. data/app/components/primer/alpha/action_menu.rb +361 -0
  22. data/app/components/primer/alpha/auto_complete.css.json +0 -11
  23. data/app/components/primer/alpha/banner.css.json +0 -14
  24. data/app/components/primer/alpha/button_marketing.css.json +0 -10
  25. data/app/components/primer/alpha/dialog.css +1 -1
  26. data/app/components/primer/alpha/dialog.css.json +0 -65
  27. data/app/components/primer/alpha/dialog.css.map +1 -1
  28. data/app/components/primer/alpha/dialog.pcss +0 -4
  29. data/app/components/primer/alpha/dialog.rb +6 -2
  30. data/app/components/primer/alpha/dropdown/menu.rb +1 -1
  31. data/app/components/primer/alpha/dropdown.css.json +0 -21
  32. data/app/components/primer/alpha/layout.css.json +0 -27
  33. data/app/components/primer/alpha/menu.css.json +0 -11
  34. data/app/components/primer/alpha/modal_dialog.js +12 -0
  35. data/app/components/primer/alpha/modal_dialog.ts +17 -0
  36. data/app/components/primer/alpha/nav_list/item.rb +5 -0
  37. data/app/components/primer/alpha/overlay.css +1 -1
  38. data/app/components/primer/alpha/overlay.css.json +0 -3
  39. data/app/components/primer/alpha/overlay.css.map +1 -1
  40. data/app/components/primer/alpha/overlay.pcss +1 -0
  41. data/app/components/primer/alpha/overlay.rb +19 -19
  42. data/app/components/primer/alpha/segmented_control.css.json +0 -15
  43. data/app/components/primer/alpha/tab_nav.css.json +0 -10
  44. data/app/components/primer/alpha/text_field.css.json +0 -38
  45. data/app/components/primer/alpha/toggle_switch.css.json +0 -16
  46. data/app/components/primer/alpha/underline_nav.css.json +0 -13
  47. data/app/components/primer/beta/auto_complete/auto_complete.html.erb +1 -1
  48. data/app/components/primer/beta/auto_complete.rb +19 -1
  49. data/app/components/primer/beta/avatar.css.json +0 -14
  50. data/app/components/primer/beta/avatar_stack.css.json +0 -9
  51. data/app/components/primer/beta/blankslate.css.json +0 -12
  52. data/app/components/primer/beta/border_box.css.json +0 -32
  53. data/app/components/primer/beta/border_box.rb +3 -3
  54. data/app/components/primer/beta/breadcrumbs.css.json +0 -4
  55. data/app/components/primer/beta/button.css +1 -1
  56. data/app/components/primer/beta/button.css.json +0 -24
  57. data/app/components/primer/beta/button.css.map +1 -1
  58. data/app/components/primer/beta/button.pcss +5 -7
  59. data/app/components/primer/beta/counter.css.json +0 -6
  60. data/app/components/primer/beta/flash.css.json +0 -15
  61. data/app/components/primer/beta/label.css.json +0 -20
  62. data/app/components/primer/beta/link.css.json +0 -8
  63. data/app/components/primer/beta/popover.css.json +0 -18
  64. data/app/components/primer/beta/progress_bar.css.json +0 -6
  65. data/app/components/primer/beta/state.css.json +0 -10
  66. data/app/components/primer/beta/subhead.css.json +0 -8
  67. data/app/components/primer/beta/timeline_item.css.json +0 -9
  68. data/app/components/primer/beta/truncate.css.json +0 -6
  69. data/app/components/primer/focus_group.d.ts +19 -0
  70. data/app/components/primer/focus_group.js +144 -0
  71. data/app/components/primer/focus_group.ts +137 -0
  72. data/app/components/primer/icon_button.rb +1 -1
  73. data/app/components/primer/primer.d.ts +2 -0
  74. data/app/components/primer/primer.js +2 -0
  75. data/app/components/primer/primer.ts +2 -0
  76. data/app/components/primer/truncate.css.json +0 -7
  77. data/app/lib/primer/css/layout.css.json +0 -263
  78. data/app/lib/primer/css/utilities.css.json +0 -1636
  79. data/lib/primer/static/generate_arguments.rb +55 -0
  80. data/lib/primer/static/generate_audited_at.rb +17 -0
  81. data/lib/primer/static/generate_constants.rb +19 -0
  82. data/lib/primer/static/generate_info_arch.rb +156 -0
  83. data/lib/primer/static/generate_previews.rb +45 -0
  84. data/lib/primer/static/generate_statuses.rb +17 -0
  85. data/lib/primer/static.rb +72 -0
  86. data/lib/primer/view_components/linters/disallow_component_css_counter.rb +43 -4
  87. data/lib/primer/view_components/version.rb +1 -1
  88. data/lib/primer/view_components.rb +0 -48
  89. data/lib/primer/yard/component_manifest.rb +1 -0
  90. data/lib/primer/yard/component_ref.rb +14 -0
  91. data/lib/primer/yard/docs_helper.rb +3 -0
  92. data/lib/primer/yard/info_arch_docs_helper.rb +31 -0
  93. data/lib/primer/yard/legacy_gatsby_backend.rb +3 -35
  94. data/lib/primer/yard/registry.rb +2 -1
  95. data/lib/primer/yard.rb +1 -0
  96. data/lib/tasks/docs.rake +10 -12
  97. data/lib/tasks/static.rake +20 -28
  98. data/previews/primer/alpha/action_list_preview.rb +4 -1
  99. data/previews/primer/alpha/action_menu_preview/align_end.html.erb +6 -0
  100. data/previews/primer/alpha/action_menu_preview/content_labels.html.erb +9 -0
  101. data/previews/primer/alpha/action_menu_preview/opens_dialog.html.erb +21 -0
  102. data/previews/primer/alpha/action_menu_preview.rb +245 -0
  103. data/previews/primer/alpha/dialog_preview/body_has_scrollbar_overflow.html.erb +2 -2
  104. data/previews/primer/alpha/dialog_preview/custom_header.html.erb +3 -3
  105. data/previews/primer/alpha/dialog_preview/nested_dialog.html.erb +4 -4
  106. data/previews/primer/alpha/dialog_preview/test.html.erb +3 -3
  107. data/previews/primer/alpha/dialog_preview/with_footer.html.erb +3 -3
  108. data/previews/primer/alpha/dialog_preview/with_form.html.erb +1 -1
  109. data/previews/primer/alpha/dialog_preview/with_text_input.html.erb +2 -2
  110. data/previews/primer/alpha/dialog_preview.rb +7 -2
  111. data/previews/primer/beta/auto_complete_item_preview.rb +1 -0
  112. data/previews/primer/beta/auto_complete_preview.rb +36 -23
  113. data/static/arguments.json +3085 -1405
  114. data/static/audited_at.json +2 -0
  115. data/static/classes.json +576 -311
  116. data/static/constants.json +53 -2
  117. data/static/info_arch.json +8888 -0
  118. data/static/previews.json +226 -101
  119. data/static/statuses.json +2 -0
  120. metadata +28 -6
data/lib/primer/yard.rb CHANGED
@@ -6,6 +6,7 @@ module Primer
6
6
  autoload :ComponentManifest, "primer/yard/component_manifest"
7
7
  autoload :ComponentRef, "primer/yard/component_ref"
8
8
  autoload :DocsHelper, "primer/yard/docs_helper"
9
+ autoload :InfoArchDocsHelper, "primer/yard/info_arch_docs_helper"
9
10
  autoload :LegacyGatsbyBackend, "primer/yard/legacy_gatsby_backend"
10
11
  autoload :Registry, "primer/yard/registry"
11
12
  autoload :RendersManyHandler, "primer/yard/renders_many_handler"
data/lib/tasks/docs.rake CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  require "active_support/inflector"
4
4
 
5
+ task :init_pvc do
6
+ ENV["RAILS_ENV"] = "test"
7
+ ENV["VC_COMPAT_PATCH_ENABLED"] = "true"
8
+
9
+ require File.expand_path("./../../demo/config/environment.rb", __dir__)
10
+ Dir[File.expand_path("../../app/components/primer/**/*.rb", __dir__)].sort.each { |file| require file }
11
+ end
12
+
5
13
  namespace :docs do
6
14
  task :livereload do
7
15
  require "listen"
@@ -39,7 +47,7 @@ namespace :docs do
39
47
 
40
48
  manifest = Primer::Yard::ComponentManifest.where(published: true)
41
49
  backend = Primer::Yard::LegacyGatsbyBackend.new(registry, manifest)
42
- args_for_components, errors = backend.generate
50
+ errors = backend.generate
43
51
 
44
52
  unless errors.empty?
45
53
  puts "==============================================="
@@ -50,11 +58,7 @@ namespace :docs do
50
58
  puts "==============================================="
51
59
  puts "==============================================="
52
60
 
53
- raise
54
- end
55
-
56
- File.open("static/arguments.json", "w") do |f|
57
- f.puts JSON.pretty_generate(args_for_components)
61
+ raise
58
62
  end
59
63
 
60
64
  puts "Markdown compiled."
@@ -162,12 +166,6 @@ namespace :docs do
162
166
  end
163
167
  end
164
168
 
165
- task :init_pvc do
166
- ENV["RAILS_ENV"] = "test"
167
- require File.expand_path("./../../demo/config/environment.rb", __dir__)
168
- Dir[File.expand_path("../../app/components/primer/**/*.rb", __dir__)].sort.each { |file| require file }
169
- end
170
-
171
169
  task build_yard_registry: :init_pvc do
172
170
  require "primer/yard"
173
171
 
@@ -1,37 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  namespace :static do
4
- task :dump do
5
- ENV["RAILS_ENV"] = "test"
6
- require File.expand_path("./../../demo/config/environment.rb", __dir__)
7
- require "primer/view_components"
8
- require "lookbook"
9
- # Loads all components for `.descendants` to work properly
10
- Dir["./app/components/primer/**/*.rb"].sort.each { |file| require file }
4
+ task dump: [:dump_statuses, :dump_constants, :dump_audited_at, :dump_previews, :dump_arguments, :dump_info_arch]
11
5
 
12
- Primer::ViewComponents.dump(:statuses)
13
- Primer::ViewComponents.dump(:constants)
14
- Primer::ViewComponents.dump(:audited_at)
6
+ task dump_statuses: :init_pvc do
7
+ Primer::Static.dump(:statuses)
8
+ end
9
+
10
+ task dump_constants: :init_pvc do
11
+ Primer::Static.dump(:constants)
12
+ end
15
13
 
16
- previews = Lookbook.previews.map do |preview|
17
- {
18
- name: preview.name,
19
- lookup_path: preview.lookup_path,
20
- examples: preview.examples.map { |example|
21
- {
22
- inspect_path: example.url_path,
23
- preview_path: example.url_path.sub("/inspect/", "/preview/"),
24
- name: example.name
25
- }
26
- }
27
- }
28
- end
14
+ task dump_audited_at: :init_pvc do
15
+ Primer::Static.dump(:audited_at)
16
+ end
29
17
 
30
- require "json"
18
+ task dump_previews: :init_pvc do
19
+ Primer::Static.dump(:previews)
20
+ end
21
+
22
+ task dump_arguments: ["docs:build_yard_registry", :init_pvc] do
23
+ Primer::Static.dump(:arguments)
24
+ end
31
25
 
32
- File.open(File.join(Primer::ViewComponents::DEFAULT_STATIC_PATH, "previews.json"), "w") do |f|
33
- f.write(JSON.pretty_generate(previews))
34
- f.write($INPUT_RECORD_SEPARATOR)
35
- end
26
+ task dump_info_arch: ["docs:build_yard_registry", :dump_previews, :dump_arguments] do
27
+ Primer::Static.dump(:info_arch)
36
28
  end
37
29
  end
@@ -344,7 +344,10 @@ module Primer
344
344
  render(Primer::Alpha::ActionList.new(
345
345
  aria: { label: "List heading" }
346
346
  )) do |component|
347
- component.with_item(label: "Disabled item", href: "/", disabled: true)
347
+ component.with_item(label: "Disabled item", href: "/", disabled: true) do |item|
348
+ item.with_description { "Item description" }
349
+ item.with_leading_visual_icon(icon: :gear)
350
+ end
348
351
  end
349
352
  end
350
353
 
@@ -0,0 +1,6 @@
1
+ <div style="display: grid; place-content: center;">
2
+ <%= render(Primer::Alpha::ActionMenu.new(anchor_align: :end)) do |component| %>
3
+ <% component.with_show_button { "Menu" } %>
4
+ <% component.with_item(label: "Item", tag: :button, value: "") %>
5
+ <% end %>
6
+ </div>
@@ -0,0 +1,9 @@
1
+ <%= render(Primer::Alpha::ActionMenu.new) do |menu| %>
2
+ <% menu.with_show_button { "Menu" } %>
3
+ <% menu.with_item(value: "") do %>
4
+ <span class="copy-link">Copy link</span>
5
+ <% end %>
6
+ <% menu.with_item(value: "") do %>
7
+ <span class="quote-reply">Quote reply</span>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,21 @@
1
+ <%= render(Primer::Alpha::ActionMenu.new) do |component| %>
2
+ <% component.with_show_button { "Menu" } %>
3
+ <% component.with_item(label: "Item", tag: :button, value: "") %>
4
+ <% component.with_item(
5
+ label: "Show dialog",
6
+ tag: :button,
7
+ content_arguments: { "data-show-dialog-id": "my-dialog" },
8
+ value: "",
9
+ scheme: :danger
10
+ ) %>
11
+ <% end %>
12
+
13
+ <%= render(Primer::Alpha::Dialog.new(id: "my-dialog", title: "Confirm deletion")) do |d| %>
14
+ <%= render(Primer::Alpha::Dialog::Body.new()) do %>
15
+ Are you sure you want to delete this?
16
+ <% end %>
17
+ <%= render(Primer::Alpha::Dialog::Footer.new()) do %>
18
+ <%= render(Primer::Beta::Button.new(data: { "close-dialog-id": "my-dialog" })) { "Cancel" } %>
19
+ <%= render(Primer::Beta::Button.new(scheme: :danger)) { "Delete" } %>
20
+ <% end %>
21
+ <% end %>
@@ -0,0 +1,245 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Alpha
5
+ # @label ActionMenu
6
+ class ActionMenuPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param select_variant [Symbol] select [single, multiple, none]
10
+ # @param anchor_align [Symbol] select [start, center, end]
11
+ # @param anchor_side [Symbol] select [outside_bottom, outside_top, outside_left, outside_right]
12
+ def playground(
13
+ select_variant: Primer::Alpha::ActionMenu::DEFAULT_SELECT_VARIANT, anchor_align: Primer::Alpha::Overlay::DEFAULT_ANCHOR_ALIGN, anchor_side: Primer::Alpha::Overlay::DEFAULT_ANCHOR_SIDE
14
+ )
15
+ render(Primer::Alpha::ActionMenu.new(select_variant: select_variant, anchor_align: anchor_align, anchor_side: anchor_side)) do |menu|
16
+ menu.with_show_button { "Menu" }
17
+ menu.with_item(label: "Copy link")
18
+ menu.with_item(label: "Quote reply")
19
+ menu.with_item(label: "Reference in new issue")
20
+ menu.with_divider
21
+ menu.with_item(label: "Edit")
22
+ menu.with_item(label: "Delete", scheme: :danger)
23
+ end
24
+ end
25
+
26
+ # @label Content labels
27
+ #
28
+ def content_labels
29
+ end
30
+
31
+ # @label Default
32
+ #
33
+ def default
34
+ render(Primer::Alpha::ActionMenu.new(menu_id: "menu-1")) do |menu|
35
+ menu.with_show_button { |button| button.with_trailing_action_icon(icon: :"triangle-down"); "Menu" }
36
+ menu.with_item(label: "Copy link")
37
+ menu.with_item(label: "Quote reply")
38
+ menu.with_item(label: "Reference in new issue")
39
+ menu.with_divider
40
+ menu.with_item(label: "Edit") do |item|
41
+ item.with_description.with_content("Change settings")
42
+ end
43
+ menu.with_item(label: "Delete", scheme: :danger) do |item|
44
+ item.with_description.with_content("Sayonara")
45
+ end
46
+ end
47
+ end
48
+
49
+ # @label With icon button
50
+ #
51
+ def with_icon_button
52
+ render(Primer::Alpha::ActionMenu.new) do |menu|
53
+ menu.with_show_button(icon: :star, "aria-label": "Menu")
54
+ menu.with_item(label: "Does something")
55
+ end
56
+ end
57
+
58
+ # @label Single select
59
+ #
60
+ def single_select
61
+ render(Primer::Alpha::ActionMenu.new(select_variant: :single)) do |menu|
62
+ menu.with_show_button { "Menu" }
63
+ menu.with_item(label: "Fast forward")
64
+ menu.with_item(label: "Recursive")
65
+ menu.with_item(label: "Ours")
66
+ menu.with_item(label: "Resolve")
67
+ end
68
+ end
69
+
70
+ # @label Multiple select
71
+ #
72
+ def multiple_select
73
+ render(Primer::Alpha::ActionMenu.new(select_variant: :multiple)) do |menu|
74
+ menu.with_show_button { "Menu" }
75
+ menu.with_item(label: "langermank", description_scheme: :inline) do |item|
76
+ item.with_leading_visual_avatar(src: "https://avatars.githubusercontent.com/u/18661030?v=4", alt: "Katie Langerman")
77
+ item.with_description.with_content("Katie Langerman")
78
+ end
79
+ menu.with_item(label: "jonrohan", description_scheme: :inline) do |item|
80
+ item.with_leading_visual_avatar(src: "https://avatars.githubusercontent.com/u/54012?s=96&v=4", alt: "Jon Rohan")
81
+ item.with_description.with_content("Jon Rohan")
82
+ end
83
+ menu.with_item(label: "broccolinisoup", description_scheme: :inline) do |item|
84
+ item.with_leading_visual_avatar(src: "https://avatars.githubusercontent.com/u/1446503?v=4", alt: "Armağan Ersöz")
85
+ item.with_description.with_content("Armağan Ersöz")
86
+ end
87
+ end
88
+ end
89
+
90
+ # @label Links
91
+ #
92
+ def links
93
+ render(Primer::Alpha::ActionMenu.new) do |menu|
94
+ menu.with_show_button { "Menu" }
95
+ menu.with_item(label: "Settings", href: "/")
96
+ menu.with_item(label: "Your repositories", href: "/")
97
+ menu.with_item(label: "Disabled", href: "/", disabled: true)
98
+ end
99
+ end
100
+
101
+ # @label Single item selected
102
+ #
103
+ def single_selected_item
104
+ render(Primer::Alpha::ActionMenu.new(select_variant: :single)) do |menu|
105
+ menu.with_show_button { "Menu" }
106
+ menu.with_item(label: "Copy link")
107
+ menu.with_item(label: "Quote reply", active: true)
108
+ menu.with_item(label: "Reference in new issue")
109
+ end
110
+ end
111
+
112
+ # @label Single Select with Internal Label
113
+ #
114
+ def single_select_with_internal_label
115
+ render(Primer::Alpha::ActionMenu.new(select_variant: :single, dynamic_label: true, dynamic_label_prefix: "Menu")) do |menu|
116
+ menu.with_show_button { |button| button.with_trailing_action_icon(icon: :"triangle-down"); "Menu" }
117
+ menu.with_item(label: "Copy link") do |item|
118
+ item.with_trailing_visual_label(scheme: :accent, inline: true).with_content("Recommended")
119
+ end
120
+ menu.with_item(label: "Quote reply", active: true)
121
+ menu.with_item(label: "Reference in new issue")
122
+ end
123
+ end
124
+
125
+ # @label Multiple items selected
126
+ #
127
+ def multiple_selected_items
128
+ render(Primer::Alpha::ActionMenu.new(select_variant: :multiple)) do |menu|
129
+ menu.with_show_button { "Menu" }
130
+ menu.with_item(label: "langermank", description_scheme: :inline, active: true) do |item|
131
+ item.with_leading_visual_avatar(src: "https://avatars.githubusercontent.com/u/18661030?v=4", alt: "Katie Langerman")
132
+ item.with_description.with_content("Katie Langerman")
133
+ end
134
+ menu.with_item(label: "jonrohan", description_scheme: :inline) do |item|
135
+ item.with_leading_visual_avatar(src: "https://avatars.githubusercontent.com/u/54012?s=96&v=4", alt: "Jon Rohan")
136
+ item.with_description.with_content("Jon Rohan")
137
+ end
138
+ menu.with_item(label: "broccolinisoup", description_scheme: :inline, active: true) do |item|
139
+ item.with_leading_visual_avatar(src: "https://avatars.githubusercontent.com/u/1446503?v=4", alt: "Armağan Ersöz")
140
+ item.with_description.with_content("Armağan Ersöz")
141
+ end
142
+ end
143
+ end
144
+
145
+ # @label With deferred content
146
+ #
147
+ def with_deferred_content
148
+ render(Primer::Alpha::ActionMenu.new(menu_id: "deferred", src: UrlHelpers.action_menu_deferred_path)) do |menu|
149
+ menu.with_show_button { "Menu with deferred content" }
150
+ end
151
+ end
152
+
153
+ # @label With deferred preloaded content
154
+ #
155
+ def with_deferred_preloaded_content
156
+ render(Primer::Alpha::ActionMenu.new(menu_id: "deferred-preload", preload: true, src: UrlHelpers.action_menu_deferred_preload_path)) do |menu|
157
+ menu.with_show_button { "Menu with deferred and preloaded content" }
158
+ end
159
+ end
160
+
161
+ # @label With actions
162
+ #
163
+ def with_actions
164
+ render(Primer::Alpha::ActionMenu.new) do |component|
165
+ component.with_show_button { "Trigger" }
166
+ component.with_item(label: "Alert", tag: :button, content_arguments: { onclick: "alert('Foo')", onkeydown: "if (event.key === 'Enter') { alert(event.key) }" })
167
+ component.with_item(label: "Navigate", tag: :a, content_arguments: { href: UrlHelpers.action_menu_landing_path })
168
+ component.with_item(label: "Copy text", tag: :"clipboard-copy", content_arguments: { value: "Text to copy" })
169
+ end
170
+ end
171
+
172
+ # @label With disabled items
173
+ #
174
+ def with_disabled_items
175
+ render(Primer::Alpha::ActionMenu.new) do |component|
176
+ component.with_show_button { "Trigger" }
177
+ component.with_item(label: "Does something", tag: :button, disabled: true)
178
+ component.with_item(label: "Site", tag: :a, href: "/", disabled: true)
179
+ end
180
+ end
181
+
182
+ # @label Opens a dialog
183
+ #
184
+ def opens_dialog(menu_id: "menu-1")
185
+ render_with_template(locals: {
186
+ menu_id: menu_id
187
+ })
188
+ end
189
+
190
+ # @label Align end
191
+ #
192
+ def align_end(menu_id: "menu-1")
193
+ render_with_template(locals: {
194
+ menu_id: menu_id
195
+ })
196
+ end
197
+
198
+ # @label [Item] Block description
199
+ #
200
+ def block_description
201
+ render(Primer::Alpha::ActionMenu.new(menu_id: "menu-1")) do |menu|
202
+ menu.with_show_button { |button| button.with_trailing_action_icon(icon: :"triangle-down"); "Menu" }
203
+ menu.with_item(label: "Item label") do |item|
204
+ item.with_description.with_content("Block description")
205
+ end
206
+ end
207
+ end
208
+
209
+ # @label [Item] Inline description
210
+ #
211
+ def inline_description
212
+ render(Primer::Alpha::ActionMenu.new(menu_id: "menu-1")) do |menu|
213
+ menu.with_show_button { |button| button.with_trailing_action_icon(icon: :"triangle-down"); "Menu" }
214
+ menu.with_item(label: "Item label", description_scheme: :inline) do |item|
215
+ item.with_description.with_content("Inline description")
216
+ end
217
+ end
218
+ end
219
+
220
+ # @label [Item] Leading visual
221
+ #
222
+ def leading_visual
223
+ render(Primer::Alpha::ActionMenu.new(menu_id: "menu-1")) do |menu|
224
+ menu.with_show_button { |button| button.with_trailing_action_icon(icon: :"triangle-down"); "Menu" }
225
+ menu.with_item(label: "Item label", description_scheme: :inline) do |item|
226
+ item.with_leading_visual_icon(icon: :gear)
227
+ item.with_description.with_content("Inline description")
228
+ end
229
+ end
230
+ end
231
+
232
+ # @label [Item] Leading visual single select
233
+ #
234
+ def leading_visual_single_select
235
+ render(Primer::Alpha::ActionMenu.new(menu_id: "menu-1", select_variant: :single)) do |menu|
236
+ menu.with_show_button { |button| button.with_trailing_action_icon(icon: :"triangle-down"); "Menu" }
237
+ menu.with_item(label: "Item label", description_scheme: :inline) do |item|
238
+ item.with_leading_visual_icon(icon: :gear)
239
+ item.with_description.with_content("Inline description")
240
+ end
241
+ end
242
+ end
243
+ end
244
+ end
245
+ end
@@ -1,8 +1,8 @@
1
1
  <div>
2
2
  <p>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?</p>
3
3
  <%= render(Primer::Alpha::Dialog.new(id: "dialog-one", title: title, subtitle: subtitle, visually_hide_title: false)) do |d| %>
4
- <% d.show_button { button_text } %>
5
- <% d.body do %>
4
+ <% d.with_show_button { button_text } %>
5
+ <% d.with_body do %>
6
6
  <p>Dialog</p>
7
7
  <% end %>
8
8
  <% end %>
@@ -1,7 +1,7 @@
1
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 %>
2
+ <% d.with_header(show_divider: show_divider) do %>
3
3
  <button class="btn">Custom Header Controls</button>
4
4
  <% end %>
5
- <% d.show_button { button_text } %>
6
- <% d.body { "Hello World" } %>
5
+ <% d.with_show_button { button_text } %>
6
+ <% d.with_body { "Hello World" } %>
7
7
  <% end %>
@@ -1,12 +1,12 @@
1
1
  <%= render(Primer::Alpha::Dialog.new(id: "dialog-one", title: title, subtitle: subtitle, visually_hide_title: false)) do |d| %>
2
- <% d.show_button { button_text } %>
3
- <% d.body do %>
2
+ <% d.with_show_button { button_text } %>
3
+ <% d.with_body do %>
4
4
  <p>Dialog One!</p>
5
5
 
6
6
  <p>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?</p>
7
7
  <%= render(Primer::Alpha::Dialog.new(id: "dialog-two", title: title, subtitle: subtitle, visually_hide_title: false)) do |d| %>
8
- <% d.show_button { button_text } %>
9
- <% d.body do %>
8
+ <% d.with_show_button { button_text } %>
9
+ <% d.with_body do %>
10
10
  Dialog Two!
11
11
  <% end %>
12
12
  <% end %>
@@ -1,7 +1,7 @@
1
1
  <%= render(Primer::Alpha::Dialog.new(title: title, subtitle: subtitle)) do |d| %>
2
- <% d.show_button { @button_text } %>
3
- <% d.body { "Content" } %>
4
- <% d.footer do %>
2
+ <% d.with_show_button { @button_text } %>
3
+ <% d.with_body { "Content" } %>
4
+ <% d.with_footer do %>
5
5
  render(Primer::ButtonComponent.new(scheme: :primary)) { "Submit" }
6
6
  <% end %>
7
7
  <% end %>
@@ -1,7 +1,7 @@
1
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 %>
2
+ <% d.with_show_button { button_text } %>
3
+ <% d.with_body { "Content" } %>
4
+ <% d.with_footer(show_divider: show_divider) do %>
5
5
  <%= render(Primer::ButtonComponent.new(data: { "close-dialog-id": "my-dialog" })) { "Cancel" } %>
6
6
  <%= render(Primer::ButtonComponent.new(scheme: :primary)) { "Submit" } %>
7
7
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <%= render(Primer::Alpha::Dialog.new(id: "my-dialog", title: title, subtitle: subtitle)) do |d| %>
2
- <% d.show_button { button_text } %>
2
+ <% d.with_show_button { button_text } %>
3
3
  <form class="pt-3">
4
4
  <%= render(Primer::Alpha::Dialog::Body.new) do %>
5
5
  This is a custom dialog with the body and footer wrapped in a form tag.
@@ -1,6 +1,6 @@
1
1
  <%= render(Primer::Alpha::Dialog.new(id: "dialog-one", title: title, subtitle: subtitle, visually_hide_title: false)) do |d| %>
2
- <% d.show_button { button_text } %>
3
- <% d.body do %>
2
+ <% d.with_show_button { button_text } %>
3
+ <% d.with_body do %>
4
4
  <p>Dialog One!</p>
5
5
 
6
6
  <form>
@@ -14,9 +14,14 @@ module Primer
14
14
  # @param visually_hide_title [Boolean] toggle
15
15
  # @param button_text [String] text
16
16
  # @param body_text [String] text
17
- def playground(title: "Test Dialog", subtitle: nil, size: :medium, button_text: "Show Dialog", body_text: "Content", position: :center, position_narrow: :fullscreen, visually_hide_title: false)
17
+ # @param icon [Symbol] octicon
18
+ def playground(title: "Test Dialog", subtitle: nil, size: :medium, button_text: "Show Dialog", body_text: "Content", position: :center, position_narrow: :fullscreen, visually_hide_title: false, icon: nil)
18
19
  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
+ if icon.present? && (icon != :none)
21
+ d.with_show_button(icon: icon, "aria-label": icon.to_s)
22
+ else
23
+ d.with_show_button { button_text }
24
+ end
20
25
  d.with_body { body_text }
21
26
  end
22
27
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Primer
4
4
  module Beta
5
+ # @component Primer::Beta::AutoComplete::Item
5
6
  # @label AutoCompleteItem
6
7
  class AutoCompleteItemPreview < ViewComponent::Preview
7
8
  # @label Playground