primer_view_components 0.0.13 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -0
  3. data/app/components/primer/base_component.rb +63 -15
  4. data/app/components/primer/blankslate_component.html.erb +4 -4
  5. data/app/components/primer/blankslate_component.rb +28 -2
  6. data/app/components/primer/border_box_component.rb +4 -0
  7. data/app/components/primer/box_component.rb +10 -0
  8. data/app/components/primer/breadcrumb_component.rb +2 -1
  9. data/app/components/primer/button_component.rb +1 -1
  10. data/app/components/primer/button_group_component.html.erb +5 -0
  11. data/app/components/primer/button_group_component.rb +34 -0
  12. data/app/components/primer/button_marketing_component.rb +73 -0
  13. data/app/components/primer/component.rb +14 -0
  14. data/app/components/primer/counter_component.rb +16 -12
  15. data/app/components/primer/details_component.rb +10 -6
  16. data/app/components/primer/dropdown_menu_component.rb +31 -3
  17. data/app/components/primer/flash_component.rb +2 -3
  18. data/app/components/primer/flex_component.rb +10 -9
  19. data/app/components/primer/flex_item_component.rb +2 -1
  20. data/app/components/primer/heading_component.rb +7 -0
  21. data/app/components/primer/label_component.rb +15 -9
  22. data/app/components/primer/link_component.rb +1 -1
  23. data/app/components/primer/octicon_component.rb +4 -3
  24. data/app/components/primer/popover_component.rb +3 -1
  25. data/app/components/primer/progress_bar_component.rb +5 -5
  26. data/app/components/primer/slot.rb +1 -0
  27. data/app/components/primer/spinner_component.rb +3 -4
  28. data/app/components/primer/state_component.rb +3 -3
  29. data/app/components/primer/subhead_component.rb +3 -0
  30. data/app/components/primer/timeline_item_component.rb +3 -0
  31. data/app/components/primer/tooltip_component.rb +88 -0
  32. data/app/components/primer/truncate_component.rb +41 -0
  33. data/app/components/primer/underline_nav_component.rb +26 -1
  34. data/app/components/primer/view_components.rb +5 -0
  35. data/lib/primer/class_name_helper.rb +1 -0
  36. data/lib/primer/classify.rb +129 -107
  37. data/lib/primer/fetch_or_fallback_helper.rb +9 -0
  38. data/lib/primer/join_style_arguments_helper.rb +14 -0
  39. data/lib/primer/view_components.rb +1 -0
  40. data/lib/primer/view_components/engine.rb +1 -0
  41. data/lib/primer/view_components/version.rb +1 -1
  42. metadata +42 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 055f773c8e99df5c9bce23d6a5199e71148d0331d6abe6c02fd1f16321a54130
4
- data.tar.gz: e5310f927e76533daa46918acb24b48ea7bdd684a8f8e4c9090e3545a2e7f3fd
3
+ metadata.gz: 3e5a191f5ef0c2e50f095bce5d68943ebdc38a28d0edd66334152e876045d9cd
4
+ data.tar.gz: 8a103a45a9fed84736298a7b75c45b5f2bff3e78817fd4b02100853dbdf9003e
5
5
  SHA512:
6
- metadata.gz: e6b7159b56e4a0674a7ec68e4aa0666bb2a3e3cb5ef7b90e8c418149200af1255789adc87e4b3955a9a2d6e97afb9ebe2746928ccb32ece3395c28de315206dc
7
- data.tar.gz: cc962a06f62249016eccfd224ab3655117ac193fa7f6ebb40aff91212690464047f95e2822bf4b5c8ae83d8c82df02e955f0c8ffc350e9aed85c313623388a61
6
+ metadata.gz: 467aa20851a1b48cb605984b87a76f0297e5eddd32cee077a8f3cc7a06639829bf6f4dbf79fa81c4aa18f3b6b9cf697867cc8b347a9547d408a7c2aefddd3886
7
+ data.tar.gz: 9ad2bd67f630a6e734d6b08da43cad5b94482d0ff93085e65f8e8a4ffcf36e150bc7e5ec3beaa542b54a7f9949ff6411da8c6a3db0df460c4e430b0471a03fda
data/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  ## main
4
4
 
5
+ ## 0.0.18
6
+
7
+ * Add `border_radius` system argument.
8
+
9
+ *Ash Guillaume*
10
+
11
+ * Add `animation` system argument.
12
+
13
+ *Manuel Puyol*
14
+
15
+ * Add `Truncate`, `ButtonGroup` and `ButtonMarketing` components.
16
+
17
+ *Manuel Puyol*
18
+
19
+ * Add `Tooltip` component.
20
+
21
+ *Simon Taranto*
22
+
23
+ ## 0.0.17
24
+
25
+ * Ensure all components support inline styles.
26
+
27
+ *Joel Hawksley*
28
+
29
+ ## 0.0.16
30
+
31
+ * Adding a `spinner` slot to the `BlankslateComponent` that uses the `SpinnerComponent` added in `0.0.10`.
32
+
33
+ *Jon Rohan*
34
+
35
+ * Bumping node engine to version `15.x`
36
+
37
+ *Jon Rohan*
38
+
39
+ ## 0.0.15
40
+
41
+ * Add ability to disable `limit` on Counter.
42
+
43
+ *Christian Giordano*
44
+
45
+ * Rename `v` system argument to `visibility`.
46
+
47
+ *Joel Hawksley*
48
+
49
+ ## 0.0.14
50
+
51
+ * Add functional colors to Label.
52
+
53
+ *Joel Hawksley*
54
+
5
55
  ## 0.0.13
6
56
 
7
57
  * Add support for `xl` breakpoint.
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # All Primer ViewComponents accept a standard set of options called System Arguments, mimicking the [styled-system API](https://styled-system.com/table) [used by Primer React](https://primer.style/components/system-props).
4
+ # All Primer ViewComponents accept a standard set of options called system arguments, mimicking the [styled-system API](https://styled-system.com/table) used by [Primer React](https://primer.style/components/system-props).
5
5
  #
6
- # Under the hood, System Arguments are [mapped](https://github.com/primer/view_components/blob/main/lib/primer/classify.rb) to Primer CSS classes, with any remaining options passed to Rails' [`content_tag`](https://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-content_tag).
6
+ # Under the hood, system arguments are [mapped](https://github.com/primer/view_components/blob/main/lib/primer/classify.rb) to Primer CSS classes, with any remaining options passed to Rails' [`content_tag`](https://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-content_tag).
7
7
  #
8
8
  # ## Responsive values
9
9
  #
@@ -23,9 +23,23 @@ module Primer
23
23
  # <h1 class="mt-0 mt-lg-4 mt-xl-2">Hello world</h1>
24
24
  # ```
25
25
  #
26
+ # ## HTML attributes
27
+ #
28
+ # System arguments include most HTML attributes. For example:
29
+ #
30
+ # | Name | Type | Description |
31
+ # | :- | :- | :- |
32
+ # | `width` | `Integer` | Width. |
33
+ # | `height` | `Integer` | Height. |
34
+ # | `data` | `Hash` | Data attributes: `data: { foo: :bar }` renders `data-foo='bar'`. |
35
+ # | `aria` | `Hash` | Aria attributes: `aria: { label: "foo" }` renders `aria-label='foo'`. |
36
+ # | `title` | `String` | The `title` attribute. |
37
+ # | `style` | `String` | Inline styles. |
38
+ # | `hidden` | `Boolean` | Whether to assign the `hidden` attribute. |
26
39
  class BaseComponent < Primer::Component
27
40
  TEST_SELECTOR_TAG = :test_selector
28
-
41
+ # @param test_selector [String] Adds `data-test-selector='given value'` in non-Production environments for testing purposes.
42
+ #
29
43
  # @param m [Integer] Margin. <%= one_of((-6..6).to_a) %>
30
44
  # @param mt [Integer] Margin left. <%= one_of((-6..6).to_a) %>
31
45
  # @param mr [Integer] Margin right. <%= one_of((-6..6).to_a) %>
@@ -33,13 +47,13 @@ module Primer
33
47
  # @param ml [Integer] Margin left. <%= one_of((-6..6).to_a) %>
34
48
  # @param mx [Integer] Horizontal margins. <%= one_of((-6..6).to_a + [:auto]) %>
35
49
  # @param my [Integer] Vertical margins. <%= one_of((-6..6).to_a) %>
36
- # @param m [Integer] Padding. <%= one_of((0..6).to_a) %>
37
- # @param mt [Integer] Padding left. <%= one_of((0..6).to_a) %>
38
- # @param mr [Integer] Padding right. <%= one_of((0..6).to_a) %>
39
- # @param mb [Integer] Padding bottom. <%= one_of((0..6).to_a) %>
40
- # @param ml [Integer] Padding left. <%= one_of((0..6).to_a) %>
41
- # @param mx [Integer] Horizontal padding. <%= one_of((0..6).to_a) %>
42
- # @param my [Integer] Vertical padding. <%= one_of((0..6).to_a) %>
50
+ # @param p [Integer] Padding. <%= one_of((0..6).to_a) %>
51
+ # @param pt [Integer] Padding left. <%= one_of((0..6).to_a) %>
52
+ # @param pr [Integer] Padding right. <%= one_of((0..6).to_a) %>
53
+ # @param pb [Integer] Padding bottom. <%= one_of((0..6).to_a) %>
54
+ # @param pl [Integer] Padding left. <%= one_of((0..6).to_a) %>
55
+ # @param px [Integer] Horizontal padding. <%= one_of((0..6).to_a) %>
56
+ # @param py [Integer] Vertical padding. <%= one_of((0..6).to_a) %>
43
57
  #
44
58
  # @param position [Symbol] <%= one_of([:relative, :absolute, :fixed]) %>
45
59
  #
@@ -48,7 +62,9 @@ module Primer
48
62
  # @param bottom [Boolean] If `false`, sets `bottom: 0`.
49
63
  # @param left [Boolean] If `false`, sets `left: 0`.
50
64
  #
51
- # @param display [Symbol] <%= one_of([:block, :none, :inline, :inline_block, :table, :table_cell]) %>
65
+ # @param display [Symbol] <%= one_of([:none, :block, :flex, :inline, :inline_block, :table, :table_cell]) %>
66
+ #
67
+ # @param v [Symbol] Visibility. <%= one_of([:hidden, :visible]) %>
52
68
  #
53
69
  # @param hide [Symbol] Hide the element at a specific breakpoint. <%= one_of([:sm, :md, :lg, :xl]) %>
54
70
  #
@@ -56,9 +72,41 @@ module Primer
56
72
  #
57
73
  # @param float [Symbol] <%= one_of([:left, :right]) %>
58
74
  #
59
- # @param font_size [String] <%= one_of(["00", "0", "1", "2", "3", "4", "5", "6"]) %>
60
- # @param tag [Symbol] HTML tag name to be passed to `tag.send`
61
- # @param classes [String] CSS class name value to be concatenated with generated Primer CSS classes
75
+ # @param col [Integer] Number of columns.
76
+ #
77
+ # @param underline [Boolean] Whether text should be underlined.
78
+ #
79
+ # @param color [Symbol] Text color. <%= one_of([:blue, :red, :gray_light, :gray, :gray_dark, :green, :orange, :orange_light, :purple, :pink, :white, :inherit]) %> Note: this API is subject to change as we move to functional colors.
80
+ # @param bg [String, Symbol] Background color. Accepts either a hex value as a String or a color name as a Symbol.
81
+ #
82
+ # @param box_shadow [Boolean, Symbol] Box shadow. <%= one_of([true, :medium, :large, :extra_large, :none]) %>
83
+ # @param border [Symbol] <%= one_of([:left, :top, :bottom, :right, :y, :x]) %>
84
+ # @param border_color [Symbol] <%= one_of([:blue, :blue_light, :gray, :gray_dark, :green, :purple, :red, :red_light, :white, :yellow, :black_fade]) %> Note: this API is subject to change as we move to functional colors.
85
+ # @param border_top [Integer] Set to `0` to remove the top border.
86
+ # @param border_bottom [Integer] Set to `0` to remove the bottom border.
87
+ # @param border_left [Integer] Set to `0` to remove the left border.
88
+ # @param border_right [Integer] Set to `0` to remove the right border.
89
+ # @param border_radius [Integer] <%= one_of([0, 1, 2, 3]) %>
90
+ #
91
+ # @param font_size [String, Integer] <%= one_of(["00", 0, 1, 2, 3, 4, 5, 6]) %>
92
+ # @param text_align [Symbol] Text alignment. <%= one_of([:left, :right, :center]) %>
93
+ # @param font_weight [Symbol] Font weight. <%= one_of([:light, :normal, :bold]) %>
94
+ #
95
+ # @param flex [Integer, Symbol] <%= one_of([1, :auto]) %>
96
+ # @param flex_grow [Integer] To enable, set to `0`.
97
+ # @param flex_shrink [Integer] To enable, set to `0`.
98
+ # @param align_self [Symbol] <%= one_of([:auto, :start, :end, :center, :baseline, :stretch]) %>
99
+ # @param justify_content [Symbol] <%= one_of([:flex_start, :flex_end, :center, :space_between, :space_around]) %>
100
+ # @param align_items [Symbol] <%= one_of([:flex_start, :flex_end, :center, :baseline, :stretch]) %>
101
+ # @param width [Symbol] <%= one_of([:fit, :fill]) %>
102
+ # @param height [Symbol] <%= one_of([:fit, :fill]) %>
103
+ #
104
+ # @param word_break [Symbol] Whether to break words on line breaks. Can only be `:break_all`.
105
+ #
106
+ # @param animation [Symbol] <%= one_of([:fade_in, :fade_out, :fade_up, :fade_down, :scale_in, :pulse, :grow_x, :grow]) %>
107
+ #
108
+ # @param tag [Symbol] HTML tag name to be passed to `tag.send`.
109
+ # @param classes [String] CSS class name value to be concatenated with generated Primer CSS classes.
62
110
  def initialize(tag:, classes: nil, **system_arguments)
63
111
  @tag = tag
64
112
  @result = Primer::Classify.call(**system_arguments.merge(classes: classes))
@@ -68,7 +116,7 @@ module Primer
68
116
  end
69
117
 
70
118
  def call
71
- content_tag(@tag, content, **@content_tag_args.merge(@result))
119
+ content_tag(@tag, content, { **@content_tag_args.merge(@result) })
72
120
  end
73
121
 
74
122
  private
@@ -1,13 +1,13 @@
1
1
  <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
- <% if @icon.present? %>
2
+ <% if spinner.present? %>
3
+ <%= render spinner.component %>
4
+ <% elsif @icon.present? %>
3
5
  <%= render(Primer::OcticonComponent.new(
4
6
  icon: @icon,
5
7
  size: @icon_size,
6
8
  classes: "blankslate-icon"
7
9
  )) %>
8
- <% end %>
9
-
10
- <% if @image_src.present? && @image_alt.present? %>
10
+ <% elsif @image_src.present? && @image_alt.present? %>
11
11
  <%= image_tag "#{@image_src}", class: "mb-3", size: "56x56", alt: "#{@image_alt}" %>
12
12
  <% end %>
13
13
 
@@ -3,6 +3,10 @@
3
3
  module Primer
4
4
  # Use Primer::BlankslateComponent when there is a lack of content within a page or section. Use as placeholder to tell users why something isn't there.
5
5
  class BlankslateComponent < Primer::Component
6
+ include ViewComponent::Slotable
7
+
8
+ with_slot :spinner, class_name: "Spinner"
9
+
6
10
  #
7
11
  # @example 150|Basic
8
12
  # <%= render Primer::BlankslateComponent.new(
@@ -17,6 +21,14 @@ module Primer
17
21
  # description: "Description",
18
22
  # ) %>
19
23
  #
24
+ # @example 220|Loading|Add a [SpinnerComponent](https://primer.style/view-components/components/spinner) to the blankslate in place of an icon.
25
+ # <%= render Primer::BlankslateComponent.new(
26
+ # title: "Title",
27
+ # description: "Description",
28
+ # ) do |component| %>
29
+ # <% component.slot(:spinner, size: :large) %>
30
+ # <% end %>
31
+ #
20
32
  # @example 150|Custom content|Pass custom content as a block in place of `description`.
21
33
  # <%= render Primer::BlankslateComponent.new(
22
34
  # title: "Title",
@@ -82,7 +94,7 @@ module Primer
82
94
  link_text: "",
83
95
  link_url: "",
84
96
 
85
- #variations
97
+ # variations
86
98
  narrow: false,
87
99
  large: false,
88
100
  spacious: false,
@@ -96,7 +108,7 @@ module Primer
96
108
  "blankslate",
97
109
  "blankslate-narrow": narrow,
98
110
  "blankslate-large": large,
99
- "blankslate-spacious": spacious,
111
+ "blankslate-spacious": spacious
100
112
  )
101
113
 
102
114
  @title_tag = title_tag
@@ -112,5 +124,19 @@ module Primer
112
124
  @link_text = link_text
113
125
  @link_url = link_url
114
126
  end
127
+
128
+ # :nodoc
129
+ class Spinner < Primer::Slot
130
+ # @param size [Symbol] <%= one_of(Primer::SpinnerComponent::SIZE_MAPPINGS) %>
131
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
132
+ def initialize(**system_arguments)
133
+ @system_arguments = system_arguments
134
+ @system_arguments[:mb] ||= 3
135
+ end
136
+
137
+ def component
138
+ Primer::SpinnerComponent.new(**@system_arguments)
139
+ end
140
+ end
115
141
  end
116
142
  end
@@ -34,6 +34,7 @@ module Primer
34
34
  rows.any? || header.present? || body.present? || footer.present?
35
35
  end
36
36
 
37
+ # :nodoc
37
38
  class Header < Primer::Slot
38
39
  attr_reader :system_arguments
39
40
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
@@ -47,6 +48,7 @@ module Primer
47
48
  end
48
49
  end
49
50
 
51
+ # :nodoc
50
52
  class Body < Primer::Slot
51
53
  attr_reader :system_arguments
52
54
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
@@ -60,6 +62,7 @@ module Primer
60
62
  end
61
63
  end
62
64
 
65
+ # :nodoc
63
66
  class Footer < Primer::Slot
64
67
  attr_reader :system_arguments
65
68
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
@@ -73,6 +76,7 @@ module Primer
73
76
  end
74
77
  end
75
78
 
79
+ # :nodoc
76
80
  class Row < Primer::Slot
77
81
  attr_reader :system_arguments
78
82
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
@@ -3,6 +3,12 @@
3
3
  module Primer
4
4
  # A basic wrapper component for most layout related needs.
5
5
  class BoxComponent < Primer::Component
6
+ # @example 20|Default
7
+ # <%= render(Primer::BoxComponent.new) { "Your content here" } %>
8
+ #
9
+ # @example 54|Color and padding
10
+ # <%= render(Primer::BoxComponent.new(bg: :gray, p: 3)) { "Hello world" } %>
11
+ #
6
12
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
7
13
  def initialize(**system_arguments)
8
14
  @system_arguments = system_arguments
@@ -12,5 +18,9 @@ module Primer
12
18
  def call
13
19
  render(Primer::BaseComponent.new(**@system_arguments)) { content }
14
20
  end
21
+
22
+ def self.status
23
+ Primer::Component::STATUSES[:stable]
24
+ end
15
25
  end
16
26
  end
@@ -33,7 +33,8 @@ module Primer
33
33
  # @param selected [Boolean] Whether or not the item is selected and not rendered as a link.
34
34
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
35
35
  def initialize(href: nil, selected: false, **system_arguments)
36
- @href, @system_arguments = href, system_arguments
36
+ @href = href
37
+ @system_arguments = system_arguments
37
38
 
38
39
  @href = nil if selected
39
40
  @system_arguments[:tag] = :li
@@ -16,7 +16,7 @@ module Primer
16
16
  VARIANT_MAPPINGS = {
17
17
  :small => "btn-sm",
18
18
  DEFAULT_VARIANT => "",
19
- :large => "btn-large",
19
+ :large => "btn-large"
20
20
  }.freeze
21
21
  VARIANT_OPTIONS = VARIANT_MAPPINGS.keys
22
22
 
@@ -0,0 +1,5 @@
1
+ <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
+ <% buttons.each do |button| %>
3
+ <%= button %>
4
+ <% end %>
5
+ <% end %>
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # Use ButtonGroupComponent to render a series of buttons.
5
+ class ButtonGroupComponent < Primer::Component
6
+ include ViewComponent::SlotableV2
7
+
8
+ renders_many :buttons, ->(**kwargs) { Primer::ButtonComponent.new(group_item: true, **kwargs) }
9
+
10
+ # @example 50|Default
11
+ # <%= render(Primer::ButtonGroupComponent.new) do |component|
12
+ # component.button { "Default" }
13
+ # component.button(button_type: :primary) { "Primary" }
14
+ # component.button(button_type: :danger) { "Danger" }
15
+ # component.button(button_type: :outline) { "Outline" }
16
+ # component.button(classes: "my-class") { "Custom class" }
17
+ # end %>
18
+ #
19
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
20
+ def initialize(**system_arguments)
21
+ @system_arguments = system_arguments
22
+ @system_arguments[:tag] ||= :div
23
+
24
+ @system_arguments[:classes] = class_names(
25
+ "BtnGroup",
26
+ system_arguments[:classes]
27
+ )
28
+ end
29
+
30
+ def render?
31
+ buttons.any?
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # Use buttons for actions (e.g. in forms). Use links for destinations, or moving from one page to another.
5
+ class ButtonMarketingComponent < Primer::Component
6
+ DEFAULT_BUTTON_TYPE = :default
7
+ BUTTON_TYPE_MAPPINGS = {
8
+ DEFAULT_BUTTON_TYPE => "",
9
+ :primary => "btn-primary-mktg",
10
+ :outline => "btn-outline-mktg",
11
+ :transparent => "btn-transparent"
12
+ }.freeze
13
+ BUTTON_TYPE_OPTIONS = BUTTON_TYPE_MAPPINGS.keys
14
+
15
+ DEFAULT_VARIANT = :default
16
+ VARIANT_MAPPINGS = {
17
+ DEFAULT_VARIANT => "",
18
+ :large => "btn-large-mktg"
19
+ }.freeze
20
+ VARIANT_OPTIONS = VARIANT_MAPPINGS.keys
21
+
22
+ DEFAULT_TAG = :button
23
+ TAG_OPTIONS = [DEFAULT_TAG, :a].freeze
24
+
25
+ DEFAULT_TYPE = :button
26
+ TYPE_OPTIONS = [DEFAULT_TYPE, :submit].freeze
27
+
28
+ # @example 125|Button types
29
+ # <%= render(Primer::ButtonMarketingComponent.new(mr: 2)) { "Default" } %>
30
+ # <%= render(Primer::ButtonMarketingComponent.new(button_type: :primary, mr: 2)) { "Primary" } %>
31
+ # <%= render(Primer::ButtonMarketingComponent.new(button_type: :outline)) { "Outline" } %>
32
+ # <div class="bg-gray-dark">
33
+ # <%= render(Primer::ButtonMarketingComponent.new(button_type: :transparent)) { "Transparent" } %>
34
+ # </div>
35
+ #
36
+ # @example 75|Sizes
37
+ # <%= render(Primer::ButtonMarketingComponent.new(mr: 2)) { "Default" } %>
38
+ # <%= render(Primer::ButtonMarketingComponent.new(variant: :large)) { "Large" } %>
39
+ #
40
+ # @param button_type [Symbol] <%= one_of(Primer::ButtonMarketingComponent::BUTTON_TYPE_OPTIONS) %>
41
+ # @param variant [Symbol] <%= one_of(Primer::ButtonMarketingComponent::VARIANT_OPTIONS) %>
42
+ # @param tag [Symbol] <%= one_of(Primer::ButtonMarketingComponent::TAG_OPTIONS) %>
43
+ # @param type [Symbol] <%= one_of(Primer::ButtonMarketingComponent::TYPE_OPTIONS) %>
44
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
45
+ def initialize(
46
+ button_type: DEFAULT_BUTTON_TYPE,
47
+ variant: DEFAULT_VARIANT,
48
+ tag: DEFAULT_TAG,
49
+ type: DEFAULT_TYPE,
50
+ **system_arguments
51
+ )
52
+ @system_arguments = system_arguments
53
+ @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
54
+
55
+ if @system_arguments[:tag] == :a
56
+ @system_arguments[:role] = :button
57
+ else
58
+ @system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE)
59
+ end
60
+
61
+ @system_arguments[:classes] = class_names(
62
+ "btn-mktg",
63
+ BUTTON_TYPE_MAPPINGS[fetch_or_fallback(BUTTON_TYPE_OPTIONS, button_type, DEFAULT_BUTTON_TYPE)],
64
+ VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)],
65
+ system_arguments[:classes]
66
+ )
67
+ end
68
+
69
+ def call
70
+ render(Primer::BaseComponent.new(**@system_arguments)) { content }
71
+ end
72
+ end
73
+ end