primer_view_components 0.0.19 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +78 -1
  3. data/app/assets/javascripts/primer_view_components.js +2 -0
  4. data/app/assets/javascripts/primer_view_components.js.map +1 -0
  5. data/app/components/primer/avatar_component.rb +7 -7
  6. data/app/components/primer/avatar_stack_component.rb +3 -3
  7. data/app/components/primer/base_component.rb +1 -1
  8. data/app/components/primer/blankslate_component.html.erb +3 -3
  9. data/app/components/primer/blankslate_component.rb +16 -24
  10. data/app/components/primer/border_box_component.html.erb +4 -18
  11. data/app/components/primer/border_box_component.rb +58 -67
  12. data/app/components/primer/box_component.rb +2 -2
  13. data/app/components/primer/breadcrumb_component.html.erb +1 -2
  14. data/app/components/primer/breadcrumb_component.rb +24 -13
  15. data/app/components/primer/button_component.rb +2 -2
  16. data/app/components/primer/button_group_component.rb +1 -1
  17. data/app/components/primer/button_marketing_component.rb +2 -2
  18. data/app/components/primer/component.rb +4 -0
  19. data/app/components/primer/counter_component.rb +1 -1
  20. data/app/components/primer/details_component.html.erb +2 -6
  21. data/app/components/primer/details_component.rb +22 -35
  22. data/app/components/primer/dropdown_component.html.erb +2 -2
  23. data/app/components/primer/dropdown_component.rb +4 -6
  24. data/app/components/primer/dropdown_menu_component.rb +4 -4
  25. data/app/components/primer/flash_component.html.erb +4 -7
  26. data/app/components/primer/flash_component.rb +16 -20
  27. data/app/components/primer/flex_component.rb +4 -4
  28. data/app/components/primer/flex_item_component.rb +1 -1
  29. data/app/components/primer/heading_component.rb +3 -1
  30. data/app/components/primer/label_component.rb +15 -25
  31. data/app/components/primer/layout_component.rb +2 -2
  32. data/app/components/primer/link_component.rb +2 -2
  33. data/app/components/primer/markdown_component.rb +8 -8
  34. data/app/components/primer/menu_component.rb +1 -1
  35. data/app/components/primer/octicon_component.rb +5 -3
  36. data/app/components/primer/popover_component.rb +3 -3
  37. data/app/components/primer/primer.js +1 -0
  38. data/app/components/primer/primer.ts +1 -0
  39. data/app/components/primer/progress_bar_component.html.erb +1 -1
  40. data/app/components/primer/progress_bar_component.rb +27 -31
  41. data/app/components/primer/spinner_component.rb +3 -3
  42. data/app/components/primer/state_component.rb +21 -10
  43. data/app/components/primer/subhead_component.html.erb +3 -15
  44. data/app/components/primer/subhead_component.rb +45 -61
  45. data/app/components/primer/tab_container_component.js +1 -0
  46. data/app/components/primer/tab_container_component.rb +41 -0
  47. data/app/components/primer/tab_container_component.ts +1 -0
  48. data/app/components/primer/tab_nav_component.html.erb +17 -0
  49. data/app/components/primer/tab_nav_component.rb +108 -0
  50. data/app/components/primer/text_component.rb +1 -1
  51. data/app/components/primer/timeline_item_component.html.erb +4 -16
  52. data/app/components/primer/timeline_item_component.rb +41 -52
  53. data/app/components/primer/tooltip_component.rb +5 -5
  54. data/app/components/primer/truncate_component.rb +4 -4
  55. data/app/components/primer/underline_nav_component.rb +2 -2
  56. data/{lib → app/lib}/primer/class_name_helper.rb +0 -0
  57. data/{lib → app/lib}/primer/classify.rb +1 -3
  58. data/{lib → app/lib}/primer/classify/cache.rb +0 -0
  59. data/{lib → app/lib}/primer/fetch_or_fallback_helper.rb +0 -0
  60. data/{lib → app/lib}/primer/join_style_arguments_helper.rb +0 -0
  61. data/app/lib/primer/view_helper.rb +22 -0
  62. data/app/lib/primer/view_helper/dsl.rb +34 -0
  63. data/lib/primer/view_components/engine.rb +10 -2
  64. data/lib/primer/view_components/version.rb +5 -1
  65. data/static/statuses.json +1 -1
  66. metadata +18 -8
  67. data/app/components/primer/view_components.rb +0 -60
@@ -3,7 +3,7 @@
3
3
  module Primer
4
4
  # Use labels to add contextual metadata to a design.
5
5
  class LabelComponent < Primer::Component
6
- NEW_SCHEME_MAPPINGS = {
6
+ SCHEME_MAPPINGS = {
7
7
  primary: "Label--primary",
8
8
  secondary: "Label--secondary",
9
9
  info: "Label--info",
@@ -12,21 +12,6 @@ module Primer
12
12
  danger: "Label--danger"
13
13
  }.freeze
14
14
 
15
- DEPRECATED_SCHEME_MAPPINGS = {
16
- gray: "Label--gray",
17
- dark_gray: "Label--gray-darker",
18
- yellow: "Label--yellow",
19
- orange: "Label--orange",
20
- red: "Label--red",
21
- green: "Label--green",
22
- blue: "Label--blue",
23
- purple: "Label--purple",
24
- pink: "Label--pink",
25
- outline: "Label--outline",
26
- green_outline: "Label--outline-green"
27
- }.freeze
28
-
29
- SCHEME_MAPPINGS = NEW_SCHEME_MAPPINGS.merge(DEPRECATED_SCHEME_MAPPINGS)
30
15
  SCHEME_OPTIONS = SCHEME_MAPPINGS.keys << nil
31
16
 
32
17
  VARIANT_MAPPINGS = {
@@ -35,20 +20,21 @@ module Primer
35
20
  }.freeze
36
21
  VARIANT_OPTIONS = VARIANT_MAPPINGS.keys << nil
37
22
 
38
- # @example auto|Schemes
39
- # <%= render(Primer::LabelComponent.new(title: "Label: Label")) { "default" } %>
40
- # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :gray)) { "gray" } %>
41
- # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :dark_gray)) { "dark_gray" } %>
42
- # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :yellow)) { "yellow" } %>
43
- # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :green)) { "green" } %>
44
- # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :purple)) { "purple" } %>
23
+ # @example Schemes
24
+ # <%= render(Primer::LabelComponent.new(title: "Label: Label")) { "Default" } %>
25
+ # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :primary)) { "Primary" } %>
26
+ # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :secondary)) { "Secondary" } %>
27
+ # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :info)) { "Info" } %>
28
+ # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :success)) { "Success" } %>
29
+ # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :warning)) { "Warning" } %>
30
+ # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :danger)) { "Danger" } %>
45
31
  #
46
- # @example auto|Variants
32
+ # @example Variants
47
33
  # <%= render(Primer::LabelComponent.new(title: "Label: Label")) { "Default" } %>
48
34
  # <%= render(Primer::LabelComponent.new(title: "Label: Label", variant: :large)) { "Large" } %>
49
35
  #
50
36
  # @param title [String] `title` attribute for the component element.
51
- # @param scheme [Symbol] <%= one_of(Primer::LabelComponent::DEPRECATED_SCHEME_MAPPINGS.keys) %>
37
+ # @param scheme [Symbol] <%= one_of(Primer::LabelComponent::SCHEME_MAPPINGS.keys) %>
52
38
  # @param variant [Symbol] <%= one_of(Primer::LabelComponent::VARIANT_OPTIONS) %>
53
39
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
54
40
  def initialize(title:, scheme: nil, variant: nil, **system_arguments)
@@ -67,5 +53,9 @@ module Primer
67
53
  def call
68
54
  render(Primer::BaseComponent.new(**@system_arguments)) { content }
69
55
  end
56
+
57
+ def self.status
58
+ Primer::Component::STATUSES[:beta]
59
+ end
70
60
  end
71
61
  end
@@ -12,13 +12,13 @@ module Primer
12
12
  DEFAULT_SIDEBAR_COL = 3
13
13
  ALLOWED_SIDEBAR_COLS = (1..(MAX_COL - 1)).to_a.freeze
14
14
 
15
- # @example auto|Default
15
+ # @example Default
16
16
  # <%= render(Primer::LayoutComponent.new) do |component| %>
17
17
  # <% component.with(:sidebar) { "Sidebar" } %>
18
18
  # <% component.with(:main) { "Main" } %>
19
19
  # <% end %>
20
20
  #
21
- # @example auto|Left sidebar
21
+ # @example Left sidebar
22
22
  # <%= render(Primer::LayoutComponent.new(side: :left)) do |component| %>
23
23
  # <% component.with(:sidebar) { "Sidebar" } %>
24
24
  # <% component.with(:main) { "Main" } %>
@@ -3,10 +3,10 @@
3
3
  module Primer
4
4
  # Use links for moving from one page to another. The Link component styles anchor tags with default blue styling and hover text-decoration.
5
5
  class LinkComponent < Primer::Component
6
- # @example auto|Default
6
+ # @example Default
7
7
  # <%= render(Primer::LinkComponent.new(href: "http://www.google.com")) { "Link" } %>
8
8
  #
9
- # @example auto|Muted
9
+ # @example Muted
10
10
  # <%= render(Primer::LinkComponent.new(href: "http://www.google.com", muted: true)) { "Link" } %>
11
11
  #
12
12
  # @param href [String] URL to be used for the Link
@@ -3,7 +3,7 @@
3
3
  module Primer
4
4
  # Use MarkdownComponent to wrap markdown content
5
5
  class MarkdownComponent < Primer::Component
6
- # @example 5320|Default
6
+ # @example Default
7
7
  # <%= render(Primer::MarkdownComponent.new) do %>
8
8
  # <p>Text can be <b>bold</b>, <i>italic</i>, or <s>strikethrough</s>. <a href="https://github.com">Links </a> should be blue with no underlines (unless hovered over).</p>
9
9
  #
@@ -95,17 +95,17 @@ module Primer
95
95
  # <p>And an unordered task list:</p>
96
96
  #
97
97
  # <ul>
98
- # <li><input type="checkbox" checked> Create a sample markdown document</li>
99
- # <li><input type="checkbox"> Add task lists to it</li>
100
- # <li><input type="checkbox"> Take a vacation</li>
98
+ # <li><input type="checkbox" checked /> Create a sample markdown document</li>
99
+ # <li><input type="checkbox"/> Add task lists to it</li>
100
+ # <li><input type="checkbox"/> Take a vacation</li>
101
101
  # </ul>
102
102
  #
103
103
  # <p>And a "mixed" task list:</p>
104
104
  #
105
105
  # <ul>
106
- # <li><input type="checkbox"> Steal underpants</li>
106
+ # <li><input type="checkbox"/> Steal underpants</li>
107
107
  # <li>?</li>
108
- # <li><input type="checkbox"> Profit!</li>
108
+ # <li><input type="checkbox"/> Profit!</li>
109
109
  # </ul>
110
110
  #
111
111
  # And a nested list:
@@ -266,11 +266,11 @@ module Primer
266
266
  #
267
267
  # <p>Small images should be shown at their actual size.</p>
268
268
  #
269
- # <p><img src="http://placekitten.com/g/300/200/"></p>
269
+ # <p><img src="http://placekitten.com/g/300/200/"/></p>
270
270
  #
271
271
  # <p>Large images should always scale down and fit in the content container.</p>
272
272
  #
273
- # <p><img src="http://placekitten.com/g/1200/800/"></p>
273
+ # <p><img src="http://placekitten.com/g/1200/800/"/></p>
274
274
  #
275
275
  # <pre><code>This is the final element on the page and there should be no margin below this.</code></pre>
276
276
  # <% end %>
@@ -35,7 +35,7 @@ module Primer
35
35
  Primer::BaseComponent.new(**system_arguments)
36
36
  }
37
37
 
38
- # @example auto|Default
38
+ # @example Default
39
39
  # <%= render(Primer::MenuComponent.new) do |c| %>
40
40
  # <% c.heading do %>
41
41
  # Heading
@@ -3,6 +3,8 @@
3
3
  module Primer
4
4
  # Renders an [Octicon](https://primer.style/octicons/) with <%= link_to_system_arguments_docs %>.
5
5
  class OcticonComponent < Primer::Component
6
+ view_helper :octicon
7
+
6
8
  include Primer::ClassNameHelper
7
9
  include OcticonsHelper
8
10
 
@@ -14,13 +16,13 @@ module Primer
14
16
  }.freeze
15
17
  SIZE_OPTIONS = SIZE_MAPPINGS.keys
16
18
 
17
- # @example auto|Default
19
+ # @example Default
18
20
  # <%= render(Primer::OcticonComponent.new(icon: "check")) %>
19
21
  #
20
- # @example auto|Medium
22
+ # @example Medium
21
23
  # <%= render(Primer::OcticonComponent.new(icon: "people", size: :medium)) %>
22
24
  #
23
- # @example auto|Large
25
+ # @example Large
24
26
  # <%= render(Primer::OcticonComponent.new(icon: "x", size: :large)) %>
25
27
  #
26
28
  # @param icon [String] Name of [Octicon](https://primer.style/octicons/) to use.
@@ -10,7 +10,7 @@ module Primer
10
10
  with_slot :heading, class_name: "Heading"
11
11
  with_slot :body, class_name: "Body"
12
12
 
13
- # @example auto|Default
13
+ # @example Default
14
14
  # <%= render Primer::PopoverComponent.new do |component| %>
15
15
  # <% component.slot(:heading) do %>
16
16
  # Activity feed
@@ -20,7 +20,7 @@ module Primer
20
20
  # <% end %>
21
21
  # <% end %>
22
22
  #
23
- # @example auto|Large
23
+ # @example Large
24
24
  # <%= render Primer::PopoverComponent.new do |component| %>
25
25
  # <% component.slot(:heading) do %>
26
26
  # Activity feed
@@ -30,7 +30,7 @@ module Primer
30
30
  # <% end %>
31
31
  # <% end %>
32
32
  #
33
- # @example auto|Caret position
33
+ # @example Caret position
34
34
  # <%= render Primer::PopoverComponent.new do |component| %>
35
35
  # <% component.slot(:heading) do %>
36
36
  # Activity feed
@@ -0,0 +1 @@
1
+ import './tab_container_component';
@@ -0,0 +1 @@
1
+ import './tab_container_component'
@@ -1,5 +1,5 @@
1
1
  <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
2
  <% items.each do |item| %>
3
- <%= render Primer::BaseComponent.new(**item.system_arguments) %>
3
+ <%= item %>
4
4
  <% end %>
5
5
  <% end %>
@@ -3,9 +3,24 @@
3
3
  module Primer
4
4
  # Use ProgressBar to visualize task completion.
5
5
  class ProgressBarComponent < Primer::Component
6
- include ViewComponent::Slotable
6
+ include ViewComponent::SlotableV2
7
7
 
8
- with_slot :item, collection: true, class_name: "Item"
8
+ # Use the Item slot to add an item to the progress bas
9
+ #
10
+ # @param percentage [Integer] The percent complete
11
+ # @param bg [Symbol] The background color
12
+ # @param kwargs [Hash] The same arguments as <%= link_to_system_arguments_docs %>.
13
+ renders_many :items, lambda { |percentage: 0, bg: :green, **system_arguments|
14
+ percentage = percentage
15
+ system_arguments = system_arguments
16
+
17
+ system_arguments[:tag] = :span
18
+ system_arguments[:bg] = bg
19
+ system_arguments[:style] = join_style_arguments(system_arguments[:style], "width: #{percentage}%;")
20
+ system_arguments[:classes] = class_names("Progress-item", system_arguments[:classes])
21
+
22
+ Primer::BaseComponent.new(**system_arguments)
23
+ }
9
24
 
10
25
  SIZE_DEFAULT = :default
11
26
 
@@ -16,26 +31,26 @@ module Primer
16
31
  }.freeze
17
32
 
18
33
  SIZE_OPTIONS = SIZE_MAPPINGS.keys
19
- # @example auto|Default
34
+ # @example Default
20
35
  # <%= render(Primer::ProgressBarComponent.new) do |component| %>
21
- # <% component.slot(:item, percentage: 25) %>
36
+ # <% component.item(percentage: 25) %>
22
37
  # <% end %>
23
38
  #
24
- # @example auto|Small
39
+ # @example Small
25
40
  # <%= render(Primer::ProgressBarComponent.new(size: :small)) do |component| %>
26
- # <% component.slot(:item, bg: :blue_4, percentage: 50) %>
41
+ # <% component.item(bg: :blue_4, percentage: 50) %>
27
42
  # <% end %>
28
43
  #
29
- # @example auto|Large
44
+ # @example Large
30
45
  # <%= render(Primer::ProgressBarComponent.new(size: :large)) do |component| %>
31
- # <% component.slot(:item, bg: :red_4, percentage: 75) %>
46
+ # <% component.item(bg: :red_4, percentage: 75) %>
32
47
  # <% end %>
33
48
  #
34
- # @example auto|Multiple items
49
+ # @example Multiple items
35
50
  # <%= render(Primer::ProgressBarComponent.new) do |component| %>
36
- # <% component.slot(:item, percentage: 10) %>
37
- # <% component.slot(:item, bg: :blue_4, percentage: 20) %>
38
- # <% component.slot(:item, bg: :red_4, percentage: 30) %>
51
+ # <% component.item(percentage: 10) %>
52
+ # <% component.item(bg: :blue_4, percentage: 20) %>
53
+ # <% component.item(bg: :red_4, percentage: 30) %>
39
54
  # <% end %>
40
55
  #
41
56
  # @param size [Symbol] <%= one_of(Primer::ProgressBarComponent::SIZE_OPTIONS) %> Increases height.
@@ -53,24 +68,5 @@ module Primer
53
68
  def render?
54
69
  items.any?
55
70
  end
56
-
57
- # :nodoc:
58
- class Item < Primer::Slot
59
- attr_reader :system_arguments
60
-
61
- # @param percentage [Integer] Percentage completion of item.
62
- # @param bg [Symbol] Color of item.
63
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
64
- def initialize(percentage: 0, bg: :green, **system_arguments)
65
- @percentage = percentage
66
- @system_arguments = system_arguments
67
-
68
- @system_arguments[:tag] = :span
69
- @system_arguments[:bg] = bg
70
- @system_arguments[:style] =
71
- join_style_arguments(@system_arguments[:style], "width: #{@percentage}%;")
72
- @system_arguments[:classes] = class_names("Progress-item", @system_arguments[:classes])
73
- end
74
- end
75
71
  end
76
72
  end
@@ -15,13 +15,13 @@ module Primer
15
15
  DEFAULT_STYLE = "box-sizing: content-box; color: var(--color-icon-primary);"
16
16
 
17
17
  #
18
- # @example auto|Default
18
+ # @example Default
19
19
  # <%= render(Primer::SpinnerComponent.new) %>
20
20
  #
21
- # @example auto|Small
21
+ # @example Small
22
22
  # <%= render(Primer::SpinnerComponent.new(size: :small)) %>
23
23
  #
24
- # @example auto|Large
24
+ # @example Large
25
25
  # <%= render(Primer::SpinnerComponent.new(size: :large)) %>
26
26
  #
27
27
  # @param size [Symbol] <%= one_of(Primer::SpinnerComponent::SIZE_MAPPINGS) %>
@@ -4,12 +4,19 @@ module Primer
4
4
  # Component for rendering the status of an item.
5
5
  class StateComponent < Primer::Component
6
6
  COLOR_DEFAULT = :default
7
- COLOR_MAPPINGS = {
7
+ NEW_COLOR_MAPPINGS = {
8
+ open: "State--open",
9
+ closed: "State--closed",
10
+ merged: "State--merged"
11
+ }.freeze
12
+
13
+ DEPRECATED_COLOR_MAPPINGS = {
8
14
  COLOR_DEFAULT => "",
9
- :green => "State--green",
10
- :red => "State--red",
11
- :purple => "State--purple"
15
+ :green => "State--open",
16
+ :red => "State--closed",
17
+ :purple => "State--merged"
12
18
  }.freeze
19
+ COLOR_MAPPINGS = NEW_COLOR_MAPPINGS.merge(DEPRECATED_COLOR_MAPPINGS)
13
20
  COLOR_OPTIONS = COLOR_MAPPINGS.keys
14
21
 
15
22
  SIZE_DEFAULT = :default
@@ -22,16 +29,16 @@ module Primer
22
29
  TAG_DEFAULT = :span
23
30
  TAG_OPTIONS = [TAG_DEFAULT, :div, :a].freeze
24
31
 
25
- # @example auto|Default
32
+ # @example Default
26
33
  # <%= render(Primer::StateComponent.new(title: "title")) { "State" } %>
27
34
  #
28
- # @example auto|Colors
35
+ # @example Colors
29
36
  # <%= render(Primer::StateComponent.new(title: "title")) { "Default" } %>
30
- # <%= render(Primer::StateComponent.new(title: "title", color: :green)) { "Green" } %>
31
- # <%= render(Primer::StateComponent.new(title: "title", color: :red)) { "Red" } %>
32
- # <%= render(Primer::StateComponent.new(title: "title", color: :purple)) { "Purple" } %>
37
+ # <%= render(Primer::StateComponent.new(title: "title", color: :open)) { "Open" } %>
38
+ # <%= render(Primer::StateComponent.new(title: "title", color: :closed)) { "Closed" } %>
39
+ # <%= render(Primer::StateComponent.new(title: "title", color: :merged)) { "Merged" } %>
33
40
  #
34
- # @example auto|Sizes
41
+ # @example Sizes
35
42
  # <%= render(Primer::StateComponent.new(title: "title")) { "Default" } %>
36
43
  # <%= render(Primer::StateComponent.new(title: "title", size: :small)) { "Small" } %>
37
44
  #
@@ -61,5 +68,9 @@ module Primer
61
68
  def call
62
69
  render(Primer::BaseComponent.new(**@system_arguments)) { content }
63
70
  end
71
+
72
+ def self.status
73
+ Primer::Component::STATUSES[:beta]
74
+ end
64
75
  end
65
76
  end
@@ -1,17 +1,5 @@
1
1
  <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
- <% if heading.present? %>
3
- <%= render Primer::BaseComponent.new(**heading.system_arguments) do %>
4
- <%= heading.content %>
5
- <% end %>
6
- <% end %>
7
- <% if actions.present? %>
8
- <%= render Primer::BaseComponent.new(**actions.system_arguments) do %>
9
- <%= actions.content %>
10
- <% end %>
11
- <% end %>
12
- <% if description.present? %>
13
- <%= render Primer::BaseComponent.new(**description.system_arguments) do %>
14
- <%= description.content %>
15
- <% end %>
16
- <% end %>
2
+ <%= heading %>
3
+ <%= actions %>
4
+ <%= description %>
17
5
  <% end %>
@@ -3,41 +3,72 @@
3
3
  module Primer
4
4
  # Use the Subhead component for page headings.
5
5
  class SubheadComponent < Primer::Component
6
- include ViewComponent::Slotable
6
+ include ViewComponent::SlotableV2
7
7
 
8
- with_slot :heading, class_name: "Heading"
9
- with_slot :actions, class_name: "Actions"
10
- with_slot :description, class_name: "Description"
8
+ # The heading
9
+ #
10
+ # @param danger [Boolean] Whether to style the heading as dangerous.
11
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
12
+ renders_one :heading, lambda { |danger: false, **system_arguments|
13
+ system_arguments[:tag] ||= :div
14
+ system_arguments[:classes] = class_names(
15
+ system_arguments[:classes],
16
+ "Subhead-heading",
17
+ "Subhead-heading--danger": danger
18
+ )
19
+
20
+ Primer::BaseComponent.new(**system_arguments)
21
+ }
22
+
23
+ # Actions
24
+ #
25
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
26
+ renders_one :actions, lambda { |**system_arguments|
27
+ system_arguments[:tag] = :div
28
+ system_arguments[:classes] = class_names(system_arguments[:classes], "Subhead-actions")
29
+
30
+ Primer::BaseComponent.new(**system_arguments)
31
+ }
11
32
 
12
- # @example auto|Default
33
+ # The description
34
+ #
35
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
36
+ renders_one :description, lambda { |**system_arguments|
37
+ system_arguments[:tag] = :div
38
+ system_arguments[:classes] = class_names(system_arguments[:classes], "Subhead-description")
39
+
40
+ Primer::BaseComponent.new(**system_arguments)
41
+ }
42
+
43
+ # @example Default
13
44
  # <%= render(Primer::SubheadComponent.new) do |component| %>
14
- # <% component.slot(:heading) do %>
45
+ # <% component.heading do %>
15
46
  # My Heading
16
47
  # <% end %>
17
- # <% component.slot(:description) do %>
48
+ # <% component.description do %>
18
49
  # My Description
19
50
  # <% end %>
20
51
  # <% end %>
21
52
  #
22
- # @example auto|Without border
53
+ # @example Without border
23
54
  # <%= render(Primer::SubheadComponent.new(hide_border: true)) do |component| %>
24
- # <% component.slot(:heading) do %>
55
+ # <% component.heading do %>
25
56
  # My Heading
26
57
  # <% end %>
27
- # <% component.slot(:description) do %>
58
+ # <% component.description do %>
28
59
  # My Description
29
60
  # <% end %>
30
61
  # <% end %>
31
62
  #
32
- # @example auto|With actions
63
+ # @example With actions
33
64
  # <%= render(Primer::SubheadComponent.new) do |component| %>
34
- # <% component.slot(:heading) do %>
65
+ # <% component.heading do %>
35
66
  # My Heading
36
67
  # <% end %>
37
- # <% component.slot(:description) do %>
68
+ # <% component.description do %>
38
69
  # My Description
39
70
  # <% end %>
40
- # <% component.slot(:actions) do %>
71
+ # <% component.actions do %>
41
72
  # <%= render(
42
73
  # Primer::ButtonComponent.new(
43
74
  # tag: :a, href: "http://www.google.com", button_type: :danger
@@ -66,52 +97,5 @@ module Primer
66
97
  def render?
67
98
  heading.present?
68
99
  end
69
-
70
- # :nodoc:
71
- class Heading < ViewComponent::Slot
72
- include ClassNameHelper
73
-
74
- attr_reader :system_arguments
75
-
76
- # @param danger [Boolean] Whether to style the heading as dangerous.
77
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
78
- def initialize(danger: false, **system_arguments)
79
- @system_arguments = system_arguments
80
- @system_arguments[:tag] ||= :div
81
- @system_arguments[:classes] = class_names(
82
- @system_arguments[:classes],
83
- "Subhead-heading",
84
- "Subhead-heading--danger": danger
85
- )
86
- end
87
- end
88
-
89
- # :nodoc:
90
- class Actions < ViewComponent::Slot
91
- include ClassNameHelper
92
-
93
- attr_reader :system_arguments
94
-
95
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
96
- def initialize(**system_arguments)
97
- @system_arguments = system_arguments
98
- @system_arguments[:tag] = :div
99
- @system_arguments[:classes] = class_names(@system_arguments[:classes], "Subhead-actions")
100
- end
101
- end
102
-
103
- # :nodoc:
104
- class Description < ViewComponent::Slot
105
- include ClassNameHelper
106
-
107
- attr_reader :system_arguments
108
-
109
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
110
- def initialize(**system_arguments)
111
- @system_arguments = system_arguments
112
- @system_arguments[:tag] = :div
113
- @system_arguments[:classes] = class_names(@system_arguments[:classes], "Subhead-description")
114
- end
115
- end
116
100
  end
117
101
  end