primer_view_components 0.0.38 → 0.0.43

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +283 -27
  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/components/primer/auto_complete.rb +4 -2
  6. data/app/components/primer/auto_complete/item.rb +1 -1
  7. data/app/components/primer/avatar_component.rb +22 -3
  8. data/app/components/primer/avatar_stack_component.rb +8 -5
  9. data/app/components/primer/base_button.rb +1 -1
  10. data/app/components/primer/base_component.rb +24 -13
  11. data/app/components/primer/blankslate_component.html.erb +1 -0
  12. data/app/components/primer/blankslate_component.rb +68 -47
  13. data/app/components/primer/border_box_component.rb +1 -1
  14. data/app/components/primer/box_component.rb +1 -1
  15. data/app/components/primer/breadcrumb_component.rb +1 -1
  16. data/app/components/primer/button_component.html.erb +9 -0
  17. data/app/components/primer/button_component.rb +39 -5
  18. data/app/components/primer/button_group.rb +3 -3
  19. data/app/components/primer/button_marketing_component.rb +1 -1
  20. data/app/components/primer/clipboard_copy.rb +1 -1
  21. data/app/components/primer/clipboard_copy_component.js +17 -8
  22. data/app/components/primer/clipboard_copy_component.ts +19 -8
  23. data/app/components/primer/close_button.rb +4 -2
  24. data/app/components/primer/component.rb +22 -3
  25. data/app/components/primer/counter_component.rb +6 -1
  26. data/app/components/primer/details_component.rb +1 -1
  27. data/app/components/primer/dropdown/menu_component.rb +1 -1
  28. data/app/components/primer/dropdown_component.rb +1 -1
  29. data/app/components/primer/flash_component.rb +3 -3
  30. data/app/components/primer/flex_component.rb +28 -1
  31. data/app/components/primer/flex_item_component.rb +20 -1
  32. data/app/components/primer/heading_component.rb +12 -19
  33. data/app/components/primer/hidden_text_expander.rb +4 -4
  34. data/app/components/primer/icon_button.rb +65 -0
  35. data/app/components/primer/image.rb +46 -0
  36. data/app/components/primer/image_crop.d.ts +1 -0
  37. data/app/components/primer/image_crop.html.erb +12 -0
  38. data/app/components/primer/image_crop.js +1 -0
  39. data/app/components/primer/image_crop.rb +36 -0
  40. data/app/components/primer/image_crop.ts +1 -0
  41. data/app/components/primer/label_component.rb +7 -3
  42. data/app/components/primer/layout_component.rb +1 -1
  43. data/app/components/primer/link_component.rb +1 -1
  44. data/app/components/primer/local_time.d.ts +1 -0
  45. data/app/components/primer/local_time.js +1 -0
  46. data/app/components/primer/local_time.rb +59 -0
  47. data/app/components/primer/local_time.ts +1 -0
  48. data/app/components/primer/{markdown_component.rb → markdown.rb} +12 -7
  49. data/app/components/primer/menu_component.rb +1 -1
  50. data/app/components/primer/navigation/tab_component.rb +8 -1
  51. data/app/components/primer/octicon_component.html.erb +7 -0
  52. data/app/components/primer/octicon_component.rb +53 -19
  53. data/app/components/primer/octicon_symbols_component.html.erb +3 -0
  54. data/app/components/primer/octicon_symbols_component.rb +61 -0
  55. data/app/components/primer/popover_component.rb +1 -1
  56. data/app/components/primer/primer.d.ts +2 -0
  57. data/app/components/primer/primer.js +2 -0
  58. data/app/components/primer/primer.ts +2 -0
  59. data/app/components/primer/progress_bar_component.rb +1 -1
  60. data/app/components/primer/spinner_component.rb +3 -3
  61. data/app/components/primer/state_component.rb +1 -1
  62. data/app/components/primer/subhead_component.rb +34 -4
  63. data/app/components/primer/tab_container_component.rb +1 -1
  64. data/app/components/primer/tab_nav_component.html.erb +5 -1
  65. data/app/components/primer/tab_nav_component.rb +63 -10
  66. data/app/components/primer/text_component.rb +6 -3
  67. data/app/components/primer/time_ago_component.rb +1 -1
  68. data/app/components/primer/timeline_item_component.rb +1 -1
  69. data/app/components/primer/{tooltip_component.rb → tooltip.rb} +11 -9
  70. data/app/components/primer/truncate.rb +7 -3
  71. data/app/components/primer/underline_nav_component.html.erb +1 -1
  72. data/app/components/primer/underline_nav_component.rb +18 -2
  73. data/app/lib/primer/classify.rb +27 -39
  74. data/app/lib/primer/classify/cache.rb +35 -15
  75. data/app/lib/primer/classify/flex.rb +111 -0
  76. data/app/lib/primer/classify/functional_border_colors.rb +1 -2
  77. data/app/lib/primer/classify/grid.rb +45 -0
  78. data/app/lib/primer/fetch_or_fallback_helper.rb +2 -2
  79. data/app/lib/primer/octicon/cache.rb +42 -0
  80. data/app/lib/primer/tabbed_component_helper.rb +2 -2
  81. data/app/lib/primer/view_helper.rb +2 -1
  82. data/lib/primer/view_components.rb +1 -1
  83. data/lib/primer/view_components/engine.rb +2 -0
  84. data/lib/primer/view_components/linters.rb +3 -0
  85. data/lib/primer/view_components/linters/button_component_migration_counter.rb +16 -0
  86. data/lib/primer/view_components/linters/flash_component_migration_counter.rb +16 -0
  87. data/lib/primer/view_components/linters/helpers.rb +89 -0
  88. data/lib/primer/view_components/version.rb +1 -1
  89. data/lib/tasks/coverage.rake +14 -0
  90. data/lib/tasks/docs.rake +372 -0
  91. data/lib/tasks/statuses.rake +12 -0
  92. data/lib/yard/docs_helper.rb +57 -0
  93. data/static/statuses.json +54 -1
  94. metadata +62 -11
  95. data/app/components/primer/button_component.rb.orig +0 -138
  96. data/app/components/primer/foo_bar.d.ts +0 -1
  97. data/app/components/primer/foo_bar.js +0 -1
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use popovers to bring attention to specific user interface elements, typically to suggest an action or to guide users through a new experience.
4
+ # Use `Popover` to bring attention to specific user interface elements, typically to suggest an action or to guide users through a new experience.
5
5
  #
6
6
  # By default, the popover renders with absolute positioning, meaning it should usually be wrapped in an element with a relative position in order to be positioned properly. To render the popover with relative positioning, use the relative property.
7
7
  class PopoverComponent < Primer::Component
@@ -2,3 +2,5 @@ import './auto_complete/auto_complete';
2
2
  import './clipboard_copy_component';
3
3
  import './tab_container_component';
4
4
  import './time_ago_component';
5
+ import './local_time';
6
+ import './image_crop';
@@ -2,3 +2,5 @@ import './auto_complete/auto_complete';
2
2
  import './clipboard_copy_component';
3
3
  import './tab_container_component';
4
4
  import './time_ago_component';
5
+ import './local_time';
6
+ import './image_crop';
@@ -2,3 +2,5 @@ import './auto_complete/auto_complete'
2
2
  import './clipboard_copy_component'
3
3
  import './tab_container_component'
4
4
  import './time_ago_component'
5
+ import './local_time'
6
+ import './image_crop'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use ProgressBar to visualize task completion.
4
+ # Use `ProgressBar` to visualize task completion.
5
5
  class ProgressBarComponent < Primer::Component
6
6
  status :beta
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use Primer::SpinnerComponent to let users know that content is being loaded.
4
+ # Use `Spinner` to let users know that content is being loaded.
5
5
  class SpinnerComponent < Primer::Component
6
6
  status :beta
7
7
 
@@ -27,10 +27,10 @@ module Primer
27
27
  # <%= render(Primer::SpinnerComponent.new(size: :large)) %>
28
28
  #
29
29
  # @param size [Symbol] <%= one_of(Primer::SpinnerComponent::SIZE_MAPPINGS) %>
30
- def initialize(size: DEFAULT_SIZE, **system_arguments)
30
+ def initialize(size: DEFAULT_SIZE, style: DEFAULT_STYLE, **system_arguments)
31
31
  @system_arguments = system_arguments
32
32
  @system_arguments[:tag] = :svg
33
- @system_arguments[:style] ||= DEFAULT_STYLE
33
+ @system_arguments[:style] ||= style
34
34
  @system_arguments[:animation] = :rotate
35
35
  @system_arguments[:width] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
36
36
  @system_arguments[:height] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Component for rendering the status of an item.
4
+ # Use `State` for rendering the status of an item.
5
5
  class StateComponent < Primer::Component
6
6
  status :beta
7
7
 
@@ -1,16 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use the Subhead component for page headings.
4
+ # Use `Subhead` as the start of a section. The `:heading` slot will render an `<h2>` font-sized text.
5
+ #
6
+ # - Optionally set the `:description` slot to render a short description and the `:actions` slot for a related action.
7
+ # - Use a succint, one-line description for the `:description` slot. For longer descriptions, omit the description slot and render a paragraph below the `Subhead`.
8
+ # - Use the actions slot to render a related action to the right of the heading. Use <%= link_to_component(Primer::ButtonComponent) %> or <%= link_to_component(Primer::LinkComponent) %>.
9
+ #
10
+ # @accessibility
11
+ # The `:heading` slot defaults to rendering a `<div>`. Update the tag to a heading element with the appropriate level to improve page navigation for assistive technologies.
12
+ # <%= link_to_heading_practices %>
5
13
  class SubheadComponent < Primer::Component
6
14
  status :beta
7
15
 
16
+ DEFAULT_HEADING_TAG = :div
17
+ HEADING_TAG_OPTIONS = [DEFAULT_HEADING_TAG, :h1, :h2, :h3, :h4, :h5, :h6].freeze
18
+
8
19
  # The heading
9
20
  #
21
+ # @param tag [Symbol] <%= one_of(Primer::SubheadComponent::HEADING_TAG_OPTIONS)%>
10
22
  # @param danger [Boolean] Whether to style the heading as dangerous.
11
23
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
12
- renders_one :heading, lambda { |danger: false, **system_arguments|
13
- system_arguments[:tag] ||= :div
24
+ renders_one :heading, lambda { |tag: DEFAULT_HEADING_TAG, danger: false, **system_arguments|
25
+ system_arguments[:tag] = fetch_or_fallback(HEADING_TAG_OPTIONS, tag, DEFAULT_HEADING_TAG)
14
26
  system_arguments[:classes] = class_names(
15
27
  system_arguments[:classes],
16
28
  "Subhead-heading",
@@ -42,7 +54,7 @@ module Primer
42
54
 
43
55
  # @example Default
44
56
  # <%= render(Primer::SubheadComponent.new) do |component| %>
45
- # <% component.heading do %>
57
+ # <% component.heading(tag: :h3) do %>
46
58
  # My Heading
47
59
  # <% end %>
48
60
  # <% component.description do %>
@@ -50,6 +62,24 @@ module Primer
50
62
  # <% end %>
51
63
  # <% end %>
52
64
  #
65
+ # @example With dangerous heading
66
+ # <%= render(Primer::SubheadComponent.new) do |component| %>
67
+ # <% component.heading(tag: :h3, danger: true) do %>
68
+ # My Heading
69
+ # <% end %>
70
+ # <% component.description do %>
71
+ # My Description
72
+ # <% end %>
73
+ # <% end %>
74
+ #
75
+ # @example With long description
76
+ # <%= render(Primer::SubheadComponent.new) do |component| %>
77
+ # <% component.heading(tag: :h3) do %>
78
+ # My Heading
79
+ # <% end %>
80
+ # <% end %>
81
+ # <p> This is a longer description that is sitting below the Subhead. It's much longer than a description that could sit comfortably in the Subhead. </p>
82
+ #
53
83
  # @example Without border
54
84
  # <%= render(Primer::SubheadComponent.new(hide_border: true)) do |component| %>
55
85
  # <% component.heading do %>
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use TabContainer to create tabbed content with keyboard support. This component does not add any styles.
4
+ # Use `TabContainer` to create tabbed content with keyboard support. This component does not add any styles.
5
5
  # It only provides the tab functionality. If you want styled Tabs you can look at <%= link_to_component(Primer::TabNavComponent) %>.
6
6
  #
7
7
  # This component requires javascript.
@@ -1,10 +1,14 @@
1
- <%= wrapper do %>
1
+ <%= wrapper(**@wrapper_arguments) do %>
2
2
  <%= render Primer::BaseComponent.new(**@system_arguments) do %>
3
+ <%= extra if @align == :left %>
4
+
3
5
  <%= render Primer::BaseComponent.new(**@body_arguments) do %>
4
6
  <% tabs.each do |tab| %>
5
7
  <%= tab %>
6
8
  <% end %>
7
9
  <% end %>
10
+
11
+ <%= extra if @align == :right %>
8
12
  <% end %>
9
13
 
10
14
  <% if @with_panel %>
@@ -1,10 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use TabNav to style navigation with a tab-based selected state, typically used for navigation placed at the top of the page.
4
+ # Use `TabNav` to style navigation with a tab-based selected state, typically used for navigation placed at the top of the page.
5
5
  class TabNavComponent < Primer::Component
6
6
  include Primer::TabbedComponentHelper
7
7
 
8
+ status :beta
9
+
10
+ DEFAULT_EXTRA_ALIGN = :left
11
+ EXTRA_ALIGN_OPTIONS = [DEFAULT_EXTRA_ALIGN, :right].freeze
12
+
8
13
  # Tabs to be rendered. For more information, refer to <%= link_to_component(Primer::Navigation::TabComponent) %>.
9
14
  #
10
15
  # @param selected [Boolean] Whether the tab is selected.
@@ -22,6 +27,15 @@ module Primer
22
27
  )
23
28
  }
24
29
 
30
+ # Renders extra content to the `TabNav`. This will be rendered after the tabs.
31
+ #
32
+ # @param align [Symbol] <%= one_of(Primer::TabNavComponent::EXTRA_ALIGN_OPTIONS) %>
33
+ renders_one :extra, lambda { |align: DEFAULT_EXTRA_ALIGN, &block|
34
+ @align = fetch_or_fallback(EXTRA_ALIGN_OPTIONS, align, DEFAULT_EXTRA_ALIGN)
35
+
36
+ view_context.capture { block&.call }
37
+ }
38
+
25
39
  # @example Default
26
40
  # <%= render(Primer::TabNavComponent.new(label: "Default")) do |c| %>
27
41
  # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
@@ -68,12 +82,53 @@ module Primer
68
82
  # <% end %>
69
83
  # <% end %>
70
84
  #
85
+ # @example With extra content
86
+ # <%= render(Primer::TabNavComponent.new(label: "With extra content")) do |c| %>
87
+ # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
88
+ # <% c.tab(href: "#") { "Tab 2" } %>
89
+ # <% c.tab(href: "#") { "Tab 3" } %>
90
+ # <% c.extra do %>
91
+ # <%= render(Primer::ButtonComponent.new(float: :right)) { "Button" } %>
92
+ # <% end %>
93
+ # <% end %>
94
+ #
95
+ # @example Adding extra content after the tabs
96
+ # <%= render(Primer::TabNavComponent.new(label: "Adding extra content after the tabs", display: :flex, body_arguments: { flex: 1 })) do |c| %>
97
+ # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
98
+ # <% c.tab(href: "#") { "Tab 2" } %>
99
+ # <% c.tab(href: "#") { "Tab 3" } %>
100
+ # <% c.extra(align: :right) do %>
101
+ # <div>
102
+ # <%= render(Primer::ButtonComponent.new) { "Button" } %>
103
+ # </div>
104
+ # <% end %>
105
+ # <% end %>
106
+ #
107
+ # @example Customizing the body
108
+ # <%= render(Primer::TabNavComponent.new(label: "Default", body_arguments: { classes: "custom-class", border: true, border_color: :info })) do |c| %>
109
+ # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
110
+ # <% c.tab(href: "#") { "Tab 2" } %>
111
+ # <% c.tab(href: "#") { "Tab 3" } %>
112
+ # <% end %>
113
+ #
114
+ # @example Customizing the wrapper
115
+ # <%= render(Primer::TabNavComponent.new(label: "Default", wrapper_arguments: { classes: "custom-class", border: true, border_color: :info })) do |c| %>
116
+ # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
117
+ # <% c.tab(href: "#") { "Tab 2" } %>
118
+ # <% c.tab(href: "#") { "Tab 3" } %>
119
+ # <% end %>
120
+ #
71
121
  # @param label [String] Used to set the `aria-label` on the top level `<nav>` element.
72
122
  # @param with_panel [Boolean] Whether the TabNav should navigate through pages or panels.
123
+ # @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
124
+ # @param wrapper_arguments [Hash] <%= link_to_system_arguments_docs %> for the `TabContainer` wrapper. Only applies if `with_panel` is `true`.
73
125
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
74
- def initialize(label:, with_panel: false, **system_arguments)
126
+ def initialize(label:, with_panel: false, body_arguments: {}, wrapper_arguments: {}, **system_arguments)
127
+ @align = DEFAULT_EXTRA_ALIGN
75
128
  @with_panel = with_panel
76
129
  @system_arguments = system_arguments
130
+ @body_arguments = body_arguments
131
+ @wrapper_arguments = wrapper_arguments
77
132
 
78
133
  @system_arguments[:tag] ||= :div
79
134
  @system_arguments[:classes] = class_names(
@@ -81,15 +136,13 @@ module Primer
81
136
  system_arguments[:classes]
82
137
  )
83
138
 
84
- @body_arguments = {
85
- tag: navigation_tag(with_panel),
86
- classes: "tabnav-tabs",
87
- aria: {
88
- label: label
89
- }
90
- }
91
-
139
+ @body_arguments[:tag] = navigation_tag(with_panel)
140
+ @body_arguments[:"aria-label"] = label
92
141
  @body_arguments[:role] = :tablist if @with_panel
142
+ @body_arguments[:classes] = class_names(
143
+ "tabnav-tabs",
144
+ body_arguments[:classes]
145
+ )
93
146
  end
94
147
  end
95
148
  end
@@ -1,18 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # The Text component is a wrapper component that will apply typography styles to the text inside.
4
+ # `Text` is a wrapper component that will apply typography styles to the text inside.
5
5
  class TextComponent < Primer::Component
6
6
  status :beta
7
7
 
8
+ DEFAULT_TAG = :span
9
+
8
10
  # @example Default
9
11
  # <%= render(Primer::TextComponent.new(tag: :p, font_weight: :bold)) { "Bold Text" } %>
10
12
  # <%= render(Primer::TextComponent.new(tag: :p, color: :text_danger)) { "Danger Text" } %>
11
13
  #
14
+ # @param tag [Symbol]
12
15
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
13
- def initialize(**system_arguments)
16
+ def initialize(tag: DEFAULT_TAG, **system_arguments)
14
17
  @system_arguments = system_arguments
15
- @system_arguments[:tag] ||= :span
18
+ @system_arguments[:tag] = tag
16
19
  end
17
20
 
18
21
  def call
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use Primer::TimeAgoComponent to display a time relative to how long ago it was. This component requires JavaScript.
4
+ # Use `TimeAgo` to display a time relative to how long ago it was. This component requires JavaScript.
5
5
  class TimeAgoComponent < Primer::Component
6
6
  status :beta
7
7
 
@@ -19,7 +19,7 @@ module Primer
19
19
 
20
20
  # Badge that will be connected to other TimelineItems.
21
21
  #
22
- # @param icon [String] Name of [Octicon](https://primer.style/octicons/) to use.
22
+ # @param icon [String] Name of <%= link_to_octicons %> to use.
23
23
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
24
24
  renders_one :badge, "BadgeComponent"
25
25
 
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # The Tooltip component is a wrapper component that will apply a tooltip to the provided content.
5
- class TooltipComponent < Primer::Component
4
+ # `Tooltip` is a wrapper component that will apply a tooltip to the provided content.
5
+ class Tooltip < Primer::Component
6
+ status :beta
7
+
6
8
  DIRECTION_DEFAULT = :n
7
9
  ALIGN_DEFAULT = :default
8
10
  MULTILINE_DEFAULT = false
@@ -28,34 +30,34 @@ module Primer
28
30
 
29
31
  # @example Default
30
32
  # <div class="pt-5">
31
- # <%= render(Primer::TooltipComponent.new(label: "Even bolder")) { "Default Bold Text" } %>
33
+ # <%= render(Primer::Tooltip.new(label: "Even bolder")) { "Default Bold Text" } %>
32
34
  # </div>
33
35
  #
34
36
  # @example Wrapping another component
35
37
  # <div class="pt-5">
36
- # <%= render(Primer::TooltipComponent.new(label: "Even bolder")) do %>
38
+ # <%= render(Primer::Tooltip.new(label: "Even bolder")) do %>
37
39
  # <%= render(Primer::ButtonComponent.new) { "Bold Button" } %>
38
40
  # <% end %>
39
41
  # </div>
40
42
  #
41
43
  # @example With a direction
42
44
  # <div class="pt-5">
43
- # <%= render(Primer::TooltipComponent.new(label: "Even bolder", direction: :s)) { "Bold Text With a Direction" } %>
45
+ # <%= render(Primer::Tooltip.new(label: "Even bolder", direction: :s)) { "Bold Text With a Direction" } %>
44
46
  # </div>
45
47
  #
46
48
  # @example With an alignment
47
49
  # <div class="pt-5">
48
- # <%= render(Primer::TooltipComponent.new(label: "Even bolder", direction: :s, alignment: :right_1)) { "Bold Text With an Alignment" } %>
50
+ # <%= render(Primer::Tooltip.new(label: "Even bolder", direction: :s, alignment: :right_1)) { "Bold Text With an Alignment" } %>
49
51
  # </div>
50
52
  #
51
53
  # @example Without a delay
52
54
  # <div class="pt-5">
53
- # <%= render(Primer::TooltipComponent.new(label: "Even bolder", direction: :s, no_delay: true)) { "Bold Text without a delay" } %>
55
+ # <%= render(Primer::Tooltip.new(label: "Even bolder", direction: :s, no_delay: true)) { "Bold Text without a delay" } %>
54
56
  # </div>
55
57
  #
56
58
  # @param label [String] the text to appear in the tooltip
57
- # @param direction [String] Direction of the tooltip. <%= one_of(Primer::TooltipComponent::DIRECTION_OPTIONS) %>
58
- # @param align [String] Align tooltips to the left or right of an element, combined with a `direction` to specify north or south. <%= one_of(Primer::TooltipComponent::ALIGN_MAPPING.keys) %>
59
+ # @param direction [String] Direction of the tooltip. <%= one_of(Primer::Tooltip::DIRECTION_OPTIONS) %>
60
+ # @param align [String] Align tooltips to the left or right of an element, combined with a `direction` to specify north or south. <%= one_of(Primer::Tooltip::ALIGN_MAPPING.keys) %>
59
61
  # @param multiline [Boolean] Use this when you have long content
60
62
  # @param no_delay [Boolean] By default the tooltips have a slight delay before appearing. Set true to override this
61
63
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use Truncate to shorten overflowing text with an ellipsis.
4
+ # Use `Truncate` to shorten overflowing text with an ellipsis.
5
5
  class Truncate < Primer::Component
6
6
  status :beta
7
7
 
8
+ DEFAULT_TAG = :div
9
+ TAG_OPTIONS = [DEFAULT_TAG, :span, :p].freeze
10
+
8
11
  # @example Default
9
12
  # <div class="col-2">
10
13
  # <%= render(Primer::Truncate.new(tag: :p)) { "branch-name-that-is-really-long" } %>
@@ -19,13 +22,14 @@ module Primer
19
22
  # @example Custom size
20
23
  # <%= render(Primer::Truncate.new(tag: :span, inline: true, expandable: true, max_width: 100)) { "branch-name-that-is-really-long" } %>
21
24
  #
25
+ # @param tag [Symbol] <%= one_of(Primer::Truncate::TAG_OPTIONS) %>
22
26
  # @param inline [Boolean] Whether the element is inline (or inline-block).
23
27
  # @param expandable [Boolean] Whether the entire string should be revealed on hover. Can only be used in conjunction with `inline`.
24
28
  # @param max_width [Integer] Sets the max-width of the text.
25
29
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
26
- def initialize(inline: false, expandable: false, max_width: nil, **system_arguments)
30
+ def initialize(tag: DEFAULT_TAG, inline: false, expandable: false, max_width: nil, **system_arguments)
27
31
  @system_arguments = system_arguments
28
- @system_arguments[:tag] ||= :div
32
+ @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
29
33
  @system_arguments[:classes] = class_names(
30
34
  @system_arguments[:classes],
31
35
  "css-truncate",
@@ -1,4 +1,4 @@
1
- <%= wrapper do %>
1
+ <%= wrapper(**@wrapper_arguments) do %>
2
2
  <%= render Primer::BaseComponent.new(**@system_arguments) do %>
3
3
  <% if @align == :right %>
4
4
  <%= actions %>
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use the UnderlineNav component to style navigation with a minimal
4
+ # Use `UnderlineNav` to style navigation with a minimal
5
5
  # underlined selected state, typically used for navigation placed at the top
6
6
  # of the page.
7
7
  class UnderlineNavComponent < Primer::Component
@@ -116,14 +116,30 @@ module Primer
116
116
  # <% end %>
117
117
  # <% end %>
118
118
  #
119
+ # @example Customizing the body
120
+ # <%= render(Primer::UnderlineNavComponent.new(label: "Default", body_arguments: { tag: :ul, classes: "custom-class", border: true, border_color: :info })) do |c| %>
121
+ # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
122
+ # <% c.tab(href: "#") { "Tab 2" } %>
123
+ # <% c.tab(href: "#") { "Tab 3" } %>
124
+ # <% end %>
125
+ #
126
+ # @example Customizing the wrapper
127
+ # <%= render(Primer::UnderlineNavComponent.new(label: "Default", wrapper_arguments: { classes: "custom-class", border: true, border_color: :info })) do |c| %>
128
+ # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
129
+ # <% c.tab(href: "#") { "Tab 2" } %>
130
+ # <% c.tab(href: "#") { "Tab 3" } %>
131
+ # <% end %>
132
+ #
119
133
  # @param label [String] The `aria-label` on top level `<nav>` element.
120
134
  # @param with_panel [Boolean] Whether the TabNav should navigate through pages or panels.
121
135
  # @param align [Symbol] <%= one_of(Primer::UnderlineNavComponent::ALIGN_OPTIONS) %> - Defaults to <%= Primer::UnderlineNavComponent::ALIGN_DEFAULT %>
122
136
  # @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
137
+ # @param wrapper_arguments [Hash] <%= link_to_system_arguments_docs %> for the `TabContainer` wrapper. Only applies if `with_panel` is `true`.
123
138
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
124
- def initialize(label:, with_panel: false, align: ALIGN_DEFAULT, body_arguments: { tag: BODY_TAG_DEFAULT }, **system_arguments)
139
+ def initialize(label:, with_panel: false, align: ALIGN_DEFAULT, body_arguments: { tag: BODY_TAG_DEFAULT }, wrapper_arguments: {}, **system_arguments)
125
140
  @with_panel = with_panel
126
141
  @align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
142
+ @wrapper_arguments = wrapper_arguments
127
143
 
128
144
  @system_arguments = system_arguments
129
145
  @system_arguments[:tag] = navigation_tag(with_panel)