openproject-primer_view_components 0.29.0 → 0.30.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +32 -0
  3. data/app/assets/javascripts/app/components/primer/open_project/page_header_element.d.ts +0 -2
  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_list/form_wrapper.rb +5 -0
  9. data/app/components/primer/alpha/button_marketing.rb +2 -0
  10. data/app/components/primer/alpha/dialog/header.html.erb +3 -0
  11. data/app/components/primer/alpha/dialog/header.rb +26 -0
  12. data/app/components/primer/alpha/overlay/header.html.erb +3 -1
  13. data/app/components/primer/alpha/overlay/header.rb +15 -0
  14. data/app/components/primer/alpha/tab_nav.css +1 -1
  15. data/app/components/primer/alpha/tab_nav.css.json +2 -0
  16. data/app/components/primer/alpha/tab_nav.css.map +1 -1
  17. data/app/components/primer/alpha/tab_nav.pcss +10 -0
  18. data/app/components/primer/alpha/tab_panels.html.erb +5 -9
  19. data/app/components/primer/alpha/tab_panels.rb +4 -13
  20. data/app/components/primer/alpha/underline_nav.css +1 -1
  21. data/app/components/primer/alpha/underline_nav.css.json +2 -0
  22. data/app/components/primer/alpha/underline_nav.css.map +1 -1
  23. data/app/components/primer/alpha/underline_nav.pcss +7 -1
  24. data/app/components/primer/alpha/underline_panels.css +1 -0
  25. data/app/components/primer/alpha/underline_panels.css.json +6 -0
  26. data/app/components/primer/alpha/underline_panels.css.map +1 -0
  27. data/app/components/primer/alpha/underline_panels.html.erb +6 -8
  28. data/app/components/primer/alpha/underline_panels.pcss +4 -0
  29. data/app/components/primer/alpha/underline_panels.rb +6 -14
  30. data/app/components/primer/anchored_position.js +2 -0
  31. data/app/components/primer/anchored_position.ts +2 -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.html.erb +6 -1
  35. data/app/components/primer/beta/button.pcss +1 -0
  36. data/app/components/primer/beta/button.rb +9 -1
  37. data/app/components/primer/open_project/page_header.css +1 -1
  38. data/app/components/primer/open_project/page_header.css.json +0 -1
  39. data/app/components/primer/open_project/page_header.css.map +1 -1
  40. data/app/components/primer/open_project/page_header.html.erb +2 -0
  41. data/app/components/primer/open_project/page_header.pcss +0 -10
  42. data/app/components/primer/open_project/page_header.rb +53 -36
  43. data/app/components/primer/open_project/page_header_element.d.ts +0 -2
  44. data/app/components/primer/open_project/page_header_element.js +1 -16
  45. data/app/components/primer/open_project/page_header_element.ts +1 -16
  46. data/app/components/primer/open_project/zen_mode_button.html.erb +1 -0
  47. data/app/components/primer/open_project/zen_mode_button.rb +2 -0
  48. data/app/components/primer/primer.pcss +1 -0
  49. data/lib/primer/view_components/version.rb +1 -1
  50. data/previews/primer/alpha/button_marketing_preview.rb +15 -3
  51. data/previews/primer/alpha/dialog_preview/with_header_filter.html.erb +19 -0
  52. data/previews/primer/alpha/dialog_preview.rb +4 -0
  53. data/previews/primer/alpha/overlay_preview/in_a_sticky_container.html.erb +19 -0
  54. data/previews/primer/alpha/overlay_preview.rb +15 -0
  55. data/previews/primer/beta/button_group_preview.rb +3 -7
  56. data/previews/primer/beta/button_preview/small_scheme_one_character.html.erb +5 -0
  57. data/previews/primer/beta/button_preview/summary_as_button.html.erb +14 -0
  58. data/previews/primer/beta/button_preview.rb +42 -12
  59. data/previews/primer/open_project/page_header_preview.rb +15 -0
  60. data/static/arguments.json +0 -12
  61. data/static/classes.json +0 -3
  62. data/static/constants.json +1 -1
  63. data/static/info_arch.json +131 -17
  64. data/static/previews.json +93 -2
  65. metadata +10 -2
@@ -47,16 +47,6 @@
47
47
  align-items: center;
48
48
  }
49
49
 
50
- .PageHeader--singleAction .PageHeader-action {
51
- @media (max-width: 543.98px) {
52
- position: absolute;
53
- top: 10px;
54
-
55
- /* Normally, the actions are hidden on mobile, except for this special case of a single action */
56
- display: flex !important;
57
- }
58
- }
59
-
60
50
  .PageHeader-breadcrumbs {
61
51
  display: block;
62
52
  width: 100%;
@@ -21,7 +21,7 @@ module Primer
21
21
  ].freeze
22
22
 
23
23
  DEFAULT_ACTION_SCHEME = :default
24
- MORE_MENU_DISPLAY = [:flex, :none].freeze
24
+ MOBILE_ACTIONS_DISPLAY = [:flex, :none].freeze
25
25
 
26
26
  DEFAULT_LEADING_ACTION_DISPLAY = [:none, :flex].freeze
27
27
  DEFAULT_BREADCRUMBS_DISPLAY = [:none, :flex].freeze
@@ -58,32 +58,37 @@ module Primer
58
58
  #
59
59
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
60
60
  renders_many :actions, types: {
61
- icon_button: lambda { |icon:, mobile_icon:, label:, scheme: DEFAULT_ACTION_SCHEME, **system_arguments|
61
+ icon_button: lambda { |icon:, mobile_icon:, label:, scheme: DEFAULT_ACTION_SCHEME, **system_arguments, &block|
62
62
  deny_tag_argument(**system_arguments)
63
63
 
64
- system_arguments = set_action_arguments(system_arguments, scheme: scheme, button_action: true)
64
+ system_arguments[:icon] = icon
65
+ system_arguments[:"aria-label"] ||= label
66
+ system_arguments = set_action_arguments(system_arguments, scheme: scheme)
65
67
 
66
- add_option_to_mobile_menu(system_arguments, mobile_icon, label, scheme)
68
+ component = Primer::Beta::IconButton
69
+ create_mobile_alternatives(component, mobile_icon, label, scheme, **system_arguments, &block)
67
70
 
68
- Primer::Beta::IconButton.new(icon: icon, "aria-label": label, **system_arguments)
71
+ component.new(**system_arguments)
69
72
  },
70
- button: lambda { |mobile_icon:, mobile_label:, scheme: DEFAULT_ACTION_SCHEME, **system_arguments|
73
+ button: lambda { |mobile_icon:, mobile_label:, scheme: DEFAULT_ACTION_SCHEME, **system_arguments, &block|
71
74
  deny_tag_argument(**system_arguments)
72
75
 
73
- system_arguments = set_action_arguments(system_arguments, scheme: scheme, button_action: true)
76
+ system_arguments = set_action_arguments(system_arguments, scheme: scheme)
74
77
 
75
- add_option_to_mobile_menu(system_arguments, mobile_icon, mobile_label, scheme)
78
+ component = Primer::Beta::Button
79
+ create_mobile_alternatives(component, mobile_icon, mobile_label, scheme, **system_arguments, &block)
76
80
 
77
- Primer::Beta::Button.new(**system_arguments)
81
+ component.new(**system_arguments)
78
82
  },
79
- zen_mode_button: lambda { |mobile_icon: Primer::OpenProject::ZenModeButton::ZEN_MODE_BUTTON_ICON, mobile_label: Primer::OpenProject::ZenModeButton::ZEN_MODE_BUTTON_LABEL, **system_arguments|
83
+ zen_mode_button: lambda { |mobile_icon: Primer::OpenProject::ZenModeButton::ZEN_MODE_BUTTON_ICON, mobile_label: Primer::OpenProject::ZenModeButton::ZEN_MODE_BUTTON_LABEL, **system_arguments, &block|
80
84
  deny_tag_argument(**system_arguments)
81
85
 
82
- system_arguments = set_action_arguments(system_arguments, scheme: DEFAULT_ACTION_SCHEME, button_action: true)
86
+ system_arguments = set_action_arguments(system_arguments, scheme: DEFAULT_ACTION_SCHEME)
83
87
 
84
- add_option_to_mobile_menu(system_arguments, mobile_icon, mobile_label, DEFAULT_ACTION_SCHEME)
88
+ component = Primer::OpenProject::ZenModeButton
89
+ create_mobile_alternatives(component, mobile_icon, mobile_label, DEFAULT_ACTION_SCHEME, **system_arguments, &block)
85
90
 
86
- Primer::OpenProject::ZenModeButton.new(**system_arguments)
91
+ component.new(**system_arguments)
87
92
  },
88
93
 
89
94
  link: lambda { |mobile_icon:, mobile_label:, scheme: DEFAULT_ACTION_SCHEME, **system_arguments|
@@ -109,29 +114,31 @@ module Primer
109
114
  renders: lambda { |**system_arguments, &block|
110
115
  deny_tag_argument(**system_arguments)
111
116
 
112
- system_arguments[:menu_arguments] = set_action_arguments(system_arguments[:menu_arguments])
113
117
  system_arguments[:button_arguments] ||= {}
114
- system_arguments[:button_arguments][:data] ||= {}
115
- system_arguments[:button_arguments][:data][:targets] = "page-header.actionItems"
118
+ system_arguments[:button_arguments] = set_action_arguments(system_arguments[:button_arguments])
116
119
 
117
120
  # Add the options individually to the mobile menu in the template
118
121
  @desktop_menu_block = block
119
122
 
120
- Primer::OpenProject::PageHeader::Menu.new(**system_arguments)
123
+ component = Primer::OpenProject::PageHeader::Menu
124
+ create_mobile_single_action(component, **system_arguments, &block)
125
+
126
+ component.new(**system_arguments)
121
127
  },
122
128
  },
123
129
  dialog: {
124
- renders: lambda { |mobile_icon:, mobile_label:, **system_arguments|
130
+ renders: lambda { |mobile_icon:, mobile_label:, **system_arguments, &block|
125
131
  deny_tag_argument(**system_arguments)
126
132
 
127
133
  # The id will be automatically calculated for the trigger button, so we have to behave the same, for the mobile click to work
128
134
  system_arguments[:button_arguments] ||= {}
129
135
  system_arguments[:button_arguments][:id] = "dialog-show-#{system_arguments[:dialog_arguments][:id]}"
130
- system_arguments[:button_arguments] = set_action_arguments(system_arguments[:button_arguments], button_action: true)
136
+ system_arguments[:button_arguments] = set_action_arguments(system_arguments[:button_arguments])
131
137
 
132
- add_option_to_mobile_menu(system_arguments[:button_arguments], mobile_icon, mobile_label, :default)
138
+ component = Primer::OpenProject::PageHeader::Dialog
139
+ create_mobile_alternatives(component, mobile_icon, mobile_label, :default, **system_arguments, &block)
133
140
 
134
- Primer::OpenProject::PageHeader::Dialog.new(**system_arguments)
141
+ component.new(**system_arguments)
135
142
  },
136
143
  },
137
144
  }
@@ -212,7 +219,7 @@ module Primer
212
219
  )
213
220
 
214
221
  @mobile_action_menu = Primer::Alpha::ActionMenu.new(
215
- display: MORE_MENU_DISPLAY,
222
+ display: MOBILE_ACTIONS_DISPLAY,
216
223
  anchor_align: :end
217
224
  )
218
225
  end
@@ -224,15 +231,6 @@ module Primer
224
231
  title? && breadcrumbs?
225
232
  end
226
233
 
227
- def before_render
228
- @system_arguments[:classes] = class_names(
229
- @system_arguments[:classes],
230
- "PageHeader--singleAction": !render_mobile_menu?
231
- )
232
-
233
- content
234
- end
235
-
236
234
  def render_mobile_menu?
237
235
  actions.count > 1
238
236
  end
@@ -242,26 +240,32 @@ module Primer
242
240
  def set_action_arguments(system_arguments, scheme: nil, button_action: false)
243
241
  system_arguments[:ml] ||= 2
244
242
  system_arguments[:display] = [:none, :flex]
243
+ system_arguments[:size] = :medium
245
244
  system_arguments[:scheme] = scheme unless scheme.nil?
246
245
  system_arguments[:classes] = class_names(
247
246
  system_arguments[:classes],
248
247
  "PageHeader-action",
249
248
  )
250
- if button_action
251
- system_arguments[:data] ||= {}
252
- system_arguments[:data][:targets] = "page-header.actionItems"
253
- end
254
249
 
255
250
  system_arguments[:id] ||= self.class.generate_id
256
251
  system_arguments
257
252
  end
258
253
 
254
+ def create_mobile_alternatives(component, mobile_icon, mobile_label, scheme, **system_arguments, &block)
255
+ # All actions should collapse into a single actionMenu on mobile
256
+ add_option_to_mobile_menu(system_arguments, mobile_icon, mobile_label, scheme)
257
+
258
+ # Except for single actions, which remain as they are, just smaller.
259
+ create_mobile_single_action(component, **system_arguments, &block)
260
+ end
261
+
259
262
  def add_option_to_mobile_menu(system_arguments, mobile_icon, mobile_label, scheme)
260
263
  unless mobile_icon.nil? || mobile_label.nil?
261
264
  # In action menus, only :default and :danger are allowed
262
265
  scheme = DEFAULT_ACTION_SCHEME unless scheme == :danger
263
266
 
264
- with_menu_item(id: system_arguments[:id], label: mobile_label, scheme: scheme) do |c|
267
+ id = system_arguments[:button_arguments].present? ? system_arguments[:button_arguments][:id] : system_arguments[:id]
268
+ with_menu_item(id: id, label: mobile_label, scheme: scheme) do |c|
265
269
  c.with_leading_visual_icon(icon: mobile_icon)
266
270
  end
267
271
  end
@@ -281,6 +285,19 @@ module Primer
281
285
  )
282
286
  end
283
287
 
288
+ def create_mobile_single_action(component, **system_arguments, &block)
289
+ # Single actions shall not collapse into an action menu on mobile, but keep their state.
290
+ # However the position and size will change
291
+ unless render_mobile_menu?
292
+ mobile_options = system_arguments[:button_arguments].present? ?
293
+ { button_arguments: { display: MOBILE_ACTIONS_DISPLAY, size: :small } } :
294
+ { display: MOBILE_ACTIONS_DISPLAY, size: :small }
295
+
296
+ @mobile_action = component.new(**system_arguments.deep_merge(mobile_options))
297
+ @mobile_action_block = block
298
+ end
299
+ end
300
+
284
301
  # transform anchor tag strings to {href, text} objects
285
302
  # e.g "\u003ca href=\"/admin\"\u003eAdministration\u003c/a\u003e"
286
303
  def anchor_string_to_object(html_string)
@@ -1,6 +1,4 @@
1
1
  declare class PageHeaderElement extends HTMLElement {
2
- actionItems: HTMLElement[];
3
- connectedCallback(): void;
4
2
  menuItemClick(event: Event): void;
5
3
  }
6
4
  declare global {
@@ -4,20 +4,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { controller, targets } from '@github/catalyst';
7
+ import { controller } from '@github/catalyst';
8
8
  let PageHeaderElement = class PageHeaderElement extends HTMLElement {
9
- connectedCallback() {
10
- for (const item of this.actionItems) {
11
- /*
12
- If there is only one action to be shown, we show that instead of the mobile action menu. However, the buttons should be the smaller button variant.
13
- Unfortunately, the `size` attribute does not support responsive attributes and the .pcss syntax does not support inheritance between classes.
14
- So we have to add the class manually here.
15
- */
16
- if (window.innerWidth <= 544) {
17
- item.classList.add('Button--small');
18
- }
19
- }
20
- }
21
9
  menuItemClick(event) {
22
10
  const currentTarget = event.currentTarget;
23
11
  const id = currentTarget?.getAttribute('data-for');
@@ -26,9 +14,6 @@ let PageHeaderElement = class PageHeaderElement extends HTMLElement {
26
14
  }
27
15
  }
28
16
  };
29
- __decorate([
30
- targets
31
- ], PageHeaderElement.prototype, "actionItems", void 0);
32
17
  PageHeaderElement = __decorate([
33
18
  controller
34
19
  ], PageHeaderElement);
@@ -1,22 +1,7 @@
1
- import {controller, targets} from '@github/catalyst'
1
+ import {controller} from '@github/catalyst'
2
2
 
3
3
  @controller
4
4
  class PageHeaderElement extends HTMLElement {
5
- @targets actionItems: HTMLElement[]
6
-
7
- connectedCallback() {
8
- for (const item of this.actionItems) {
9
- /*
10
- If there is only one action to be shown, we show that instead of the mobile action menu. However, the buttons should be the smaller button variant.
11
- Unfortunately, the `size` attribute does not support responsive attributes and the .pcss syntax does not support inheritance between classes.
12
- So we have to add the class manually here.
13
- */
14
- if (window.innerWidth <= 544) {
15
- item.classList.add('Button--small')
16
- }
17
- }
18
- }
19
-
20
5
  menuItemClick(event: Event) {
21
6
  const currentTarget = event.currentTarget as HTMLButtonElement
22
7
 
@@ -4,6 +4,7 @@
4
4
  scheme: :default,
5
5
  id: "zenModeButton",
6
6
  icon: ZEN_MODE_BUTTON_ICON,
7
+ size: @button_size,
7
8
  aria: { label: ZEN_MODE_BUTTON_LABEL },
8
9
  data: { target: "zen-mode-button.button", action: "click:zen-mode-button#performAction" }
9
10
  )
@@ -20,6 +20,8 @@ module Primer
20
20
  @system_arguments[:classes],
21
21
  "ZenModeButton"
22
22
  )
23
+
24
+ @button_size = @system_arguments[:size] || Primer::Beta::Button::DEFAULT_SIZE
23
25
  end
24
26
  end
25
27
  end
@@ -12,6 +12,7 @@
12
12
  @import "./alpha/button_marketing.pcss";
13
13
  @import "./alpha/toggle_switch.pcss";
14
14
  @import "./alpha/underline_nav.pcss";
15
+ @import "./alpha/underline_panels.pcss";
15
16
  @import "./alpha/segmented_control.pcss";
16
17
  @import "./alpha/menu.pcss";
17
18
 
@@ -5,7 +5,7 @@ module Primer
5
5
  module ViewComponents
6
6
  module VERSION
7
7
  MAJOR = 0
8
- MINOR = 29
8
+ MINOR = 30
9
9
  PATCH = 0
10
10
 
11
11
  STRING = [MAJOR, MINOR, PATCH].join(".")
@@ -10,19 +10,31 @@ module Primer
10
10
  # @param tag [Symbol] select [button, a]
11
11
  # @param type [Symbol] select [button, submit]
12
12
  # @param disabled [Boolean]
13
- def playground(tag: :button, type: :button, scheme: :default, variant: :default, disabled: false)
14
- render(Primer::Alpha::ButtonMarketing.new(tag: tag, type: type, scheme: scheme, variant: variant, disabled: disabled)) { "Default" }
13
+ def playground(tag: :button, type: :button, scheme: :default, variant: :default, disabled: false, href: nil)
14
+ # Sets default href to `a`, to ensure it's keyboard interactive and proper markup
15
+ if tag == :a && href.nil?
16
+ href = "#"
17
+ end
18
+ render(Primer::Alpha::ButtonMarketing.new(tag: tag, type: type, scheme: scheme, variant: variant, disabled: disabled, href: href)) { "Default" }
15
19
  end
16
20
 
17
21
  # @label Default options
18
22
  # @param scheme [Symbol] select [default, primary, outline, transparent]
19
23
  # @param variant [Symbol] select [default, large]
20
- # @param tag [Symbol] select [button, a]
21
24
  # @param type [Symbol] select [button, submit]
22
25
  def default(tag: :button, type: :button, scheme: :default, variant: :default)
23
26
  render(Primer::Alpha::ButtonMarketing.new(tag: tag, type: type, scheme: scheme, variant: variant)) { "Default" }
24
27
  end
25
28
 
29
+ # @label Link as button options
30
+ # @param scheme [Symbol] select [default, primary, outline, transparent]
31
+ # @param variant [Symbol] select [default, large]
32
+ # @param type [Symbol] select [button, submit]
33
+ # @param href [String]
34
+ def link_as_button(tag: :a, href: "#", type: :button, scheme: :default, variant: :default)
35
+ render(Primer::Alpha::ButtonMarketing.new(tag: tag, href: href, type: type, scheme: scheme, variant: variant)) { "Default" }
36
+ end
37
+
26
38
  # @!group Size Variants
27
39
  # @snapshot
28
40
  #
@@ -0,0 +1,19 @@
1
+ <%= render(Primer::Alpha::Dialog.new(open: true, title: "Dialog")) do |dialog| %>
2
+ <% dialog.with_show_button { "Open" } %>
3
+ <% dialog.with_header do |header| %>
4
+ <% header.with_filter(pr: 3, pl: 3) do %>
5
+ <%= render Primer::Alpha::TextField.new(
6
+ autofocus: true,
7
+ visually_hide_label: true,
8
+ name: "filter",
9
+ label: "Filter dialog",
10
+ ) %>
11
+ <% end %>
12
+ <% end %>
13
+ <% dialog.with_body do %>
14
+ Body
15
+ <% end %>
16
+ <% dialog.with_footer do %>
17
+ Footer
18
+ <% end %>
19
+ <% end %>
@@ -296,6 +296,10 @@ module Primer
296
296
  d.with_body { body_text }
297
297
  end
298
298
  end
299
+
300
+ def with_header_filter
301
+ render_with_template(locals: {})
302
+ end
299
303
  end
300
304
  end
301
305
  end
@@ -0,0 +1,19 @@
1
+ <div style="position:sticky;top:0;" class="color-bg-accent">
2
+ <%= render(Primer::Alpha::Overlay.new(title: "Dialog", role: :dialog, size: :large, padding: :condensed)) do |d| %>
3
+ <% d.with_header(title: "Large Dialog Header", divider: true) do |header| %>
4
+ <% header.with_filter do %>
5
+ <%= render Primer::Alpha::TextField.new(
6
+ autofocus: true,
7
+ visually_hide_label:
8
+ true,
9
+ name: "filter",
10
+ label: "Filter Overlay"
11
+ ) %>
12
+ <% end %>
13
+ <% end %>
14
+ <% d.with_show_button { "Show Overlay" } %>
15
+ <% d.with_footer { "Large Dialog Footer" } %>
16
+ <% d.with_body { "This is a long body for the overlay dialog. <br>".html_safe * 20 } %>
17
+ <% end %>
18
+ </div>
19
+ <div style="height:3000px;"></div>
@@ -183,6 +183,21 @@ module Primer
183
183
  def overlay_with_header_filter
184
184
  render_with_template(locals: {})
185
185
  end
186
+
187
+ def overlay_with_header_subtitle
188
+ render(Primer::Alpha::Overlay.new(title: "Dialog", role: :dialog, size: :large, padding: :condensed)) do |d|
189
+ d.with_header(title: "Large Dialog Header", divider: true) do |h|
190
+ h.with_subtitle {"A subtitle"}
191
+ end
192
+ d.with_show_button { "Show Overlay" }
193
+ d.with_footer { "Large Dialog Footer" }
194
+ d.with_body { "This is a long body for the overlay dialog. <br>".html_safe * 20 }
195
+ end
196
+ end
197
+
198
+ def in_a_sticky_container
199
+ render_with_template(locals: {})
200
+ end
186
201
  end
187
202
  end
188
203
  end
@@ -63,22 +63,18 @@ module Primer
63
63
  end
64
64
  end
65
65
 
66
- # @label Button group with all tags
66
+ # @label Button group with multiple tags
67
67
  # @snapshot
68
- def all_tags
68
+ def multiple_tags
69
69
  render(Primer::Beta::ButtonGroup.new) do |component|
70
70
  component.with_button(id: "button-1", tag: :button) do |button|
71
71
  button.with_tooltip(text: "Button Tooltip")
72
72
  "Button 1"
73
73
  end
74
- component.with_button(id: "button-2", tag: :a) do |button|
74
+ component.with_button(id: "button-2", tag: :a, href: "#") do |button|
75
75
  button.with_tooltip(text: "Button Tooltip")
76
76
  "Button 2"
77
77
  end
78
- component.with_button(id: "button-3", tag: :summary) do |button|
79
- button.with_tooltip(text: "Button Tooltip")
80
- "Button 3"
81
- end
82
78
  end
83
79
  end
84
80
 
@@ -0,0 +1,5 @@
1
+ <%= render(Primer::Beta::Button.new(
2
+ size: :small,
3
+ )) do %>
4
+ i
5
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <details>
2
+ <%= render(Primer::Beta::Button.new(
3
+ scheme: scheme,
4
+ size: size,
5
+ block: block,
6
+ id: id,
7
+ align_content: align_content,
8
+ tag: tag
9
+ )) do %>
10
+ Button
11
+ <% end %>
12
+ <p>A wrapping `details` tag is required when using the button with the `:summary` tag</p>
13
+ </details>
14
+
@@ -20,7 +20,7 @@ module Primer
20
20
  # @param disabled toggle
21
21
  # @param inactive toggle
22
22
  # @param align_content select [center, start]
23
- # @param tag select [a, summary, button]
23
+ # @param tag select [a, button]
24
24
  # @param label_wrap toggle
25
25
  def playground(
26
26
  scheme: :default,
@@ -31,8 +31,13 @@ module Primer
31
31
  tag: :button,
32
32
  disabled: false,
33
33
  inactive: false,
34
- label_wrap: false
34
+ label_wrap: false,
35
+ href: nil
35
36
  )
37
+ # Sets default href to `a`, to ensure it's keyboard interactive and proper markup
38
+ if tag == :a && href.nil?
39
+ href = "#"
40
+ end
36
41
  render(Primer::Beta::Button.new(
37
42
  scheme: scheme,
38
43
  size: size,
@@ -42,8 +47,9 @@ module Primer
42
47
  tag: tag,
43
48
  disabled: disabled,
44
49
  inactive: inactive,
45
- label_wrap: label_wrap
46
- )) do |_c|
50
+ label_wrap: label_wrap,
51
+ href: href
52
+ )) do |_c|
47
53
  "Button"
48
54
  end
49
55
  end
@@ -51,7 +57,6 @@ module Primer
51
57
  # @label Default
52
58
  # @param block toggle
53
59
  # @param disabled toggle
54
- # @param tag select [a, summary, button]
55
60
  def default(
56
61
  block: false,
57
62
  id: "button-preview",
@@ -73,7 +78,6 @@ module Primer
73
78
  # @label Primary
74
79
  # @param block toggle
75
80
  # @param disabled toggle
76
- # @param tag select [a, summary, button]
77
81
  def primary(
78
82
  id: "button-preview",
79
83
  block: false,
@@ -95,7 +99,6 @@ module Primer
95
99
  # @label Danger
96
100
  # @param block toggle
97
101
  # @param disabled toggle
98
- # @param tag select [a, summary, button]
99
102
  def danger(
100
103
  id: "button-preview",
101
104
  block: false,
@@ -117,7 +120,6 @@ module Primer
117
120
  # @label Invisible
118
121
  # @param block toggle
119
122
  # @param disabled toggle
120
- # @param tag select [a, summary, button]
121
123
  def invisible(
122
124
  id: "button-preview",
123
125
  block: false,
@@ -145,7 +147,6 @@ module Primer
145
147
  # @label Link
146
148
  # @param block toggle
147
149
  # @param disabled toggle
148
- # @param tag select [a, summary, button]
149
150
  # @snapshot
150
151
  def link(
151
152
  id: "button-preview",
@@ -178,7 +179,6 @@ module Primer
178
179
 
179
180
  # @label Full width
180
181
  # @param disabled toggle
181
- # @param tag select [a, summary, button]
182
182
  # @snapshot
183
183
  def full_width(
184
184
  id: "button-preview",
@@ -222,6 +222,7 @@ module Primer
222
222
  # @param size select [small, medium]
223
223
  # @param block toggle
224
224
  # @param align_content select [center, start]
225
+ # @param href
225
226
  # @snapshot
226
227
  def link_as_button(
227
228
  scheme: :default,
@@ -245,12 +246,35 @@ module Primer
245
246
  end
246
247
  end
247
248
 
249
+ # @label Summary as button
250
+ # @param scheme select [default, primary, danger, invisible, link]
251
+ # @param size select [small, medium]
252
+ # @param block toggle
253
+ # @param align_content select [center, start]
254
+ # @snapshot
255
+ def summary_as_button(
256
+ scheme: :default,
257
+ size: :medium,
258
+ block: false,
259
+ id: "button-preview",
260
+ align_content: :center,
261
+ tag: :summary
262
+ )
263
+ render_with_template(locals: {
264
+ scheme: scheme,
265
+ size: size,
266
+ block: block,
267
+ id: id,
268
+ align_content: align_content,
269
+ tag: tag
270
+ })
271
+ end
272
+
248
273
  # @label Trailing visual
249
274
  # @param scheme select [default, primary, danger, invisible, link]
250
275
  # @param size select [small, medium]
251
276
  # @param block toggle
252
277
  # @param align_content select [center, start]
253
- # @param tag select [a, summary, button]
254
278
  # @snapshot
255
279
  def trailing_visual(
256
280
  scheme: :default,
@@ -258,7 +282,7 @@ module Primer
258
282
  block: false,
259
283
  id: "button-preview",
260
284
  align_content: :center,
261
- tag: :a
285
+ tag: :button
262
286
  )
263
287
  render_with_template(locals: {
264
288
  scheme: scheme,
@@ -390,6 +414,12 @@ module Primer
390
414
  def link_scheme_label_wrap
391
415
  render_with_template(locals: {})
392
416
  end
417
+
418
+ # @label Small scheme with one character
419
+ # @snapshot
420
+ def small_scheme_one_character
421
+ render_with_template(locals: {})
422
+ end
393
423
  end
394
424
  end
395
425
  end
@@ -120,6 +120,21 @@ module Primer
120
120
  end
121
121
  end
122
122
 
123
+
124
+ # @label With a single action
125
+ # The single action will not be transformed into a menu on mobile, but remains in a smaller variant
126
+ def single_action
127
+ render(Primer::OpenProject::PageHeader.new) do |component|
128
+ component.with_title { "Great news" }
129
+ component.with_breadcrumbs([{ href: "/foo", text: "Foo" }, { href: "/bar", text: "Bar" }, "Baz"])
130
+
131
+ component.with_action_button(mobile_icon: "plus", mobile_label: "Meeting", scheme: :primary) do |button|
132
+ button.with_leading_visual_icon(icon: "plus")
133
+ "Meeting"
134
+ end
135
+ end
136
+ end
137
+
123
138
  # @label With leading action (on wide)
124
139
  # **Leading action** is only shown on **wide screens** by default.
125
140
  # If you want to override that behaviour please use the system_argument: **display**
@@ -2462,18 +2462,6 @@
2462
2462
  "default": "N/A",
2463
2463
  "description": "One of `:left` or `:right`. - Defaults to left"
2464
2464
  },
2465
- {
2466
- "name": "body_arguments",
2467
- "type": "Hash",
2468
- "default": "`{}`",
2469
- "description": "[System arguments](/system-arguments) for the body wrapper."
2470
- },
2471
- {
2472
- "name": "wrapper_arguments",
2473
- "type": "Hash",
2474
- "default": "`{}`",
2475
- "description": "[System arguments](/system-arguments) for the `TabContainer` wrapper."
2476
- },
2477
2465
  {
2478
2466
  "name": "system_arguments",
2479
2467
  "type": "Hash",
data/static/classes.json CHANGED
@@ -429,9 +429,6 @@
429
429
  "PageHeader": [
430
430
  "Primer::OpenProject::PageHeader"
431
431
  ],
432
- "PageHeader--singleAction": [
433
- "Primer::OpenProject::PageHeader"
434
- ],
435
432
  "PageHeader-actions": [
436
433
  "Primer::OpenProject::PageHeader"
437
434
  ],