openproject-primer_view_components 0.11.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +110 -0
  3. data/app/assets/javascripts/app/components/primer/alpha/tool_tip.d.ts +1 -0
  4. data/app/assets/javascripts/app/components/primer/primer.d.ts +1 -1
  5. data/app/assets/javascripts/primer_view_components.js +1 -1
  6. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  7. data/app/assets/styles/primer_view_components.css +1 -1
  8. data/app/assets/styles/primer_view_components.css.map +1 -1
  9. data/app/components/primer/alpha/action_bar/item.rb +7 -4
  10. data/app/components/primer/alpha/action_bar.rb +2 -2
  11. data/app/components/primer/alpha/action_bar_element.js +9 -4
  12. data/app/components/primer/alpha/action_bar_element.ts +9 -2
  13. data/app/components/primer/alpha/action_list/form_wrapper.html.erb +4 -2
  14. data/app/components/primer/alpha/action_list/form_wrapper.rb +20 -9
  15. data/app/components/primer/alpha/action_menu/action_menu_element.js +162 -86
  16. data/app/components/primer/alpha/action_menu/action_menu_element.ts +197 -82
  17. data/app/components/primer/alpha/action_menu/list.rb +0 -2
  18. data/app/components/primer/alpha/action_menu.rb +120 -3
  19. data/app/components/primer/alpha/check_box_group.rb +2 -0
  20. data/app/components/primer/alpha/dialog/header.rb +12 -0
  21. data/app/components/primer/alpha/dialog.rb +1 -1
  22. data/app/components/primer/alpha/modal_dialog.js +10 -13
  23. data/app/components/primer/alpha/modal_dialog.ts +10 -13
  24. data/app/components/primer/alpha/nav_list/divider.rb +2 -5
  25. data/app/components/primer/alpha/nav_list/group.rb +2 -98
  26. data/app/components/primer/alpha/nav_list/heading.rb +2 -27
  27. data/app/components/primer/alpha/nav_list/item.rb +2 -147
  28. data/app/components/primer/alpha/nav_list.rb +2 -205
  29. data/app/components/primer/alpha/overlay.css +1 -1
  30. data/app/components/primer/alpha/overlay.css.map +1 -1
  31. data/app/components/primer/alpha/overlay.pcss +1 -7
  32. data/app/components/primer/alpha/overlay.rb +6 -4
  33. data/app/components/primer/alpha/radio_button_group.rb +2 -0
  34. data/app/components/primer/alpha/segmented_control/item.html.erb +1 -8
  35. data/app/components/primer/alpha/segmented_control/item.rb +38 -4
  36. data/app/components/primer/alpha/segmented_control.css +1 -1
  37. data/app/components/primer/alpha/segmented_control.css.json +14 -13
  38. data/app/components/primer/alpha/segmented_control.css.map +1 -1
  39. data/app/components/primer/alpha/segmented_control.pcss +75 -66
  40. data/app/components/primer/alpha/segmented_control.rb +10 -0
  41. data/app/components/primer/alpha/text_field.css +1 -1
  42. data/app/components/primer/alpha/text_field.css.json +4 -1
  43. data/app/components/primer/alpha/text_field.css.map +1 -1
  44. data/app/components/primer/alpha/text_field.pcss +18 -3
  45. data/app/components/primer/alpha/tool_tip.d.ts +1 -0
  46. data/app/components/primer/alpha/tool_tip.js +26 -93
  47. data/app/components/primer/alpha/tool_tip.ts +25 -91
  48. data/app/components/primer/alpha/tooltip.rb +3 -1
  49. data/app/components/primer/beta/base_button.rb +4 -0
  50. data/app/components/primer/beta/button.css +1 -1
  51. data/app/components/primer/beta/button.css.json +2 -0
  52. data/app/components/primer/beta/button.css.map +1 -1
  53. data/app/components/primer/beta/button.pcss +17 -5
  54. data/app/components/primer/beta/icon_button.html.erb +1 -1
  55. data/app/components/primer/beta/icon_button.rb +8 -1
  56. data/app/components/primer/beta/link.css +1 -1
  57. data/app/components/primer/beta/link.css.json +1 -0
  58. data/app/components/primer/beta/link.css.map +1 -1
  59. data/app/components/primer/beta/link.pcss +5 -0
  60. data/app/components/primer/beta/link.rb +2 -2
  61. data/app/components/primer/beta/nav_list/divider.rb +14 -0
  62. data/app/components/primer/beta/nav_list/group.rb +107 -0
  63. data/app/components/primer/beta/nav_list/heading.rb +36 -0
  64. data/app/components/primer/beta/nav_list/item.rb +156 -0
  65. data/app/components/primer/beta/nav_list.rb +212 -0
  66. data/app/components/primer/focus_group.js +30 -4
  67. data/app/components/primer/focus_group.ts +29 -2
  68. data/app/components/primer/open_project/flex_layout.html.erb +23 -0
  69. data/app/components/primer/open_project/flex_layout.rb +52 -0
  70. data/app/components/primer/open_project/grid_layout/area.rb +38 -0
  71. data/app/components/primer/open_project/grid_layout.html.erb +11 -0
  72. data/app/components/primer/open_project/grid_layout.rb +34 -0
  73. data/app/components/primer/open_project/page_header.css +1 -1
  74. data/app/components/primer/open_project/page_header.css.map +1 -1
  75. data/app/components/primer/open_project/page_header.pcss +4 -0
  76. data/app/components/primer/primer.d.ts +1 -1
  77. data/app/components/primer/primer.js +1 -1
  78. data/app/components/primer/primer.ts +1 -1
  79. data/app/helpers/primer/form_helper.rb +10 -0
  80. data/lib/primer/accessibility.rb +3 -1
  81. data/lib/primer/deprecations.yml +20 -0
  82. data/lib/primer/forms/check_box_group.html.erb +3 -0
  83. data/lib/primer/forms/dsl/check_box_group_input.rb +1 -5
  84. data/lib/primer/forms/dsl/check_box_input.rb +5 -0
  85. data/lib/primer/forms/dsl/radio_button_input.rb +5 -0
  86. data/lib/primer/forms/form_control.html.erb +1 -4
  87. data/lib/primer/forms/radio_button_group.html.erb +3 -0
  88. data/lib/primer/forms/utils.rb +2 -0
  89. data/lib/primer/forms/validation_message.html.erb +4 -0
  90. data/lib/primer/forms/validation_message.rb +14 -0
  91. data/lib/primer/forms.rb +16 -0
  92. data/lib/primer/static/generate_info_arch.rb +86 -5
  93. data/lib/primer/view_components/version.rb +1 -1
  94. data/lib/primer/yard/component_manifest.rb +4 -0
  95. data/previews/primer/alpha/action_menu_preview/single_select_form_items.html.erb +31 -0
  96. data/previews/primer/alpha/action_menu_preview/with_actions.html.erb +6 -5
  97. data/previews/primer/alpha/action_menu_preview.rb +10 -1
  98. data/previews/primer/alpha/check_box_group_preview.rb +13 -0
  99. data/previews/primer/alpha/check_box_preview.rb +1 -0
  100. data/previews/primer/alpha/dialog_preview/autofocus_element.html.erb +8 -0
  101. data/previews/primer/alpha/dialog_preview/with_header.html.erb +5 -0
  102. data/previews/primer/alpha/dialog_preview.rb +22 -0
  103. data/previews/primer/alpha/overlay_preview.rb +1 -1
  104. data/previews/primer/alpha/radio_button_group_preview.rb +13 -0
  105. data/previews/primer/alpha/radio_button_preview.rb +2 -1
  106. data/previews/primer/alpha/segmented_control_preview.rb +35 -0
  107. data/previews/primer/alpha/text_field_preview/input_group_leading_action_menu.html.erb +21 -0
  108. data/previews/primer/alpha/text_field_preview/input_group_leading_button.html.erb +18 -0
  109. data/previews/primer/alpha/text_field_preview/input_group_trailing_button.html.erb +18 -0
  110. data/previews/primer/alpha/text_field_preview.rb +21 -0
  111. data/previews/primer/alpha/tooltip_preview/tooltip_with_dialog_moving_focus_to_input.html.erb +23 -0
  112. data/previews/primer/alpha/tooltip_preview.rb +6 -1
  113. data/previews/primer/beta/button_group_preview.rb +6 -6
  114. data/previews/primer/beta/button_preview.rb +21 -3
  115. data/previews/primer/beta/icon_button_preview.rb +3 -0
  116. data/previews/primer/{alpha → beta}/nav_list_preview/trailing_action.html.erb +1 -1
  117. data/previews/primer/{alpha → beta}/nav_list_preview.rb +5 -5
  118. data/previews/primer/open_project/flex_layout_preview.rb +73 -0
  119. data/previews/primer/open_project/grid_layout_preview.rb +37 -0
  120. data/static/arguments.json +278 -7
  121. data/static/audited_at.json +8 -0
  122. data/static/classes.json +15 -0
  123. data/static/constants.json +47 -1
  124. data/static/info_arch.json +1338 -632
  125. data/static/previews.json +271 -167
  126. data/static/statuses.json +13 -5
  127. metadata +33 -319
  128. /data/app/assets/javascripts/app/components/primer/{alpha → beta}/nav_list.d.ts +0 -0
  129. /data/app/components/primer/{alpha → beta}/nav_list/group.html.erb +0 -0
  130. /data/app/components/primer/{alpha → beta}/nav_list/item.html.erb +0 -0
  131. /data/app/components/primer/{alpha → beta}/nav_list.d.ts +0 -0
  132. /data/app/components/primer/{alpha → beta}/nav_list.html.erb +0 -0
  133. /data/app/components/primer/{alpha → beta}/nav_list.js +0 -0
  134. /data/app/components/primer/{alpha → beta}/nav_list.ts +0 -0
@@ -8,14 +8,15 @@
8
8
 
9
9
  <%= render(Primer::Alpha::ActionMenu.new) do |component| %>
10
10
  <% component.with_show_button { "Trigger" } %>
11
- <% component.with_item(label: "Alert", tag: :button, id: "alert-item") %>
12
- <% component.with_item(label: "Navigate", tag: :a, content_arguments: { href: action_menu_landing_path }) %>
13
- <% component.with_item(label: "Copy text", tag: :"clipboard-copy", content_arguments: { value: "Text to copy" }) %>
11
+ <% component.with_item(label: "Alert", tag: :button, id: "alert-item", disabled: disable_items) %>
12
+ <% component.with_item(label: "Navigate", tag: :a, content_arguments: { href: action_menu_landing_path }, disabled: disable_items) %>
13
+ <% component.with_item(label: "Copy text", tag: :"clipboard-copy", content_arguments: { value: "Text to copy" }, disabled: disable_items) %>
14
14
  <% component.with_item(
15
15
  label: "Submit form",
16
- href: action_menu_form_action_path,
16
+ href: action_menu_form_action_path(format: route_format),
17
17
  form_arguments: {
18
18
  name: "foo", value: "bar", method: :post
19
- }
19
+ },
20
+ disabled: disable_items
20
21
  ) %>
21
22
  <% end %>
@@ -216,7 +216,10 @@ module Primer
216
216
 
217
217
  # @label With actions
218
218
  #
219
- def with_actions; end
219
+ # @param disable_items toggle
220
+ def with_actions(disable_items: false, route_format: :html)
221
+ render_with_template(locals: { disable_items: disable_items, route_format: route_format })
222
+ end
220
223
 
221
224
  # @label Single select form
222
225
  #
@@ -224,6 +227,12 @@ module Primer
224
227
  render_with_template(locals: { route_format: route_format })
225
228
  end
226
229
 
230
+ # @label Single select form items
231
+ #
232
+ def single_select_form_items(route_format: :html)
233
+ render_with_template(locals: { route_format: route_format })
234
+ end
235
+
227
236
  # @label Multiple select form
228
237
  #
229
238
  def multiple_select_form(route_format: :html)
@@ -9,17 +9,20 @@ module Primer
9
9
  # @param name text
10
10
  # @param label text
11
11
  # @param caption text
12
+ # @param validation_message text
12
13
  # @param disabled toggle
13
14
  def playground(
14
15
  name: "my-check-group",
15
16
  label: "I would go into battle with:",
16
17
  caption: "Qa'pla!",
18
+ validation_message: nil,
17
19
  disabled: false
18
20
  )
19
21
  system_arguments = {
20
22
  name: name,
21
23
  label: label,
22
24
  caption: caption,
25
+ validation_message: validation_message,
23
26
  disabled: disabled
24
27
  }
25
28
 
@@ -41,6 +44,16 @@ module Primer
41
44
  end
42
45
  end
43
46
 
47
+ # @label Invalid
48
+ def invalid
49
+ render(Primer::Alpha::CheckBoxGroup.new(validation_message: "Please choose at least one", name: "my-check-group", label: "I would go into battle with:")) do |component|
50
+ component.check_box(label: "Jean-Luc Picard", value: "picard4")
51
+ component.check_box(label: "Hikaru Sulu", value: "sulu4")
52
+ component.check_box(label: "Kathryn Janeway", value: "janeway4")
53
+ component.check_box(label: "Benjamin Sisko", value: "sisko4")
54
+ end
55
+ end
56
+
44
57
  # @!group Options
45
58
  # @snapshot
46
59
  #
@@ -24,6 +24,7 @@ module Primer
24
24
  )
25
25
  system_arguments = {
26
26
  name: name,
27
+ id: id,
27
28
  value: value,
28
29
  label: label,
29
30
  caption: caption,
@@ -0,0 +1,8 @@
1
+ <%= render(Primer::Alpha::Dialog.new(id: "dialog-one", title: "Dialog")) do |d| %>
2
+ <% d.with_show_button { "Show Dialog" } %>
3
+ <% d.with_body do %>
4
+ <form>
5
+ <input type="text" placeholder="This element is focused on open" autofocus>
6
+ </form>
7
+ <% end %>
8
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <%= render(Primer::Alpha::Dialog.new(id: "my-dialog", title: title, subtitle: subtitle)) do |d| %>
2
+ <% d.with_show_button { button_text } %>
3
+ <% d.with_body { "Content" } %>
4
+ <% d.with_header(show_divider: show_divider, variant: header_variant) %>
5
+ <% end %>
@@ -60,6 +60,23 @@ module Primer
60
60
  end
61
61
  end
62
62
 
63
+ # @label With Header
64
+ #
65
+ # @param title [String] text
66
+ # @param subtitle [String] text
67
+ # @param header_variant [Symbol] select [medium, large]
68
+ # @param button_text [String] text
69
+ # @param show_divider [Boolean] toggle
70
+ def with_header(title: "Test Dialog", subtitle: nil, header_variant: :medium, button_text: "Show Dialog", show_divider: true)
71
+ render_with_template(locals: {
72
+ title: title,
73
+ subtitle: subtitle,
74
+ header_variant: header_variant,
75
+ button_text: button_text,
76
+ show_divider: show_divider
77
+ })
78
+ end
79
+
63
80
  # @label With Footer
64
81
  #
65
82
  # @param title [String] text
@@ -149,6 +166,11 @@ module Primer
149
166
  show_divider: show_divider
150
167
  })
151
168
  end
169
+
170
+ # @label Autofocus element with autofocus attribute
171
+ def autofocus_element
172
+ render_with_template(locals: {})
173
+ end
152
174
  end
153
175
  end
154
176
  end
@@ -165,7 +165,7 @@ module Primer
165
165
  end
166
166
 
167
167
  # @label In an ActionMenu
168
- def in_an_action_menu()
168
+ def in_an_action_menu
169
169
  render_with_template(locals: {})
170
170
  end
171
171
 
@@ -9,17 +9,20 @@ module Primer
9
9
  # @param name text
10
10
  # @param label text
11
11
  # @param caption text
12
+ # @param validation_message text
12
13
  # @param disabled toggle
13
14
  def playground(
14
15
  name: "my-radio-group",
15
16
  label: "Question: what kind of bear is best?",
16
17
  caption: "There are basically two schools of thought",
18
+ validation_message: nil,
17
19
  disabled: false
18
20
  )
19
21
  system_arguments = {
20
22
  name: name,
21
23
  label: label,
22
24
  caption: caption,
25
+ validation_message: validation_message,
23
26
  disabled: disabled
24
27
  }
25
28
 
@@ -40,6 +43,16 @@ module Primer
40
43
  end
41
44
  end
42
45
 
46
+ # @label Invalid
47
+ # @snapshot
48
+ def invalid
49
+ render(Primer::Alpha::RadioButtonGroup.new(validation_message: "Please select an option", name: "my-radio-group", label: "Question: what kind of bear is best?")) do |component|
50
+ component.radio_button(label: "Bears", value: "bears")
51
+ component.radio_button(label: "Beets", value: "beets")
52
+ component.radio_button(label: "Battlestar Galactica", value: "bsg")
53
+ end
54
+ end
55
+
43
56
  # @!group Options
44
57
  #
45
58
  # @label With caption
@@ -24,6 +24,7 @@ module Primer
24
24
  )
25
25
  system_arguments = {
26
26
  name: name,
27
+ id: id,
27
28
  value: value,
28
29
  label: label,
29
30
  caption: caption,
@@ -51,7 +52,7 @@ module Primer
51
52
  # @label Checked
52
53
  # @snapshot
53
54
  def checked
54
- render(Primer::Alpha::RadioButton.new(name: "my-radio-button", label: "Battlestar Galactica", value: "bsg2", checked: true ))
55
+ render(Primer::Alpha::RadioButton.new(name: "my-radio-button", label: "Battlestar Galactica", value: "bsg2", checked: true))
55
56
  end
56
57
 
57
58
  # @label Visually hidden label
@@ -100,6 +100,41 @@ module Primer
100
100
  end
101
101
  # @!endgroup
102
102
 
103
+ # @!group Trailing Label
104
+ # @label Size small
105
+ # @snapshot
106
+ def trailing_label_width_small
107
+ render(Primer::Alpha::SegmentedControl.new("aria-label": "Billing duration", size: :small)) do |component|
108
+ component.with_item(label: "Monthly")
109
+ component.with_item(label: "Yearly", selected: true) do |button|
110
+ button.with_trailing_visual_label(scheme: :accent) { "-8%" }
111
+ end
112
+ end
113
+ end
114
+
115
+ # @label Size medium
116
+ # @snapshot
117
+ def trailing_label_width_medium
118
+ render(Primer::Alpha::SegmentedControl.new("aria-label": "Billing duration", size: :medium)) do |component|
119
+ component.with_item(label: "Monthly")
120
+ component.with_item(label: "Yearly", selected: true) do |button|
121
+ button.with_trailing_visual_label(scheme: :accent) { "-8%" }
122
+ end
123
+ end
124
+ end
125
+
126
+ # @label Size large
127
+ # @snapshot
128
+ def trailing_label_width_large
129
+ render(Primer::Alpha::SegmentedControl.new("aria-label": "Billing duration", size: :large)) do |component|
130
+ component.with_item(label: "Monthly")
131
+ component.with_item(label: "Yearly", selected: true) do |button|
132
+ button.with_trailing_visual_label(scheme: :accent) { "-8%" }
133
+ end
134
+ end
135
+ end
136
+ # @!endgroup
137
+
103
138
  # @!group Icons only
104
139
  # @label Size small
105
140
  # @snapshot
@@ -0,0 +1,21 @@
1
+
2
+ <%= render(Primer::BaseComponent.new(tag: :div, flex_items: :center, display: :flex)) do %>
3
+ <%= form_with(url: action_menu_form_action_path(format: route_format)) do |f| %>
4
+ <%= render(Primer::Alpha::ActionMenu.new(select_variant: :single, form_arguments: { builder: f, name: "foo" })) do |menu| %>
5
+ <% menu.with_show_button(classes: "rounded-right-0 border-right-0") { |button| button.with_trailing_action_icon(icon: :"triangle-down"); "Filter" } %>
6
+ <% menu.with_item(label: "Fast forward", data: { value: "fast_forward" }) %>
7
+ <% menu.with_item(label: "Recursive", data: { value: "recursive" }) %>
8
+ <% menu.with_item(label: "Ours", data: { value: "ours" }) %>
9
+ <% menu.with_item(label: "Resolve") %>
10
+ <% end %>
11
+ <% end %>
12
+ <%= render(Primer::Alpha::TextField.new(
13
+ name: "message",
14
+ placeholder: "What's happening?",
15
+ label: "What is your current status?",
16
+ classes: "rounded-left-0",
17
+ visually_hide_label: true,
18
+ value: "Some value",
19
+ inset: true,
20
+ )) %>
21
+ <% end %>
@@ -0,0 +1,18 @@
1
+
2
+ <%= render(Primer::BaseComponent.new(tag: :div, flex_items: :center, display: :flex)) do %>
3
+ <%= render(Primer::Beta::IconButton.new(
4
+ classes: "rounded-right-0 border-right-0",
5
+ icon: :smiley,
6
+ aria: { label: "Emoji" }
7
+ )
8
+ ) %>
9
+ <%= render(Primer::Alpha::TextField.new(
10
+ name: "message",
11
+ placeholder: "What's happening?",
12
+ label: "What is your current status?",
13
+ classes: "rounded-left-0",
14
+ visually_hide_label: true,
15
+ value: "Some value",
16
+ inset: true,
17
+ )) %>
18
+ <% end %>
@@ -0,0 +1,18 @@
1
+
2
+ <%= render(Primer::BaseComponent.new(tag: :div, flex_items: :center, display: :flex)) do %>
3
+ <%= render(Primer::Alpha::TextField.new(
4
+ name: "message",
5
+ placeholder: "What's happening?",
6
+ label: "What is your current status?",
7
+ classes: "rounded-right-0",
8
+ visually_hide_label: true,
9
+ value: "Some value",
10
+ inset: true,
11
+ )) %>
12
+ <%= render(Primer::Beta::IconButton.new(
13
+ classes: "rounded-left-0 border-left-0",
14
+ icon: :smiley,
15
+ aria: { label: "Emoji" }
16
+ )
17
+ ) %>
18
+ <% end %>
@@ -189,6 +189,27 @@ module Primer
189
189
  end
190
190
  #
191
191
  # @!endgroup
192
+
193
+ # @label Input group with leading button
194
+ #
195
+ # @snapshot
196
+ def input_group_leading_button
197
+ render_with_template
198
+ end
199
+
200
+ # @label Input group with trailing button
201
+ #
202
+ # @snapshot
203
+ def input_group_trailing_button
204
+ render_with_template
205
+ end
206
+
207
+ # @label Input group with ActionMenu
208
+ #
209
+ # @snapshot
210
+ def input_group_leading_action_menu(route_format: :html)
211
+ render_with_template(locals: { route_format: route_format })
212
+ end
192
213
  end
193
214
  end
194
215
  end
@@ -0,0 +1,23 @@
1
+ <%= render(Primer::Alpha::Dialog.new(id: "my-dialog", title: "Confirm focus")) do |d| %>
2
+ <%= render(Primer::Alpha::Dialog::Body.new()) do %>
3
+ Are you sure you want to focus the input?
4
+ <% end %>
5
+ <%= render(Primer::Alpha::Dialog::Footer.new()) do %>
6
+ <%= render(Primer::Beta::Button.new(id: "yes-button", data: { "close-dialog-id": "my-dialog" })) { "Yes" } %>
7
+ <%= render(Primer::Beta::Button.new(scheme: :primary, data: { "close-dialog-id": "my-dialog" })) { "Yes but in green" } %>
8
+ <% end %>
9
+ <% d.with_show_button do |b| %>
10
+ Focus input
11
+ <% b.with_tooltip(text: "This is a tooltip in an Overlay") %>
12
+ <% end %>
13
+ <% end %>
14
+ <label>
15
+ An input
16
+ <input type="text" id="input">
17
+ </label>
18
+ <script>
19
+ document.querySelector('#my-dialog').addEventListener('cancel', function () {
20
+ console.log('!!')
21
+ setTimeout(() => document.querySelector('#input').focus(), 0);
22
+ });
23
+ </script>
@@ -78,11 +78,16 @@ module Primer
78
78
  # @!endgroup
79
79
 
80
80
  # @label Tooltip inside Primer::Alpha::Overlay
81
- def tooltip_inside_primer_overlay(direction: :s, tooltip_text: "You can press a button")
81
+ def tooltip_inside_primer_overlay
82
82
  render_with_template(
83
83
  locals: {}
84
84
  )
85
85
  end
86
+
87
+ # @label Tooltip with button moving focus to input
88
+ def tooltip_with_dialog_moving_focus_to_input
89
+ render_with_template(locals: {})
90
+ end
86
91
  end
87
92
  end
88
93
  end
@@ -55,16 +55,16 @@ module Primer
55
55
  # @snapshot
56
56
  def all_tags
57
57
  render(Primer::Beta::ButtonGroup.new) do |component|
58
- component.with_button(id: "button-1", tag: :button) do |component|
59
- component.with_tooltip(text: "Button Tooltip")
58
+ component.with_button(id: "button-1", tag: :button) do |button|
59
+ button.with_tooltip(text: "Button Tooltip")
60
60
  "Button 1"
61
61
  end
62
- component.with_button(id: "button-2", tag: :a) do |component|
63
- component.with_tooltip(text: "Button Tooltip")
62
+ component.with_button(id: "button-2", tag: :a) do |button|
63
+ button.with_tooltip(text: "Button Tooltip")
64
64
  "Button 2"
65
65
  end
66
- component.with_button(id: "button-3", tag: :summary) do |component|
67
- component.with_tooltip(text: "Button Tooltip")
66
+ component.with_button(id: "button-3", tag: :summary) do |button|
67
+ button.with_tooltip(text: "Button Tooltip")
68
68
  "Button 3"
69
69
  end
70
70
  end
@@ -18,6 +18,7 @@ module Primer
18
18
  # @param size select [small, medium, large]
19
19
  # @param block toggle
20
20
  # @param disabled toggle
21
+ # @param inactive toggle
21
22
  # @param align_content select [center, start]
22
23
  # @param tag select [a, summary, button]
23
24
  def playground(
@@ -27,7 +28,8 @@ module Primer
27
28
  id: "button-preview",
28
29
  align_content: :center,
29
30
  tag: :button,
30
- disabled: false
31
+ disabled: false,
32
+ inactive: false
31
33
  )
32
34
  render(Primer::Beta::Button.new(
33
35
  scheme: scheme,
@@ -36,7 +38,8 @@ module Primer
36
38
  id: id,
37
39
  align_content: align_content,
38
40
  tag: tag,
39
- disabled: disabled
41
+ disabled: disabled,
42
+ inactive: inactive
40
43
  )) do |_c|
41
44
  "Button"
42
45
  end
@@ -166,7 +169,7 @@ module Primer
166
169
  disabled: false
167
170
  )
168
171
  render_with_template(locals: {
169
- disabled: disabled,
172
+ disabled: disabled
170
173
  })
171
174
  end
172
175
 
@@ -341,6 +344,21 @@ module Primer
341
344
  align_content: align_content
342
345
  })
343
346
  end
347
+
348
+ # @label Inactive
349
+ # @param inactive toggle
350
+ # @snapshot
351
+ def inactive(
352
+ id: "button-preview",
353
+ inactive: true
354
+ )
355
+ render(Primer::Beta::Button.new(
356
+ id: id,
357
+ inactive: inactive
358
+ )) do |_c|
359
+ "Button"
360
+ end
361
+ end
344
362
  end
345
363
  end
346
364
  end
@@ -9,6 +9,7 @@ module Primer
9
9
  # @param size select [small, medium, large]
10
10
  # @param aria_label text
11
11
  # @param disabled toggle
12
+ # @param inactive toggle
12
13
  # @param tag select [a, summary, button]
13
14
  # @param icon [Symbol] octicon
14
15
  # @param show_tooltip toggle
@@ -18,6 +19,7 @@ module Primer
18
19
  id: "button-preview",
19
20
  tag: :button,
20
21
  disabled: false,
22
+ inactive: false,
21
23
  icon: :plus,
22
24
  aria_label: "Button",
23
25
  show_tooltip: true
@@ -28,6 +30,7 @@ module Primer
28
30
  id: id,
29
31
  tag: tag,
30
32
  disabled: disabled,
33
+ inactive: inactive,
31
34
  icon: icon,
32
35
  "aria-label": aria_label,
33
36
  show_tooltip: show_tooltip
@@ -1,4 +1,4 @@
1
- <%= render(Primer::Alpha::NavList.new(aria: { label: "Workflow results" })) do |list| %>
1
+ <%= render(Primer::Beta::NavList.new(aria: { label: "Workflow results" })) do |list| %>
2
2
  <% list.with_group do |group| %>
3
3
  <% group.with_heading(title: "Workflows") %>
4
4
  <% group.with_item(label: "Build and Test", href: "/workflows/1") do |item| %>
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- module Alpha
4
+ module Beta
5
5
  # @label NavList
6
6
  class NavListPreview < ViewComponent::Preview
7
7
  # @label Playground
8
8
  def playground
9
- render(Primer::Alpha::NavList.new(selected_item_id: :collaborators)) do |list|
9
+ render(Primer::Beta::NavList.new(selected_item_id: :collaborators)) do |list|
10
10
  list.with_heading(title: "Repository settings")
11
11
 
12
12
  list.with_item(label: "General", href: "/general") do |item|
@@ -34,7 +34,7 @@ module Primer
34
34
  # @label Default
35
35
  # @snapshot
36
36
  def default
37
- render(Primer::Alpha::NavList.new(selected_item_id: :code_review_limits)) do |list|
37
+ render(Primer::Beta::NavList.new(selected_item_id: :code_review_limits)) do |list|
38
38
  list.with_heading(title: "Repository settings")
39
39
 
40
40
  list.with_item(label: "General", href: "/general") do |item|
@@ -77,7 +77,7 @@ module Primer
77
77
  # @label Top-level items
78
78
  #
79
79
  def top_level_items
80
- render(Primer::Alpha::NavList.new) do |list|
80
+ render(Primer::Beta::NavList.new) do |list|
81
81
  list.with_heading(title: "Account settings")
82
82
 
83
83
  list.with_item(label: "General", href: "/general") do |item|
@@ -105,7 +105,7 @@ module Primer
105
105
  # @label Show more item
106
106
  # @snapshot
107
107
  def show_more_item
108
- render(Primer::Alpha::NavList.new(aria: { label: "My favorite foods" })) do |list|
108
+ render(Primer::Beta::NavList.new(aria: { label: "My favorite foods" })) do |list|
109
109
  list.with_group do |group|
110
110
  group.with_heading(title: "My favorite foods")
111
111
  group.with_item(label: "Popplers", href: "/foods/popplers")
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Setup Playground to use all available component props
4
+ # Setup Features to use individual component props and combinations
5
+
6
+ module Primer
7
+ module OpenProject
8
+ # @label FlexLayout
9
+ class FlexLayoutPreview < ViewComponent::Preview
10
+ # @label Playground
11
+ # @param direction [Symbol] select [column, column_reverse, row, row_reverse]
12
+ # @param justify_content [Symbol] select [space_between, space_around, center, flex_start, flex_end]
13
+ def playground(direction: :row, justify_content: :flex_start)
14
+ render(Primer::OpenProject::FlexLayout.new(direction: direction, justify_content: justify_content)) do |component|
15
+ component.with_box(bg: :attention, p: 6) do
16
+ "Block 1"
17
+ end
18
+ component.with_box(bg: :accent, p: 6) do
19
+ "Block 2"
20
+ end
21
+ end
22
+ end
23
+
24
+ # @label Default
25
+ def default
26
+ render(Primer::OpenProject::FlexLayout.new) do |component|
27
+ component.with_column(bg: :attention, p: 6) do
28
+ "Block 1"
29
+ end
30
+ component.with_column(bg: :accent, p: 6) do
31
+ "Block 2"
32
+ end
33
+ end
34
+ end
35
+
36
+ # @label Row layout
37
+ def row_layout
38
+ render(Primer::OpenProject::FlexLayout.new) do |component|
39
+ component.with_row(bg: :attention, p: 6) do
40
+ "Block 1"
41
+ end
42
+ component.with_row(bg: :accent, p: 6) do
43
+ "Block 2"
44
+ end
45
+ end
46
+ end
47
+
48
+ # @label Column layout
49
+ def column_layout
50
+ render(Primer::OpenProject::FlexLayout.new) do |component|
51
+ component.with_column(bg: :attention, p: 6) do
52
+ "Block 1"
53
+ end
54
+ component.with_column(bg: :accent, p: 6) do
55
+ "Block 2"
56
+ end
57
+ end
58
+ end
59
+
60
+ # @label Nested layout
61
+ def nested_layout
62
+ render(Primer::OpenProject::FlexLayout.new) do |component|
63
+ component.with_row(flex_layout: true) do |flex_child|
64
+ flex_child.with_column(bg: :attention, p: 3) { "Block 1" }
65
+ flex_child.with_column(bg: :success, p: 3) { "Block 2" }
66
+ end
67
+
68
+ component.with_row(bg: :accent, p: 6) { "Block 3" }
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Setup Playground to use all available component props
4
+ # Setup Features to use individual component props and combinations
5
+
6
+ module Primer
7
+ module OpenProject
8
+ # @label GridLayout
9
+ class GridLayoutPreview < ViewComponent::Preview
10
+ # @label Playground
11
+ def playground
12
+ render(Primer::OpenProject::GridLayout.new(css_class: "grid-layout", tag: :div)) do |component|
13
+ component.with_area(:area1, bg: :attention, p: 6) do
14
+ "Block 1"
15
+ end
16
+ component.with_area(:area2, bg: :accent, p: 6) do
17
+ "Block 2"
18
+ end
19
+ end
20
+ end
21
+
22
+ # The component can be used for easy layouting of multiple child components.
23
+ # The component sets classes as well the grid-area definitions. The actual grid template can then be defined a separate CSS file.
24
+ # @label Default
25
+ def default
26
+ render(Primer::OpenProject::GridLayout.new(css_class: "grid-layout", tag: :div)) do |component|
27
+ component.with_area(:area1, bg: :attention, p: 6) do
28
+ "Block 1"
29
+ end
30
+ component.with_area(:area2, bg: :accent, p: 6) do
31
+ "Block 2"
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end