primer_view_components 0.0.14 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +82 -0
  3. data/app/components/primer/avatar_component.rb +24 -6
  4. data/app/components/primer/avatar_stack_component.html.erb +10 -0
  5. data/app/components/primer/avatar_stack_component.rb +81 -0
  6. data/app/components/primer/base_component.rb +63 -15
  7. data/app/components/primer/blankslate_component.html.erb +4 -4
  8. data/app/components/primer/blankslate_component.rb +34 -8
  9. data/app/components/primer/border_box_component.rb +29 -13
  10. data/app/components/primer/box_component.rb +10 -0
  11. data/app/components/primer/breadcrumb_component.rb +3 -2
  12. data/app/components/primer/button_component.rb +3 -3
  13. data/app/components/primer/button_group_component.html.erb +5 -0
  14. data/app/components/primer/button_group_component.rb +37 -0
  15. data/app/components/primer/button_marketing_component.rb +73 -0
  16. data/app/components/primer/component.rb +13 -0
  17. data/app/components/primer/counter_component.rb +21 -13
  18. data/app/components/primer/details_component.rb +10 -6
  19. data/app/components/primer/dropdown/menu_component.html.erb +12 -0
  20. data/app/components/primer/dropdown/menu_component.rb +48 -0
  21. data/app/components/primer/dropdown_component.html.erb +9 -0
  22. data/app/components/primer/dropdown_component.rb +77 -0
  23. data/app/components/primer/dropdown_menu_component.rb +35 -3
  24. data/app/components/primer/flash_component.rb +10 -7
  25. data/app/components/primer/flex_component.rb +47 -9
  26. data/app/components/primer/flex_item_component.rb +16 -1
  27. data/app/components/primer/heading_component.rb +7 -0
  28. data/app/components/primer/label_component.rb +6 -6
  29. data/app/components/primer/layout_component.rb +2 -2
  30. data/app/components/primer/link_component.rb +7 -3
  31. data/app/components/primer/markdown_component.rb +293 -0
  32. data/app/components/primer/menu_component.html.erb +6 -0
  33. data/app/components/primer/menu_component.rb +71 -0
  34. data/app/components/primer/octicon_component.rb +11 -6
  35. data/app/components/primer/popover_component.rb +6 -4
  36. data/app/components/primer/progress_bar_component.rb +9 -9
  37. data/app/components/primer/slot.rb +1 -0
  38. data/app/components/primer/spinner_component.rb +10 -7
  39. data/app/components/primer/state_component.rb +6 -6
  40. data/app/components/primer/subhead_component.rb +6 -3
  41. data/app/components/primer/text_component.rb +1 -1
  42. data/app/components/primer/timeline_item_component.rb +4 -1
  43. data/app/components/primer/tooltip_component.rb +88 -0
  44. data/app/components/primer/truncate_component.rb +41 -0
  45. data/app/components/primer/underline_nav_component.rb +26 -1
  46. data/app/components/primer/view_components.rb +9 -0
  47. data/lib/primer/class_name_helper.rb +1 -0
  48. data/lib/primer/classify.rb +141 -106
  49. data/lib/primer/classify/cache.rb +125 -0
  50. data/lib/primer/fetch_or_fallback_helper.rb +9 -0
  51. data/lib/primer/join_style_arguments_helper.rb +14 -0
  52. data/lib/primer/view_components.rb +32 -0
  53. data/lib/primer/view_components/engine.rb +1 -0
  54. data/lib/primer/view_components/version.rb +1 -1
  55. data/lib/yard/renders_many_handler.rb +19 -0
  56. data/lib/yard/renders_one_handler.rb +19 -0
  57. data/static/statuses.json +1 -0
  58. metadata +80 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cb2ccfdc2a705a1395c0b18dd535b305cf0b00ef77f778fe6bbc9b6417c3f4a
4
- data.tar.gz: fa2cea6523b0281502b65d654c11ab4224d345d25a3608a63e92f8680aaeb742
3
+ metadata.gz: 2123d6cd3a227f0cf3df93cc601098dc6e6b0b59ba98bbc589ccdd6a4c8b0b4f
4
+ data.tar.gz: b8b5075b18d79f10a385bb51b6f2d17d324a10fb3c5c5c961e841f96713a8c59
5
5
  SHA512:
6
- metadata.gz: c4506031b1c2e99c36aa9b868e210b15b396b8b38a8347e1b06785510e3caee7b6edb2e4fe0eafb178effa74cd2287e6e7d421d5c04394f5bead62cb0c3b9ffa
7
- data.tar.gz: 7e3a7b3a2ca8932cbdb563738d040b5ceb1239736ecf7603a3c9cdfa3cf3bc24aa9df3faa251568b9f8020a119bb75ed439a9881342e7e307b708a742fa42897
6
+ metadata.gz: b5ce375e1b8fa9d95cd784ea19565a6bfeb1024db7fdc5e010995f2a7085f5b03cfa163979c7b33648eacfd986b4339b1ca1bdba06e5ba581b8b20a006935d62
7
+ data.tar.gz: 0d6124a56d36eb09075d4be8bc50b8d1e061c2e9137c030733f6b875488f3f15e0939dd5692116e7f2d29cc7ac81ed6adc5f27cdb442e57ad44b8d456e5c60cc
data/CHANGELOG.md CHANGED
@@ -2,6 +2,88 @@
2
2
 
3
3
  ## main
4
4
 
5
+ ## 0.0.19
6
+
7
+ * Add support for functional colors to `color` system argument.
8
+
9
+ *Jake Shorty
10
+
11
+ * Add `AvatarStack`, `Dropdown`, `Markdown` and `Menu` components.
12
+
13
+ *Manuel Puyol*
14
+
15
+ * Deprecate `DropdownMenuComponent`.
16
+
17
+ *Manuel Puyol*
18
+
19
+ * Fix `Avatar` bug when used with links.
20
+
21
+ *Manuel Puyol*
22
+
23
+ * Add cache for common Primer values.
24
+
25
+ *Blake Williams*
26
+
27
+ * Add support for `octicons_helper` v12.
28
+
29
+ *Cole Bemis*
30
+
31
+ * Add support for `border: true` to apply the `border` class.
32
+
33
+ *Simon Taranto*
34
+
35
+ * Promote `Avatar`, `Link`, and `Counter` components to beta.
36
+
37
+ *Simon Taranto*
38
+
39
+ * **Breaking change**: Drop support for Ruby 2.4.
40
+
41
+ *Simon Taranto*
42
+
43
+ ## 0.0.18
44
+
45
+ * Add `border_radius` system argument.
46
+
47
+ *Ash Guillaume*
48
+
49
+ * Add `animation` system argument.
50
+
51
+ *Manuel Puyol*
52
+
53
+ * Add `Truncate`, `ButtonGroup` and `ButtonMarketing` components.
54
+
55
+ *Manuel Puyol*
56
+
57
+ * Add `Tooltip` component.
58
+
59
+ *Simon Taranto*
60
+
61
+ ## 0.0.17
62
+
63
+ * Ensure all components support inline styles.
64
+
65
+ *Joel Hawksley*
66
+
67
+ ## 0.0.16
68
+
69
+ * Adding a `spinner` slot to the `BlankslateComponent` that uses the `SpinnerComponent` added in `0.0.10`.
70
+
71
+ *Jon Rohan*
72
+
73
+ * Bumping node engine to version `15.x`
74
+
75
+ *Jon Rohan*
76
+
77
+ ## 0.0.15
78
+
79
+ * Add ability to disable `limit` on Counter.
80
+
81
+ *Christian Giordano*
82
+
83
+ * Rename `v` system argument to `visibility`.
84
+
85
+ *Joel Hawksley*
86
+
5
87
  ## 0.0.14
6
88
 
7
89
  * Add functional colors to Label.
@@ -7,15 +7,23 @@ module Primer
7
7
  class AvatarComponent < Primer::Component
8
8
  SMALL_THRESHOLD = 24
9
9
 
10
- #
11
- # @example 34|Default
10
+ # @example auto|Default
12
11
  # <%= render(Primer::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser")) %>
13
12
  #
13
+ # @example auto|Square
14
+ # <%= render(Primer::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", square: true)) %>
15
+ #
16
+ # @example auto|Link
17
+ # <%= render(Primer::AvatarComponent.new(href: "#", src: "http://placekitten.com/200/200", alt: "@kittenuser")) %>
18
+ #
14
19
  # @param src [String] The source url of the avatar image
15
20
  # @param alt [String] Passed through to alt on img tag
16
21
  # @param size [Integer] Adds the avatar-small class if less than 24
17
22
  # @param square [Boolean] Used to create a square avatar.
18
- def initialize(src:, alt:, size: 20, square: false, **system_arguments)
23
+ # @param href [String] The URL to link to. If used, component will be wrapped by an `<a>` tag
24
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
25
+ def initialize(src:, alt:, size: 20, square: false, href: nil, **system_arguments)
26
+ @href = href
19
27
  @system_arguments = system_arguments
20
28
  @system_arguments[:tag] = :img
21
29
  @system_arguments[:src] = src
@@ -25,15 +33,25 @@ module Primer
25
33
  @system_arguments[:width] = size
26
34
 
27
35
  @system_arguments[:classes] = class_names(
28
- "avatar",
29
36
  system_arguments[:classes],
37
+ "avatar" => !href,
30
38
  "avatar--small" => size < SMALL_THRESHOLD,
31
- "CircleBadge" => !square
39
+ "circle" => !square
32
40
  )
33
41
  end
34
42
 
35
43
  def call
36
- render(Primer::BaseComponent.new(**@system_arguments)) { content }
44
+ if @href
45
+ render(Primer::LinkComponent.new(href: @href, classes: "avatar")) do
46
+ render(Primer::BaseComponent.new(**@system_arguments)) { content }
47
+ end
48
+ else
49
+ render(Primer::BaseComponent.new(**@system_arguments)) { content }
50
+ end
51
+ end
52
+
53
+ def self.status
54
+ Primer::Component::STATUSES[:beta]
37
55
  end
38
56
  end
39
57
  end
@@ -0,0 +1,10 @@
1
+ <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
+ <%= render body_component do %>
3
+ <% avatars.each_with_index do |avatar, i| %>
4
+ <% if i == 2 %>
5
+ <div class="avatar avatar-more"></div>
6
+ <% end %>
7
+ <%= avatar %>
8
+ <% end %>
9
+ <% end %>
10
+ <% end %>
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # Use AvatarStack to stack multiple avatars together.
5
+ class AvatarStackComponent < Primer::Component
6
+ include ViewComponent::SlotableV2
7
+
8
+ ALIGN_DEFAULT = :left
9
+ ALIGN_OPTIONS = [ALIGN_DEFAULT, :right].freeze
10
+
11
+ # Required list of stacked avatars.
12
+ #
13
+ # @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::AvatarComponent) %>.
14
+ renders_many :avatars, Primer::AvatarComponent
15
+
16
+ # @example auto|Default
17
+ # <%= render(Primer::AvatarStackComponent.new) do |c| %>
18
+ # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
19
+ # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
20
+ # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
21
+ # <% end %>
22
+ #
23
+ # @example auto|Align right
24
+ # <%= render(Primer::AvatarStackComponent.new(align: :right)) do |c| %>
25
+ # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
26
+ # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
27
+ # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
28
+ # <% end %>
29
+ #
30
+ # @example auto|With tooltip
31
+ # <%= render(Primer::AvatarStackComponent.new(tooltipped: true, body_arguments: { label: 'This is a tooltip!' })) do |c| %>
32
+ # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
33
+ # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
34
+ # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
35
+ # <% end %>
36
+ #
37
+ # @param align [Symbol] <%= one_of(Primer::AvatarStackComponent::ALIGN_OPTIONS) %>
38
+ # @param tooltipped [Boolean] Whether to add a tooltip to the stack or not.
39
+ # @param body_arguments [Hash] Parameters to add to the Body. If `tooltipped` is set, has the same arguments as <%= link_to_component(Primer::TooltipComponent) %>.
40
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
41
+ def initialize(align: ALIGN_DEFAULT, tooltipped: false, body_arguments: {}, **system_arguments)
42
+ @align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
43
+ @system_arguments = system_arguments
44
+ @tooltipped = tooltipped
45
+ @body_arguments = body_arguments
46
+
47
+ @body_arguments[:tag] ||= :div
48
+ @body_arguments[:classes] = class_names(
49
+ "AvatarStack-body",
50
+ @body_arguments[:classes]
51
+ )
52
+
53
+ @system_arguments[:tag] ||= :div
54
+ @system_arguments[:classes] = class_names(
55
+ "AvatarStack",
56
+ system_arguments[:classes],
57
+ "AvatarStack--right" => @align == :right
58
+ )
59
+ end
60
+
61
+ def body_component
62
+ if @tooltipped
63
+ Primer::TooltipComponent.new(**@body_arguments)
64
+ else
65
+ Primer::BaseComponent.new(**@body_arguments)
66
+ end
67
+ end
68
+
69
+ def before_render
70
+ @system_arguments[:classes] = class_names(
71
+ @system_arguments[:classes],
72
+ "AvatarStack--two" => avatars.size == 2,
73
+ "AvatarStack--three-plus" => avatars.size > 2
74
+ )
75
+ end
76
+
77
+ def render?
78
+ avatars.any?
79
+ end
80
+ end
81
+ end
@@ -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, :text_primary, :text_secondary, :text_tertiary, :text_link, :text_success, :text_warning, :text_danger, :icon_primary, :icon_secondary, :icon_tertiary, :icon_info, :icon_success, :icon_warning, :icon_danger]) %>
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, true]) %>
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,28 +3,40 @@
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
- # @example 150|Basic
11
+ # @example auto|Basic
8
12
  # <%= render Primer::BlankslateComponent.new(
9
13
  # title: "Title",
10
14
  # description: "Description",
11
15
  # ) %>
12
16
  #
13
- # @example 190|Icon|Add an `icon` to give additional context. Refer to the [Octicons](https://primer.style/octicons/) documentation to choose an icon.
17
+ # @example auto|Icon|Add an `icon` to give additional context. Refer to the [Octicons](https://primer.style/octicons/) documentation to choose an icon.
14
18
  # <%= render Primer::BlankslateComponent.new(
15
19
  # icon: "octoface",
16
20
  # title: "Title",
17
21
  # description: "Description",
18
22
  # ) %>
19
23
  #
20
- # @example 150|Custom content|Pass custom content as a block in place of `description`.
24
+ # @example auto|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
+ #
32
+ # @example auto|Custom content|Pass custom content as a block in place of `description`.
21
33
  # <%= render Primer::BlankslateComponent.new(
22
34
  # title: "Title",
23
35
  # ) do %>
24
36
  # <em>Your custom content here</em>
25
37
  # <% end %>
26
38
  #
27
- # @example 270|Action button|Provide a button to guide users to take action from the blankslate. The button appears below the description and custom content.
39
+ # @example auto|Action button|Provide a button to guide users to take action from the blankslate. The button appears below the description and custom content.
28
40
  # <%= render Primer::BlankslateComponent.new(
29
41
  # icon: "book",
30
42
  # title: "Welcome to the mona wiki!",
@@ -34,7 +46,7 @@ module Primer
34
46
  # button_url: "https://github.com/monalisa/mona/wiki/_new",
35
47
  # ) %>
36
48
  #
37
- # @example 225|Link|Add an additional link to help users learn more about a feature. The link will be shown at the very bottom:
49
+ # @example auto|Link|Add an additional link to help users learn more about a feature. The link will be shown at the very bottom:
38
50
  # <%= render Primer::BlankslateComponent.new(
39
51
  # icon: "book",
40
52
  # title: "Welcome to the mona wiki!",
@@ -43,7 +55,7 @@ module Primer
43
55
  # link_url: "https://docs.github.com/en/github/building-a-strong-community/about-wikis",
44
56
  # ) %>
45
57
  #
46
- # @example 340|Variations|There are a few variations of how the Blankslate appears: `narrow` adds a maximum width, `large` increases the font size, and `spacious` adds extra padding.
58
+ # @example auto|Variations|There are a few variations of how the Blankslate appears: `narrow` adds a maximum width, `large` increases the font size, and `spacious` adds extra padding.
47
59
  # <%= render Primer::BlankslateComponent.new(
48
60
  # icon: "book",
49
61
  # title: "Welcome to the mona wiki!",
@@ -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