openproject-primer_view_components 0.12.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -0
  3. data/app/assets/javascripts/app/components/primer/alpha/tool_tip.d.ts +1 -0
  4. data/app/assets/javascripts/primer_view_components.js +1 -1
  5. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  6. data/app/assets/styles/primer_view_components.css +1 -1
  7. data/app/assets/styles/primer_view_components.css.map +1 -1
  8. data/app/components/primer/alpha/action_bar/item.rb +7 -4
  9. data/app/components/primer/alpha/action_bar.rb +2 -2
  10. data/app/components/primer/alpha/action_bar_element.js +9 -4
  11. data/app/components/primer/alpha/action_bar_element.ts +9 -2
  12. data/app/components/primer/alpha/action_list/form_wrapper.html.erb +4 -2
  13. data/app/components/primer/alpha/action_list/form_wrapper.rb +20 -9
  14. data/app/components/primer/alpha/action_menu/action_menu_element.js +160 -85
  15. data/app/components/primer/alpha/action_menu/action_menu_element.ts +195 -81
  16. data/app/components/primer/alpha/action_menu/list.rb +0 -2
  17. data/app/components/primer/alpha/action_menu.rb +120 -3
  18. data/app/components/primer/alpha/modal_dialog.js +10 -13
  19. data/app/components/primer/alpha/modal_dialog.ts +10 -13
  20. data/app/components/primer/alpha/segmented_control/item.html.erb +1 -8
  21. data/app/components/primer/alpha/segmented_control/item.rb +38 -4
  22. data/app/components/primer/alpha/segmented_control.css +1 -1
  23. data/app/components/primer/alpha/segmented_control.css.json +14 -13
  24. data/app/components/primer/alpha/segmented_control.css.map +1 -1
  25. data/app/components/primer/alpha/segmented_control.pcss +75 -66
  26. data/app/components/primer/alpha/segmented_control.rb +10 -0
  27. data/app/components/primer/alpha/text_field.css +1 -1
  28. data/app/components/primer/alpha/tool_tip.d.ts +1 -0
  29. data/app/components/primer/alpha/tool_tip.js +26 -93
  30. data/app/components/primer/alpha/tool_tip.ts +25 -91
  31. data/app/components/primer/beta/base_button.rb +4 -0
  32. data/app/components/primer/beta/button.css +1 -1
  33. data/app/components/primer/beta/button.css.map +1 -1
  34. data/app/components/primer/beta/button.pcss +6 -2
  35. data/app/components/primer/focus_group.js +28 -3
  36. data/app/components/primer/focus_group.ts +27 -1
  37. data/lib/primer/accessibility.rb +3 -1
  38. data/lib/primer/static/generate_info_arch.rb +86 -5
  39. data/lib/primer/view_components/version.rb +2 -2
  40. data/previews/primer/alpha/action_menu_preview/single_select_form_items.html.erb +31 -0
  41. data/previews/primer/alpha/action_menu_preview/with_actions.html.erb +6 -5
  42. data/previews/primer/alpha/action_menu_preview.rb +10 -1
  43. data/previews/primer/alpha/check_box_preview.rb +1 -0
  44. data/previews/primer/alpha/dialog_preview/autofocus_element.html.erb +8 -0
  45. data/previews/primer/alpha/dialog_preview.rb +5 -0
  46. data/previews/primer/alpha/radio_button_preview.rb +1 -0
  47. data/previews/primer/alpha/segmented_control_preview.rb +35 -0
  48. data/previews/primer/alpha/tooltip_preview/tooltip_with_dialog_moving_focus_to_input.html.erb +23 -0
  49. data/previews/primer/alpha/tooltip_preview.rb +6 -1
  50. data/previews/primer/beta/button_group_preview.rb +6 -6
  51. data/previews/primer/beta/button_preview.rb +20 -2
  52. data/previews/primer/beta/icon_button_preview.rb +3 -0
  53. data/static/arguments.json +18 -1
  54. data/static/classes.json +12 -0
  55. data/static/constants.json +12 -1
  56. data/static/info_arch.json +137 -161
  57. data/static/previews.json +91 -172
  58. metadata +5 -310
@@ -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)
@@ -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 %>
@@ -166,6 +166,11 @@ module Primer
166
166
  show_divider: show_divider
167
167
  })
168
168
  end
169
+
170
+ # @label Autofocus element with autofocus attribute
171
+ def autofocus_element
172
+ render_with_template(locals: {})
173
+ end
169
174
  end
170
175
  end
171
176
  end
@@ -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,
@@ -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,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
@@ -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
@@ -46,7 +46,18 @@
46
46
  "source": "https://github.com/primer/view_components/tree/main/app/components/primer/alpha/action_bar/item.rb",
47
47
  "lookbook": "https://primer.style/view-components/lookbook/inspect/primer/alpha/action_bar/item/default/",
48
48
  "parameters": [
49
-
49
+ {
50
+ "name": "item_content",
51
+ "type": "String",
52
+ "default": "N/A",
53
+ "description": "The content to render inside the item."
54
+ },
55
+ {
56
+ "name": "item_arguments",
57
+ "type": "Hash",
58
+ "default": "N/A",
59
+ "description": "[System arguments](/system-arguments)"
60
+ }
50
61
  ]
51
62
  },
52
63
  {
@@ -3117,6 +3128,12 @@
3117
3128
  "default": "`false`",
3118
3129
  "description": "Whether or not the button is disabled. If true, this option forces `tag:` to `:button`."
3119
3130
  },
3131
+ {
3132
+ "name": "inactive",
3133
+ "type": "Boolean",
3134
+ "default": "`false`",
3135
+ "description": "Whether the button looks visually disabled, but can still accept all the same interactions as an enabled button."
3136
+ },
3120
3137
  {
3121
3138
  "name": "system_arguments",
3122
3139
  "type": "Hash",
data/static/classes.json CHANGED
@@ -507,6 +507,18 @@
507
507
  "SegmentedControl--fullWidth": [
508
508
  "Primer::Alpha::SegmentedControl"
509
509
  ],
510
+ "SegmentedControl--iconOnly": [
511
+ "Primer::Alpha::SegmentedControl"
512
+ ],
513
+ "SegmentedControl--large": [
514
+ "Primer::Alpha::SegmentedControl"
515
+ ],
516
+ "SegmentedControl--medium": [
517
+ "Primer::Alpha::SegmentedControl"
518
+ ],
519
+ "SegmentedControl--small": [
520
+ "Primer::Alpha::SegmentedControl"
521
+ ],
510
522
  "SegmentedControl-item": [
511
523
  "Primer::Alpha::SegmentedControl"
512
524
  ],
@@ -544,9 +544,20 @@
544
544
  "Primer::Alpha::RadioButtonGroup": {
545
545
  },
546
546
  "Primer::Alpha::SegmentedControl": {
547
+ "DEFAULT_SIZE": "medium",
547
548
  "FULL_WIDTH_DEFAULT": false,
548
549
  "HIDE_LABELS_DEFAULT": false,
549
- "Item": "Primer::Alpha::SegmentedControl::Item"
550
+ "Item": "Primer::Alpha::SegmentedControl::Item",
551
+ "SIZE_MAPPINGS": {
552
+ "small": "SegmentedControl--small",
553
+ "medium": "SegmentedControl--medium",
554
+ "large": "SegmentedControl--large"
555
+ },
556
+ "SIZE_OPTIONS": [
557
+ "small",
558
+ "medium",
559
+ "large"
560
+ ]
550
561
  },
551
562
  "Primer::Alpha::SegmentedControl::Item": {
552
563
  },