primer_view_components 0.0.116 → 0.0.117

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -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.css +1 -1
  8. data/app/components/primer/alpha/action_list.css.json +1 -1
  9. data/app/components/primer/alpha/action_list.css.map +1 -1
  10. data/app/components/primer/alpha/auto_complete/item.rb +4 -4
  11. data/app/components/primer/alpha/auto_complete.rb +6 -6
  12. data/app/components/primer/alpha/dialog.rb +0 -2
  13. data/app/components/primer/alpha/dropdown.rb +53 -53
  14. data/app/components/primer/alpha/hellip_button.rb +41 -0
  15. data/app/components/primer/alpha/hidden_text_expander.rb +1 -1
  16. data/app/components/primer/alpha/layout.rb +48 -48
  17. data/app/components/primer/alpha/menu.css +1 -1
  18. data/app/components/primer/alpha/menu.css.json +1 -1
  19. data/app/components/primer/alpha/menu.css.map +1 -1
  20. data/app/components/primer/alpha/menu.rb +5 -5
  21. data/app/components/primer/alpha/segmented_control.rb +20 -20
  22. data/app/components/primer/{tab_container_component.d.ts → alpha/tab_container.d.ts} +0 -0
  23. data/app/components/primer/{tab_container_component.js → alpha/tab_container.js} +0 -0
  24. data/app/components/primer/alpha/tab_container.rb +43 -0
  25. data/app/components/primer/{tab_container_component.ts → alpha/tab_container.ts} +0 -0
  26. data/app/components/primer/alpha/tab_nav.css +1 -1
  27. data/app/components/primer/alpha/tab_nav.css.json +1 -1
  28. data/app/components/primer/alpha/tab_nav.css.map +1 -1
  29. data/app/components/primer/alpha/tab_nav.rb +32 -32
  30. data/app/components/primer/alpha/tool_tip.js +3 -7
  31. data/app/components/primer/alpha/tool_tip.ts +3 -7
  32. data/app/components/primer/alpha/tooltip.rb +18 -18
  33. data/app/components/primer/alpha/underline_nav.css +1 -1
  34. data/app/components/primer/alpha/underline_nav.css.json +1 -1
  35. data/app/components/primer/alpha/underline_nav.css.map +1 -1
  36. data/app/components/primer/alpha/underline_nav.rb +18 -18
  37. data/app/components/primer/beta/auto_complete/item.rb +2 -3
  38. data/app/components/primer/beta/auto_complete.rb +14 -16
  39. data/app/components/primer/beta/avatar_stack.rb +12 -14
  40. data/app/components/primer/beta/blankslate.rb +0 -1
  41. data/app/components/primer/beta/border_box/header.rb +0 -2
  42. data/app/components/primer/beta/border_box.rb +0 -2
  43. data/app/components/primer/beta/breadcrumbs.css +1 -1
  44. data/app/components/primer/beta/breadcrumbs.css.json +1 -1
  45. data/app/components/primer/beta/breadcrumbs.css.map +1 -1
  46. data/app/components/primer/beta/breadcrumbs.rb +0 -1
  47. data/app/components/primer/beta/button.rb +9 -10
  48. data/app/components/primer/beta/button_group.rb +0 -1
  49. data/app/components/primer/beta/details.rb +0 -1
  50. data/app/components/primer/beta/flash.rb +0 -1
  51. data/app/components/primer/beta/link.rb +2 -3
  52. data/app/components/primer/beta/octicon.rb +0 -1
  53. data/app/components/primer/beta/popover.rb +0 -1
  54. data/app/components/primer/{state_component.css → beta/state.css} +0 -0
  55. data/app/components/primer/beta/state.css.json +1 -0
  56. data/app/components/primer/beta/state.css.map +1 -0
  57. data/app/components/primer/{state_component.pcss → beta/state.pcss} +0 -0
  58. data/app/components/primer/beta/state.rb +76 -0
  59. data/app/components/primer/{subhead_component.css → beta/subhead.css} +0 -0
  60. data/app/components/primer/beta/subhead.css.json +1 -0
  61. data/app/components/primer/beta/subhead.css.map +1 -0
  62. data/app/components/primer/{subhead_component.html.erb → beta/subhead.html.erb} +0 -0
  63. data/app/components/primer/{subhead_component.pcss → beta/subhead.pcss} +0 -0
  64. data/app/components/primer/beta/subhead.rb +135 -0
  65. data/app/components/primer/{timeline_item_component.css → beta/timeline_item.css} +0 -0
  66. data/app/components/primer/beta/timeline_item.css.json +1 -0
  67. data/app/components/primer/beta/timeline_item.css.map +1 -0
  68. data/app/components/primer/{timeline_item_component.html.erb → beta/timeline_item.html.erb} +0 -0
  69. data/app/components/primer/{timeline_item_component.pcss → beta/timeline_item.pcss} +0 -0
  70. data/app/components/primer/beta/timeline_item.rb +90 -0
  71. data/app/components/primer/beta/truncate.css +1 -1
  72. data/app/components/primer/beta/truncate.css.json +1 -1
  73. data/app/components/primer/beta/truncate.css.map +1 -1
  74. data/app/components/primer/beta/truncate.rb +0 -1
  75. data/app/components/primer/button_component.rb +9 -9
  76. data/app/components/primer/component.rb +0 -1
  77. data/app/components/primer/hellip_button.rb +2 -34
  78. data/app/components/primer/navigation/tab_component.rb +16 -16
  79. data/app/components/primer/primer.d.ts +1 -1
  80. data/app/components/primer/primer.js +1 -1
  81. data/app/components/primer/primer.pcss +3 -3
  82. data/app/components/primer/primer.ts +1 -1
  83. data/app/components/primer/state_component.rb +2 -69
  84. data/app/components/primer/subhead_component.rb +2 -128
  85. data/app/components/primer/tab_container_component.rb +2 -36
  86. data/app/components/primer/timeline_item_component.rb +5 -78
  87. data/app/forms/example_toggle_switch_form/example_field_caption.html.erb +1 -0
  88. data/app/forms/example_toggle_switch_form.rb +8 -0
  89. data/app/forms/submit_button_form.rb +4 -4
  90. data/app/lib/primer/tabbed_component_helper.rb +1 -1
  91. data/lib/primer/deprecations.rb +7 -13
  92. data/lib/primer/deprecations.yml +24 -0
  93. data/lib/primer/forms/button.html.erb +2 -2
  94. data/lib/primer/forms/dsl/toggle_switch_input.rb +35 -0
  95. data/lib/primer/forms/toggle_switch.html.erb +17 -0
  96. data/lib/primer/forms/toggle_switch.rb +19 -0
  97. data/lib/primer/forms/toggle_switch_form.rb +74 -0
  98. data/lib/primer/view_components/linters/subhead_component_migration_counter.rb +1 -1
  99. data/lib/primer/view_components/version.rb +1 -1
  100. data/lib/rubocop/cop/primer/component_name_migration.rb +2 -1
  101. data/lib/tasks/docs.rake +6 -6
  102. data/previews/primer/alpha/action_list_preview.rb +44 -44
  103. data/previews/primer/alpha/dropdown_preview.rb +97 -97
  104. data/previews/primer/alpha/hellip_button_preview.rb +24 -0
  105. data/previews/primer/alpha/layout_preview.rb +63 -63
  106. data/previews/primer/alpha/menu_preview/default.html.erb +5 -5
  107. data/previews/primer/alpha/menu_preview/playground.html.erb +5 -5
  108. data/previews/primer/alpha/segmented_control_preview.rb +60 -60
  109. data/previews/primer/alpha/tab_nav_preview.rb +22 -22
  110. data/previews/primer/alpha/tab_panels_preview.rb +2 -2
  111. data/previews/primer/alpha/tooltip_preview/with_multiple_on_a_page.html.erb +6 -6
  112. data/previews/primer/alpha/tooltip_preview.rb +12 -12
  113. data/previews/primer/alpha/underline_nav_preview.rb +4 -4
  114. data/previews/primer/alpha/underline_panels_preview.rb +8 -8
  115. data/previews/primer/beta/auto_complete_item_preview/default.html.erb +2 -2
  116. data/previews/primer/beta/auto_complete_item_preview/playground.html.erb +2 -2
  117. data/previews/primer/beta/auto_complete_item_preview/with_description.html.erb +3 -3
  118. data/previews/primer/beta/auto_complete_preview/with_submit_button.html.erb +2 -2
  119. data/previews/primer/beta/auto_complete_preview.rb +18 -18
  120. data/previews/primer/beta/avatar_stack_preview.rb +32 -32
  121. data/previews/primer/beta/blankslate_preview.rb +40 -40
  122. data/previews/primer/beta/border_box_preview.rb +38 -38
  123. data/previews/primer/beta/breadcrumbs_preview.rb +2 -2
  124. data/previews/primer/beta/button_group_preview.rb +10 -10
  125. data/previews/primer/beta/button_preview/all_schemes.html.erb +4 -4
  126. data/previews/primer/beta/button_preview/invisible_all_visuals.html.erb +16 -16
  127. data/previews/primer/beta/button_preview/leading_visual.html.erb +2 -2
  128. data/previews/primer/beta/button_preview/trailing_action.html.erb +2 -2
  129. data/previews/primer/beta/button_preview/trailing_visual.html.erb +2 -2
  130. data/previews/primer/beta/button_preview/with_tooltip.html.erb +2 -2
  131. data/previews/primer/beta/details_preview.rb +6 -6
  132. data/previews/primer/beta/state_preview.rb +66 -0
  133. data/previews/primer/beta/subhead_preview/actions.html.erb +14 -0
  134. data/previews/primer/beta/subhead_preview.rb +99 -0
  135. data/previews/primer/beta/timeline_item_preview.rb +30 -0
  136. data/previews/primer/forms/forms_preview/example_toggle_switch_form.html.erb +1 -0
  137. data/previews/primer/forms/forms_preview.rb +2 -0
  138. data/static/arguments.json +118 -118
  139. data/static/audited_at.json +6 -0
  140. data/static/constants.json +67 -54
  141. data/static/statuses.json +12 -6
  142. metadata +36 -23
  143. data/app/components/primer/state_component.css.json +0 -1
  144. data/app/components/primer/state_component.css.map +0 -1
  145. data/app/components/primer/subhead_component.css.json +0 -1
  146. data/app/components/primer/subhead_component.css.map +0 -1
  147. data/app/components/primer/timeline_item_component.css.json +0 -1
  148. data/app/components/primer/timeline_item_component.css.map +0 -1
  149. data/previews/primer/hellip_button_preview.rb +0 -22
  150. data/previews/primer/state_component_preview.rb +0 -26
  151. data/previews/primer/subhead_component_preview.rb +0 -40
  152. data/previews/primer/timeline_item_component_preview.rb +0 -28
@@ -10,47 +10,47 @@ module Primer
10
10
  # @param scheme [Symbol] select [default, neutral, info, warning]
11
11
  def playground(padding: :default, scheme: :default)
12
12
  render(Primer::Beta::BorderBox.new(padding: padding)) do |component|
13
- component.header { "Header" }
14
- component.body { "Body" }
15
- component.row(scheme: scheme) { "#{scheme.to_s.capitalize} row one" }
16
- component.row(scheme: scheme) { "#{scheme.to_s.capitalize} row two" }
17
- component.row(scheme: scheme) { "#{scheme.to_s.capitalize} row three" }
18
- component.footer { "Footer" }
13
+ component.with_header { "Header" }
14
+ component.with_body { "Body" }
15
+ component.with_row(scheme: scheme) { "#{scheme.to_s.capitalize} row one" }
16
+ component.with_row(scheme: scheme) { "#{scheme.to_s.capitalize} row two" }
17
+ component.with_row(scheme: scheme) { "#{scheme.to_s.capitalize} row three" }
18
+ component.with_footer { "Footer" }
19
19
  end
20
20
  end
21
21
 
22
22
  # @label Default
23
23
  def default
24
24
  render(Primer::Beta::BorderBox.new) do |component|
25
- component.header { "Header" }
26
- component.body { "Body" }
27
- component.row { "Row one" }
28
- component.row { "Row two" }
29
- component.row { "Row three" }
30
- component.footer { "Footer" }
25
+ component.with_header { "Header" }
26
+ component.with_body { "Body" }
27
+ component.with_row { "Row one" }
28
+ component.with_row { "Row two" }
29
+ component.with_row { "Row three" }
30
+ component.with_footer { "Footer" }
31
31
  end
32
32
  end
33
33
 
34
34
  # @label Header with title
35
35
  def header_with_title
36
36
  render(Primer::Beta::BorderBox.new) do |component|
37
- component.with_header do |h|
38
- h.title(tag: :h2) do
37
+ component.with_header do |header|
38
+ header.with_title(tag: :h2) do
39
39
  "Header with title"
40
40
  end
41
41
  end
42
- component.body { "Body" }
43
- component.footer { "Footer" }
42
+ component.with_body { "Body" }
43
+ component.with_footer { "Footer" }
44
44
  end
45
45
  end
46
46
 
47
47
  # @label Row colors
48
48
  def row_colors
49
49
  render(Primer::Beta::BorderBox.new) do |component|
50
- component.row(scheme: :default) { "Default" }
51
- component.row(scheme: :neutral) { "Neutral" }
52
- component.row(scheme: :info) { "Info" }
53
- component.row(scheme: :warning) { "Warning" }
50
+ component.with_row(scheme: :default) { "Default" }
51
+ component.with_row(scheme: :neutral) { "Neutral" }
52
+ component.with_row(scheme: :info) { "Info" }
53
+ component.with_row(scheme: :warning) { "Warning" }
54
54
  end
55
55
  end
56
56
 
@@ -59,36 +59,36 @@ module Primer
59
59
  # @label Default
60
60
  def padding_default
61
61
  render(Primer::Beta::BorderBox.new) do |component|
62
- component.header { "Header" }
63
- component.body { "Body" }
64
- component.row { "Row one" }
65
- component.row { "Row two" }
66
- component.row { "Row three" }
67
- component.footer { "Footer" }
62
+ component.with_header { "Header" }
63
+ component.with_body { "Body" }
64
+ component.with_row { "Row one" }
65
+ component.with_row { "Row two" }
66
+ component.with_row { "Row three" }
67
+ component.with_footer { "Footer" }
68
68
  end
69
69
  end
70
70
 
71
71
  # @label Condensed
72
72
  def padding_condensed
73
73
  render(Primer::Beta::BorderBox.new(padding: :condensed)) do |component|
74
- component.header { "Header" }
75
- component.body { "Body" }
76
- component.row { "Row one" }
77
- component.row { "Row two" }
78
- component.row { "Row three" }
79
- component.footer { "Footer" }
74
+ component.with_header { "Header" }
75
+ component.with_body { "Body" }
76
+ component.with_row { "Row one" }
77
+ component.with_row { "Row two" }
78
+ component.with_row { "Row three" }
79
+ component.with_footer { "Footer" }
80
80
  end
81
81
  end
82
82
 
83
83
  # @label Spacious
84
84
  def padding_spacious
85
85
  render(Primer::Beta::BorderBox.new(padding: :spacious)) do |component|
86
- component.header { "Header" }
87
- component.body { "Body" }
88
- component.row { "Row one" }
89
- component.row { "Row two" }
90
- component.row { "Row three" }
91
- component.footer { "Footer" }
86
+ component.with_header { "Header" }
87
+ component.with_body { "Body" }
88
+ component.with_row { "Row one" }
89
+ component.with_row { "Row two" }
90
+ component.with_row { "Row three" }
91
+ component.with_footer { "Footer" }
92
92
  end
93
93
  end
94
94
  #
@@ -10,7 +10,7 @@ module Primer
10
10
  def playground(number_of_links: 2)
11
11
  render(Primer::Beta::Breadcrumbs.new) do |component|
12
12
  Array.new(number_of_links || 3) do |i|
13
- component.item(href: "##{i}") { "Breadcrumb Item #{i + 1}" }
13
+ component.with_item(href: "##{i}") { "Breadcrumb Item #{i + 1}" }
14
14
  end
15
15
  end
16
16
  end
@@ -21,7 +21,7 @@ module Primer
21
21
  def default(number_of_links: 2)
22
22
  render(Primer::Beta::Breadcrumbs.new) do |component|
23
23
  Array.new(number_of_links || 3) do |i|
24
- component.item(href: "##{i}") { "Breadcrumb Item #{i + 1}" }
24
+ component.with_item(href: "##{i}") { "Breadcrumb Item #{i + 1}" }
25
25
  end
26
26
  end
27
27
  end
@@ -8,11 +8,11 @@ module Primer
8
8
  #
9
9
  # @param size [Symbol] select [medium, small]
10
10
  def playground(size: :medium)
11
- render(Primer::Beta::ButtonGroup.new(size: size)) do |c|
12
- c.button { "Button" }
13
- c.button(scheme: :primary) { "Primary" }
14
- c.button(scheme: :danger) { "Danger" }
15
- c.button(scheme: :outline) { "Outline" }
11
+ render(Primer::Beta::ButtonGroup.new(size: size)) do |component|
12
+ component.with_button { "Button" }
13
+ component.with_button(scheme: :primary) { "Primary" }
14
+ component.with_button(scheme: :danger) { "Danger" }
15
+ component.with_button(scheme: :outline) { "Outline" }
16
16
  end
17
17
  end
18
18
 
@@ -20,11 +20,11 @@ module Primer
20
20
  #
21
21
  # @param size [Symbol] select [medium, small]
22
22
  def default(size: :medium)
23
- render(Primer::Beta::ButtonGroup.new(size: size)) do |c|
24
- c.button { "Button" }
25
- c.button(scheme: :primary) { "Primary" }
26
- c.button(scheme: :danger) { "Danger" }
27
- c.button(scheme: :outline) { "Outline" }
23
+ render(Primer::Beta::ButtonGroup.new(size: size)) do |component|
24
+ component.with_button { "Button" }
25
+ component.with_button(scheme: :primary) { "Primary" }
26
+ component.with_button(scheme: :danger) { "Danger" }
27
+ component.with_button(scheme: :outline) { "Outline" }
28
28
  end
29
29
  end
30
30
  end
@@ -2,25 +2,25 @@
2
2
  <%= render(Primer::Beta::Button.new(
3
3
  scheme: :secondary,
4
4
  size: :medium,
5
- )) do |c| %>
5
+ )) do %>
6
6
  Button
7
7
  <% end %>
8
8
  <%= render(Primer::Beta::Button.new(
9
9
  scheme: :primary,
10
10
  size: :medium,
11
- )) do |c| %>
11
+ )) do %>
12
12
  Button
13
13
  <% end %>
14
14
  <%= render(Primer::Beta::Button.new(
15
15
  scheme: :invisible,
16
16
  size: :medium,
17
- )) do |c| %>
17
+ )) do %>
18
18
  Button
19
19
  <% end %>
20
20
  <%= render(Primer::Beta::Button.new(
21
21
  scheme: :danger,
22
22
  size: :medium,
23
- )) do |c| %>
23
+ )) do %>
24
24
  Button
25
25
  <% end %>
26
26
  </div>
@@ -2,53 +2,53 @@
2
2
  <%= render(Primer::Beta::Button.new(
3
3
  scheme: :invisible,
4
4
  size: :medium,
5
- )) do |c| %>
5
+ )) do %>
6
6
  Button
7
7
  <% end %>
8
8
  <%= render(Primer::Beta::Button.new(
9
9
  scheme: :invisible,
10
10
  size: :medium,
11
- )) do |c| %>
12
- <% c.leading_visual_icon(icon: :search) %>
11
+ )) do |component| %>
12
+ <% component.with_leading_visual_icon(icon: :search) %>
13
13
  Button
14
14
  <% end %>
15
15
  <%= render(Primer::Beta::Button.new(
16
16
  scheme: :invisible,
17
17
  size: :medium,
18
- )) do |c| %>
19
- <% c.trailing_action_icon(icon: "triangle-down") %>
18
+ )) do |component| %>
19
+ <% component.with_trailing_action_icon(icon: "triangle-down") %>
20
20
  Button
21
21
  <% end %>
22
22
  <%= render(Primer::Beta::Button.new(
23
23
  scheme: :invisible,
24
24
  size: :medium,
25
- )) do |c| %>
26
- <% c.trailing_visual_counter(count: "15") %>
25
+ )) do |component| %>
26
+ <% component.with_trailing_visual_counter(count: "15") %>
27
27
  Button
28
28
  <% end %>
29
29
  <%= render(Primer::Beta::Button.new(
30
30
  scheme: :invisible,
31
31
  size: :medium,
32
- )) do |c| %>
33
- <% c.leading_visual_icon(icon: :eye) %>
34
- <% c.trailing_visual_counter(count: "15") %>
32
+ )) do |component| %>
33
+ <% component.with_leading_visual_icon(icon: :eye) %>
34
+ <% component.with_trailing_visual_counter(count: "15") %>
35
35
  Button
36
36
  <% end %>
37
37
  <%= render(Primer::Beta::Button.new(
38
38
  scheme: :invisible,
39
39
  size: :medium,
40
- )) do |c| %>
41
- <% c.leading_visual_icon(icon: :eye) %>
42
- <% c.trailing_visual_counter(count: "15") %>
43
- <% c.trailing_action_icon(icon: "triangle-down") %>
40
+ )) do |component| %>
41
+ <% component.with_leading_visual_icon(icon: :eye) %>
42
+ <% component.with_trailing_visual_counter(count: "15") %>
43
+ <% component.with_trailing_action_icon(icon: "triangle-down") %>
44
44
  Button
45
45
  <% end %>
46
46
  <%= render(Primer::Beta::Button.new(
47
47
  scheme: :invisible,
48
48
  size: :medium,
49
49
  id: "my-id"
50
- )) do |c| %>
51
- <% c.with_tooltip(text: "Tooltip text") %>
50
+ )) do |component| %>
51
+ <% component.with_tooltip(text: "Tooltip text") %>
52
52
  Button with tooltip
53
53
  <% end %>
54
54
  </div>
@@ -4,7 +4,7 @@
4
4
  block: block,
5
5
  id: id,
6
6
  align_content: align_content
7
- )) do |c| %>
8
- <% c.leading_visual_icon(icon: :search) %>
7
+ )) do |component| %>
8
+ <% component.with_leading_visual_icon(icon: :search) %>
9
9
  Button
10
10
  <% end %>
@@ -4,7 +4,7 @@
4
4
  block: block,
5
5
  id: id,
6
6
  align_content: align_content
7
- )) do |c| %>
8
- <% c.trailing_action_icon(icon: "triangle-down") %>
7
+ )) do |component| %>
8
+ <% component.with_trailing_action_icon(icon: "triangle-down") %>
9
9
  Button
10
10
  <% end %>
@@ -5,7 +5,7 @@
5
5
  id: id,
6
6
  align_content: align_content,
7
7
  tag: tag
8
- )) do |c| %>
9
- <% c.trailing_visual_counter(count: "15") %>
8
+ )) do |component| %>
9
+ <% component.with_trailing_visual_counter(count: "15") %>
10
10
  Button
11
11
  <% end %>
@@ -4,7 +4,7 @@
4
4
  block: block,
5
5
  id: id,
6
6
  align_content: align_content
7
- )) do |c| %>
8
- <% c.with_tooltip(text: "Tooltip text") %>
7
+ )) do |component| %>
8
+ <% component.with_tooltip(text: "Tooltip text") %>
9
9
  Button
10
10
  <% end %>
@@ -9,11 +9,11 @@ module Primer
9
9
  # @param overlay [Symbol] select [none, default, dark]
10
10
  # @param reset [Boolean] toggle
11
11
  def playground(reset: false, overlay: :default)
12
- render Primer::Beta::Details.new(reset: reset, overlay: overlay) do |c|
13
- c.with_summary do
12
+ render Primer::Beta::Details.new(reset: reset, overlay: overlay) do |component|
13
+ component.with_summary do
14
14
  "Summary"
15
15
  end
16
- c.with_body do
16
+ component.with_body do
17
17
  "Body"
18
18
  end
19
19
  end
@@ -24,11 +24,11 @@ module Primer
24
24
  # @param overlay [Symbol] select [none, default, dark]
25
25
  # @param reset [Boolean] toggle
26
26
  def default(reset: false, overlay: :default)
27
- render Primer::Beta::Details.new(reset: reset, overlay: overlay) do |c|
28
- c.with_summary do
27
+ render Primer::Beta::Details.new(reset: reset, overlay: overlay) do |component|
28
+ component.with_summary do
29
29
  "Summary"
30
30
  end
31
- c.with_body do
31
+ component.with_body do
32
32
  "Body"
33
33
  end
34
34
  end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label State
6
+ class StatePreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param title [String]
10
+ # @param tag [Symbol] select [span, div]
11
+ # @param size [Symbol] select [default, small]
12
+ # @param scheme [Symbol] select [default, open, closed, merged]
13
+ def playground(title: "State", scheme: :default, size: :default, tag: :span)
14
+ render(Primer::Beta::State.new(title: title, scheme: scheme, size: size, tag: tag)) { "State" }
15
+ end
16
+
17
+ # @label Default
18
+ #
19
+ # @param title [String]
20
+ # @param tag [Symbol] select [span, div]
21
+ # @param size [Symbol] select [default, small]
22
+ # @param scheme [Symbol] select [default, open, closed, merged]
23
+ def default(title: "State", scheme: :default, size: :default, tag: :span)
24
+ render(Primer::Beta::State.new(title: title, scheme: scheme, size: size, tag: tag)) { "State" }
25
+ end
26
+
27
+ # @!group States
28
+ #
29
+ # @label Default
30
+ def states_default
31
+ render(Primer::Beta::State.new(title: "Default")) { "Default state" }
32
+ end
33
+
34
+ # @label Open
35
+ def states_open
36
+ render(Primer::Beta::State.new(title: "Open", scheme: :open)) { "Open state" }
37
+ end
38
+
39
+ # @label Closed
40
+ def states_closed
41
+ render(Primer::Beta::State.new(title: "Closed", scheme: :closed)) { "Closed state" }
42
+ end
43
+
44
+ # @label Merged
45
+ def states_merged
46
+ render(Primer::Beta::State.new(title: "Merged", scheme: :merged)) { "Merged state" }
47
+ end
48
+ #
49
+ # @!endgroup
50
+
51
+ # @!group Sizes
52
+ #
53
+ # @label Default
54
+ def sizes_default
55
+ render(Primer::Beta::State.new(title: "Default")) { "Default size" }
56
+ end
57
+
58
+ # @label Small
59
+ def sizes_small
60
+ render(Primer::Beta::State.new(title: "Default", size: :small)) { "Small size" }
61
+ end
62
+ #
63
+ # @!endgroup
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,14 @@
1
+ <%= render(Primer::Beta::Subhead.new) do |component| %>
2
+ <% component.with_heading do %>
3
+ A Heading
4
+ <% end %>
5
+ <% component.with_description do %>
6
+ A description with actions
7
+ <% end %>
8
+ <% component.with_actions do %>
9
+ <% render(Primer::Beta::Button.new(scheme: :primary)) do %>
10
+ An action
11
+ <% end %>
12
+ <% end %>
13
+ <% end %>
14
+
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label Subhead
6
+ class SubheadPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param spacious [Boolean]
10
+ # @param hide_border [Boolean]
11
+ # @param heading_danger [Boolean]
12
+ # @param heading_tag [Symbol] select [div, h1, h2, h3, h4, h5, h6]
13
+ def playground(spacious: false, hide_border: false, heading_tag: :div, heading_danger: false)
14
+ render(Primer::Beta::Subhead.new(spacious: spacious, hide_border: hide_border)) do |component|
15
+ component.with_heading(tag: heading_tag, danger: heading_danger) do
16
+ "My Heading"
17
+ end
18
+ component.with_description do
19
+ "My Description"
20
+ end
21
+ end
22
+ end
23
+
24
+ # @label Default Options
25
+ #
26
+ # @param spacious [Boolean]
27
+ # @param hide_border [Boolean]
28
+ # @param heading_danger [Boolean]
29
+ # @param heading_tag [Symbol] select [div, h1, h2, h3, h4, h5, h6]
30
+ def default(spacious: false, hide_border: false, heading_tag: :div, heading_danger: false)
31
+ render(Primer::Beta::Subhead.new(spacious: spacious, hide_border: hide_border)) do |component|
32
+ component.with_heading(tag: heading_tag, danger: heading_danger) do
33
+ "My Heading"
34
+ end
35
+ component.with_description do
36
+ "My Description"
37
+ end
38
+ end
39
+ end
40
+
41
+ # @label Danger
42
+ def danger
43
+ render(Primer::Beta::Subhead.new) do |component|
44
+ component.with_heading(danger: true) do
45
+ "Danger Heading"
46
+ end
47
+ component.with_description do
48
+ "A description of the 'danger'"
49
+ end
50
+ end
51
+ end
52
+
53
+ # @label Actions
54
+ def actions
55
+ render_with_template(locals: {})
56
+ end
57
+
58
+ # @!group Spacing
59
+ #
60
+ # @label Default
61
+ def spacing_default
62
+ render(Primer::Beta::Subhead.new(spacious: false)) do |component|
63
+ component.with_heading do
64
+ "Default Spacing"
65
+ end
66
+ component.with_description do
67
+ "Default spacing above the component"
68
+ end
69
+ end
70
+ end
71
+
72
+ # @label Spacious
73
+ def spacing_spacious
74
+ render(Primer::Beta::Subhead.new(spacious: true)) do |component|
75
+ component.with_heading do
76
+ "Spacious"
77
+ end
78
+ component.with_description do
79
+ "With extra space above the component"
80
+ end
81
+ end
82
+ end
83
+
84
+ # @label Spacious w/ Danger Heading
85
+ def spacing_dangerous
86
+ render(Primer::Beta::Subhead.new(spacious: true)) do |component|
87
+ component.with_heading(danger: true) do
88
+ "Danger Heading"
89
+ end
90
+ component.with_description do
91
+ "With extra space above the component, and a 'danger' heading"
92
+ end
93
+ end
94
+ end
95
+ #
96
+ # @!endgroup
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label TimelineItem
6
+ class TimelineItemPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param condensed [Boolean]
10
+ def playground(condensed: false)
11
+ render(Primer::Beta::TimelineItem.new(condensed: condensed)) do |component|
12
+ component.with_avatar(src: Primer::ExampleImage::BASE64_SRC, alt: "octocat")
13
+ component.with_badge(bg: :success_emphasis, color: :on_emphasis, icon: :check)
14
+ component.with_body { "Success!" }
15
+ end
16
+ end
17
+
18
+ # @label Default
19
+ #
20
+ # @param condensed [Boolean]
21
+ def default(condensed: false)
22
+ render(Primer::Beta::TimelineItem.new(condensed: condensed)) do |component|
23
+ component.with_avatar(src: Primer::ExampleImage::BASE64_SRC, alt: "octocat")
24
+ component.with_badge(bg: :success_emphasis, color: :on_emphasis, icon: :check)
25
+ component.with_body { "Success!" }
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1 @@
1
+ <%= render(ExampleToggleSwitchForm.new(csrf: "let_me_in", src: toggle_switch_index_path)) %>
@@ -39,6 +39,8 @@ module Primer
39
39
  def name_with_question_mark_form; end
40
40
 
41
41
  def immediate_validation_form; end
42
+
43
+ def example_toggle_switch_form; end
42
44
  end
43
45
  end
44
46
  end