primer_view_components 0.0.21 → 0.0.26

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +77 -0
  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 +3 -3
  6. data/app/components/primer/avatar_stack_component.rb +3 -3
  7. data/app/components/primer/base_component.rb +6 -2
  8. data/app/components/primer/blankslate_component.html.erb +2 -2
  9. data/app/components/primer/blankslate_component.rb +11 -7
  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 +21 -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 +2 -2
  26. data/app/components/primer/flash_component.rb +5 -5
  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 +22 -26
  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 +47 -59
  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.rb +1 -1
  52. data/app/components/primer/tooltip_component.rb +5 -5
  53. data/app/components/primer/truncate_component.rb +4 -4
  54. data/app/components/primer/underline_nav_component.rb +2 -2
  55. data/{lib → app/lib}/primer/class_name_helper.rb +0 -0
  56. data/{lib → app/lib}/primer/classify.rb +0 -2
  57. data/{lib → app/lib}/primer/classify/cache.rb +0 -0
  58. data/{lib → app/lib}/primer/fetch_or_fallback_helper.rb +0 -0
  59. data/{lib → app/lib}/primer/join_style_arguments_helper.rb +0 -0
  60. data/app/lib/primer/view_helper.rb +22 -0
  61. data/app/lib/primer/view_helper/dsl.rb +34 -0
  62. data/lib/primer/view_components/engine.rb +10 -2
  63. data/lib/primer/view_components/version.rb +5 -1
  64. data/static/statuses.json +1 -1
  65. metadata +18 -8
  66. data/app/components/primer/view_components.rb +0 -60
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62c2e7e2e043daf8288aa72a91d674af96180cc0430c8d59c5fdbf5764e19b59
4
- data.tar.gz: 75b205867ce0f2835ee32d9a859032d02eef6dbb98b8ff5c9d485001893fce5b
3
+ metadata.gz: ca8de029e2997291254306cb0a863803d46ea5125225e9bf43a313e77b547928
4
+ data.tar.gz: 0c37752e22a84e032203680b747c80a7dc6322a8f91e700ddab846682bd393c1
5
5
  SHA512:
6
- metadata.gz: f6ad3831ccbb77616d668036954108e3642ffe747ee2837714761ebc54ca353b654813cad3396bb31e4a94f03f6e84f5ae52c75cf07387fffd24758d73967b70
7
- data.tar.gz: 79d4aca35c8556fcbbcbab8fb6cf5d4e5440f920508af5ed880bb200a03820869a576ebafd3200ff756a3b7a580855c8b1c77ba71a65f085367fc80ac063e49f
6
+ metadata.gz: 27e23b261419d94f99ccd6af30e750b63ecdeccb24802a3a49e7b4876846a1674aeff192497ffc3ff6b4b8e8a78727a7b1922d02b1c1d78f07989df2d9759d8f
7
+ data.tar.gz: a106bdae510f0dae72183a7893dbabec0560fe30d8a28dc5250de3293bda8e7efc11c0e26506721c4272c59de0ac62ca911ab1e6b89a2b2c70d5e9a92bb2f23e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,83 @@
2
2
 
3
3
  ## main
4
4
 
5
+ ## 0.0.26
6
+
7
+ * Fix `DetailsComponent` summary always being rendered as a `btn`.
8
+
9
+ *Manuel Puyol*
10
+
11
+ * Promote `BlankslateComponent` and `BaseComponent` to beta status.
12
+
13
+ *Simon Taranto*
14
+
15
+ ## 0.0.25
16
+
17
+ * Promote `SubheadComponent` to beta.
18
+
19
+ *Simon Taranto*
20
+
21
+ * Add deprecated `orange` and `purple` schemes to `LabelComponent`.
22
+
23
+ *Manuel Puyol*
24
+
25
+ ## 0.0.24
26
+
27
+ * Fix zeitwerk autoload integration.
28
+
29
+ *Manuel Puyol*
30
+
31
+ * **Breaking change**: Upgrade `ProgressBarComponent` to use Slots V2.
32
+
33
+ *Simon Taranto*
34
+
35
+ * **Breaking change**: Upgrade `BreadcrumbComponent` to use Slots V2.
36
+
37
+ *Manuel Puyol*
38
+
39
+ ## 0.0.23
40
+
41
+ * Remove node and yarn version requirements from `@primer/view-components`.
42
+
43
+ *Manuel Puyol*
44
+
45
+ * **Breaking change**: Upgrade `SubheadComponent` to use Slots V2.
46
+
47
+ *Simon Taranto*
48
+
49
+ * **Breaking change**: Update `LabelComponent` to use only functional color
50
+ supportive scheme keys. The component no longer accepts colors (`:gray`, for
51
+ example) but only functional schemes (`primary`, for example).
52
+ `LabelComponent` is promoted to beta status.
53
+
54
+ *Simon Taranto*
55
+
56
+ ## 0.0.22
57
+
58
+ * Add view helpers to easily render Primer components.
59
+
60
+ *Manuel Puyol*
61
+
62
+ * Add `TabContainer` and `TabNav` components.
63
+
64
+ *Manuel Puyol*
65
+
66
+ * Promote `StateComponent` to beta.
67
+
68
+ *Simon Taranto*
69
+
70
+ * **Breaking change**: Upgrade `BorderBoxComponent` to use Slots V2.
71
+
72
+ *Manuel Puyol*
73
+
74
+ * **Breaking change**: Upgrade `StateComponent` to support functional colors. This change requires using [@primer/css-next](https://www.npmjs.com/package/@primer/css-next). The required changes will be upstreamed to @primer/css at a later date.
75
+
76
+ *Simon Taranto*
77
+
78
+ * **Breaking change**: Upgrade `DetailsComponent` to use Slots V2.
79
+
80
+ *Simon Taranto*
81
+
5
82
  ## 0.0.21
6
83
 
7
84
  * **Breaking change**: Upgrade `FlashComponent` to use Slots V2.
@@ -0,0 +1,2 @@
1
+ class t extends HTMLElement{constructor(){super(),this.addEventListener("keydown",(t=>{const r=t.target;if(!(r instanceof HTMLElement))return;if("tab"!==r.getAttribute("role")&&!r.closest('[role="tablist"]'))return;const a=Array.from(this.querySelectorAll('[role="tablist"] [role="tab"]')),n=a.indexOf(a.find((t=>t.matches('[aria-selected="true"]'))));if("ArrowRight"===t.code){let t=n+1;t>=a.length&&(t=0),e(this,t)}else if("ArrowLeft"===t.code){let t=n-1;t<0&&(t=a.length-1),e(this,t)}else"Home"===t.code?(e(this,0),t.preventDefault()):"End"===t.code&&(e(this,a.length-1),t.preventDefault())})),this.addEventListener("click",(t=>{const r=Array.from(this.querySelectorAll('[role="tablist"] [role="tab"]'));if(!(t.target instanceof Element))return;const a=t.target.closest('[role="tab"]');if(!a||!a.closest('[role="tablist"]'))return;e(this,r.indexOf(a))}))}connectedCallback(){for(const t of this.querySelectorAll('[role="tablist"] [role="tab"]'))t.hasAttribute("aria-selected")||t.setAttribute("aria-selected","false"),t.hasAttribute("tabindex")||("true"===t.getAttribute("aria-selected")?t.setAttribute("tabindex","0"):t.setAttribute("tabindex","-1"))}}function e(t,e){const r=t.querySelectorAll('[role="tablist"] [role="tab"]'),a=t.querySelectorAll('[role="tabpanel"]'),n=r[e],i=a[e];if(!!t.dispatchEvent(new CustomEvent("tab-container-change",{bubbles:!0,cancelable:!0,detail:{relatedTarget:i}}))){for(const t of r)t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1");for(const t of a)t.hidden=!0,t.hasAttribute("tabindex")||t.hasAttribute("data-tab-container-no-tabstop")||t.setAttribute("tabindex","0");n.setAttribute("aria-selected","true"),n.setAttribute("tabindex","0"),n.focus(),i.hidden=!1,t.dispatchEvent(new CustomEvent("tab-container-changed",{bubbles:!0,detail:{relatedTarget:i}}))}}window.customElements.get("tab-container")||(window.TabContainerElement=t,window.customElements.define("tab-container",t));
2
+ //# sourceMappingURL=primer_view_components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primer_view_components.js","sources":["../../../node_modules/@github/tab-container-element/dist/index.js"],"sourcesContent":["export default class TabContainerElement extends HTMLElement {\n constructor() {\n super();\n this.addEventListener('keydown', (event) => {\n const target = event.target;\n if (!(target instanceof HTMLElement))\n return;\n if (target.getAttribute('role') !== 'tab' && !target.closest('[role=\"tablist\"]'))\n return;\n const tabs = Array.from(this.querySelectorAll('[role=\"tablist\"] [role=\"tab\"]'));\n const currentIndex = tabs.indexOf(tabs.find(tab => tab.matches('[aria-selected=\"true\"]')));\n if (event.code === 'ArrowRight') {\n let index = currentIndex + 1;\n if (index >= tabs.length)\n index = 0;\n selectTab(this, index);\n }\n else if (event.code === 'ArrowLeft') {\n let index = currentIndex - 1;\n if (index < 0)\n index = tabs.length - 1;\n selectTab(this, index);\n }\n else if (event.code === 'Home') {\n selectTab(this, 0);\n event.preventDefault();\n }\n else if (event.code === 'End') {\n selectTab(this, tabs.length - 1);\n event.preventDefault();\n }\n });\n this.addEventListener('click', (event) => {\n const tabs = Array.from(this.querySelectorAll('[role=\"tablist\"] [role=\"tab\"]'));\n if (!(event.target instanceof Element))\n return;\n const tab = event.target.closest('[role=\"tab\"]');\n if (!tab || !tab.closest('[role=\"tablist\"]'))\n return;\n const index = tabs.indexOf(tab);\n selectTab(this, index);\n });\n }\n connectedCallback() {\n for (const tab of this.querySelectorAll('[role=\"tablist\"] [role=\"tab\"]')) {\n if (!tab.hasAttribute('aria-selected')) {\n tab.setAttribute('aria-selected', 'false');\n }\n if (!tab.hasAttribute('tabindex')) {\n if (tab.getAttribute('aria-selected') === 'true') {\n tab.setAttribute('tabindex', '0');\n }\n else {\n tab.setAttribute('tabindex', '-1');\n }\n }\n }\n }\n}\nfunction selectTab(tabContainer, index) {\n const tabs = tabContainer.querySelectorAll('[role=\"tablist\"] [role=\"tab\"]');\n const panels = tabContainer.querySelectorAll('[role=\"tabpanel\"]');\n const selectedTab = tabs[index];\n const selectedPanel = panels[index];\n const cancelled = !tabContainer.dispatchEvent(new CustomEvent('tab-container-change', {\n bubbles: true,\n cancelable: true,\n detail: { relatedTarget: selectedPanel }\n }));\n if (cancelled)\n return;\n for (const tab of tabs) {\n tab.setAttribute('aria-selected', 'false');\n tab.setAttribute('tabindex', '-1');\n }\n for (const panel of panels) {\n panel.hidden = true;\n if (!panel.hasAttribute('tabindex') && !panel.hasAttribute('data-tab-container-no-tabstop')) {\n panel.setAttribute('tabindex', '0');\n }\n }\n selectedTab.setAttribute('aria-selected', 'true');\n selectedTab.setAttribute('tabindex', '0');\n selectedTab.focus();\n selectedPanel.hidden = false;\n tabContainer.dispatchEvent(new CustomEvent('tab-container-changed', {\n bubbles: true,\n detail: { relatedTarget: selectedPanel }\n }));\n}\nif (!window.customElements.get('tab-container')) {\n window.TabContainerElement = TabContainerElement;\n window.customElements.define('tab-container', TabContainerElement);\n}\n//# sourceMappingURL=index.js.map"],"names":["TabContainerElement","HTMLElement","[object Object]","super","this","addEventListener","event","target","getAttribute","closest","tabs","Array","from","querySelectorAll","currentIndex","indexOf","find","tab","matches","code","index","length","selectTab","preventDefault","Element","hasAttribute","setAttribute","tabContainer","panels","selectedTab","selectedPanel","dispatchEvent","CustomEvent","bubbles","cancelable","detail","relatedTarget","panel","hidden","focus","window","customElements","get","define"],"mappings":"AAAe,MAAMA,UAA4BC,YAC7CC,cACIC,QACAC,KAAKC,iBAAiB,WAAYC,IAC9B,MAAMC,EAASD,EAAMC,OACrB,KAAMA,aAAkBN,aACpB,OACJ,GAAoC,QAAhCM,EAAOC,aAAa,UAAsBD,EAAOE,QAAQ,oBACzD,OACJ,MAAMC,EAAOC,MAAMC,KAAKR,KAAKS,iBAAiB,kCACxCC,EAAeJ,EAAKK,QAAQL,EAAKM,MAAKC,GAAOA,EAAIC,QAAQ,6BAC/D,GAAmB,eAAfZ,EAAMa,KAAuB,CAC7B,IAAIC,EAAQN,EAAe,EACvBM,GAASV,EAAKW,SACdD,EAAQ,GACZE,EAAUlB,KAAMgB,QAEf,GAAmB,cAAfd,EAAMa,KAAsB,CACjC,IAAIC,EAAQN,EAAe,EACvBM,EAAQ,IACRA,EAAQV,EAAKW,OAAS,GAC1BC,EAAUlB,KAAMgB,OAEI,SAAfd,EAAMa,MACXG,EAAUlB,KAAM,GAChBE,EAAMiB,kBAEc,QAAfjB,EAAMa,OACXG,EAAUlB,KAAMM,EAAKW,OAAS,GAC9Bf,EAAMiB,qBAGdnB,KAAKC,iBAAiB,SAAUC,IAC5B,MAAMI,EAAOC,MAAMC,KAAKR,KAAKS,iBAAiB,kCAC9C,KAAMP,EAAMC,kBAAkBiB,SAC1B,OACJ,MAAMP,EAAMX,EAAMC,OAAOE,QAAQ,gBACjC,IAAKQ,IAAQA,EAAIR,QAAQ,oBACrB,OAEJa,EAAUlB,KADIM,EAAKK,QAAQE,OAInCf,oBACI,IAAK,MAAMe,KAAOb,KAAKS,iBAAiB,iCAC/BI,EAAIQ,aAAa,kBAClBR,EAAIS,aAAa,gBAAiB,SAEjCT,EAAIQ,aAAa,cACwB,SAAtCR,EAAIT,aAAa,iBACjBS,EAAIS,aAAa,WAAY,KAG7BT,EAAIS,aAAa,WAAY,QAMjD,SAASJ,EAAUK,EAAcP,GAC7B,MAAMV,EAAOiB,EAAad,iBAAiB,iCACrCe,EAASD,EAAad,iBAAiB,qBACvCgB,EAAcnB,EAAKU,GACnBU,EAAgBF,EAAOR,GAM7B,KALmBO,EAAaI,cAAc,IAAIC,YAAY,uBAAwB,CAClFC,SAAS,EACTC,YAAY,EACZC,OAAQ,CAAEC,cAAeN,MAE7B,CAEA,IAAK,MAAMb,KAAOP,EACdO,EAAIS,aAAa,gBAAiB,SAClCT,EAAIS,aAAa,WAAY,MAEjC,IAAK,MAAMW,KAAST,EAChBS,EAAMC,QAAS,EACVD,EAAMZ,aAAa,aAAgBY,EAAMZ,aAAa,kCACvDY,EAAMX,aAAa,WAAY,KAGvCG,EAAYH,aAAa,gBAAiB,QAC1CG,EAAYH,aAAa,WAAY,KACrCG,EAAYU,QACZT,EAAcQ,QAAS,EACvBX,EAAaI,cAAc,IAAIC,YAAY,wBAAyB,CAChEC,SAAS,EACTE,OAAQ,CAAEC,cAAeN,OAG5BU,OAAOC,eAAeC,IAAI,mBAC3BF,OAAOxC,oBAAsBA,EAC7BwC,OAAOC,eAAeE,OAAO,gBAAiB3C"}
@@ -7,13 +7,13 @@ module Primer
7
7
  class AvatarComponent < Primer::Component
8
8
  SMALL_THRESHOLD = 24
9
9
 
10
- # @example auto|Default
10
+ # @example Default
11
11
  # <%= render(Primer::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser")) %>
12
12
  #
13
- # @example auto|Square
13
+ # @example Square
14
14
  # <%= render(Primer::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", square: true)) %>
15
15
  #
16
- # @example auto|Link
16
+ # @example Link
17
17
  # <%= render(Primer::AvatarComponent.new(href: "#", src: "http://placekitten.com/200/200", alt: "@kittenuser")) %>
18
18
  #
19
19
  # @param src [String] The source url of the avatar image.
@@ -13,21 +13,21 @@ module Primer
13
13
  # @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::AvatarComponent) %>.
14
14
  renders_many :avatars, Primer::AvatarComponent
15
15
 
16
- # @example auto|Default
16
+ # @example Default
17
17
  # <%= render(Primer::AvatarStackComponent.new) do |c| %>
18
18
  # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
19
19
  # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
20
20
  # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
21
21
  # <% end %>
22
22
  #
23
- # @example auto|Align right
23
+ # @example Align right
24
24
  # <%= render(Primer::AvatarStackComponent.new(align: :right)) do |c| %>
25
25
  # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
26
26
  # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
27
27
  # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
28
28
  # <% end %>
29
29
  #
30
- # @example auto|With tooltip
30
+ # @example With tooltip
31
31
  # <%= render(Primer::AvatarStackComponent.new(tooltipped: true, body_arguments: { label: 'This is a tooltip!' })) do |c| %>
32
32
  # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
33
33
  # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
@@ -3,7 +3,7 @@
3
3
  module Primer
4
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/app/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
  #
@@ -41,7 +41,7 @@ module Primer
41
41
  # @param test_selector [String] Adds `data-test-selector='given value'` in non-Production environments for testing purposes.
42
42
  #
43
43
  # @param m [Integer] Margin. <%= one_of((-6..6).to_a) %>
44
- # @param mt [Integer] Margin left. <%= one_of((-6..6).to_a) %>
44
+ # @param mt [Integer] Margin top. <%= one_of((-6..6).to_a) %>
45
45
  # @param mr [Integer] Margin right. <%= one_of((-6..6).to_a) %>
46
46
  # @param mb [Integer] Margin bottom. <%= one_of((-6..6).to_a) %>
47
47
  # @param ml [Integer] Margin left. <%= one_of((-6..6).to_a) %>
@@ -119,6 +119,10 @@ module Primer
119
119
  content_tag(@tag, content, @content_tag_args.merge(@result))
120
120
  end
121
121
 
122
+ def self.status
123
+ Primer::Component::STATUSES[:beta]
124
+ end
125
+
122
126
  private
123
127
 
124
128
  def add_test_selector(args)
@@ -2,11 +2,11 @@
2
2
  <% if spinner.present? %>
3
3
  <%= spinner %>
4
4
  <% elsif @icon.present? %>
5
- <%= render(Primer::OcticonComponent.new(
5
+ <%= primer(:octicon,
6
6
  icon: @icon,
7
7
  size: @icon_size,
8
8
  classes: "blankslate-icon"
9
- )) %>
9
+ ) %>
10
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 %>
@@ -14,20 +14,20 @@ module Primer
14
14
  }
15
15
 
16
16
  #
17
- # @example auto|Basic
17
+ # @example Basic
18
18
  # <%= render Primer::BlankslateComponent.new(
19
19
  # title: "Title",
20
20
  # description: "Description",
21
21
  # ) %>
22
22
  #
23
- # @example auto|Icon|Add an `icon` to give additional context. Refer to the [Octicons](https://primer.style/octicons/) documentation to choose an icon.
23
+ # @example Icon|Add an `icon` to give additional context. Refer to the [Octicons](https://primer.style/octicons/) documentation to choose an icon.
24
24
  # <%= render Primer::BlankslateComponent.new(
25
25
  # icon: "octoface",
26
26
  # title: "Title",
27
27
  # description: "Description",
28
28
  # ) %>
29
29
  #
30
- # @example auto|Loading|Add a [SpinnerComponent](https://primer.style/view-components/components/spinner) to the blankslate in place of an icon.
30
+ # @example Loading|Add a [SpinnerComponent](https://primer.style/view-components/components/spinner) to the blankslate in place of an icon.
31
31
  # <%= render Primer::BlankslateComponent.new(
32
32
  # title: "Title",
33
33
  # description: "Description",
@@ -35,14 +35,14 @@ module Primer
35
35
  # <% component.spinner(size: :large) %>
36
36
  # <% end %>
37
37
  #
38
- # @example auto|Custom content|Pass custom content as a block in place of `description`.
38
+ # @example Custom content|Pass custom content as a block in place of `description`.
39
39
  # <%= render Primer::BlankslateComponent.new(
40
40
  # title: "Title",
41
41
  # ) do %>
42
42
  # <em>Your custom content here</em>
43
43
  # <% end %>
44
44
  #
45
- # @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.
45
+ # @example Action button|Provide a button to guide users to take action from the blankslate. The button appears below the description and custom content.
46
46
  # <%= render Primer::BlankslateComponent.new(
47
47
  # icon: "book",
48
48
  # title: "Welcome to the mona wiki!",
@@ -52,7 +52,7 @@ module Primer
52
52
  # button_url: "https://github.com/monalisa/mona/wiki/_new",
53
53
  # ) %>
54
54
  #
55
- # @example auto|Link|Add an additional link to help users learn more about a feature. The link will be shown at the very bottom:
55
+ # @example Link|Add an additional link to help users learn more about a feature. The link will be shown at the very bottom:
56
56
  # <%= render Primer::BlankslateComponent.new(
57
57
  # icon: "book",
58
58
  # title: "Welcome to the mona wiki!",
@@ -61,7 +61,7 @@ module Primer
61
61
  # link_url: "https://docs.github.com/en/github/building-a-strong-community/about-wikis",
62
62
  # ) %>
63
63
  #
64
- # @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.
64
+ # @example 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.
65
65
  # <%= render Primer::BlankslateComponent.new(
66
66
  # icon: "book",
67
67
  # title: "Welcome to the mona wiki!",
@@ -130,5 +130,9 @@ module Primer
130
130
  @link_text = link_text
131
131
  @link_url = link_url
132
132
  end
133
+
134
+ def self.status
135
+ Primer::Component::STATUSES[:beta]
136
+ end
133
137
  end
134
138
  end
@@ -1,26 +1,12 @@
1
1
  <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
- <% if header %>
3
- <%= render Primer::BaseComponent.new(**header.system_arguments) do %>
4
- <%= header.content %>
5
- <% end %>
6
- <% end %>
7
- <% if body %>
8
- <%= render Primer::BaseComponent.new(**body.system_arguments) do %>
9
- <%= body.content %>
10
- <% end %>
11
- <% end %>
2
+ <%= header %>
3
+ <%= body %>
12
4
  <% if rows.any? %>
13
5
  <ul>
14
6
  <% rows.each do |row| %>
15
- <%= render Primer::BaseComponent.new(**row.system_arguments) do %>
16
- <%= row.content %>
17
- <% end %>
7
+ <%= row %>
18
8
  <% end %>
19
9
  </ul>
20
10
  <% end %>
21
- <% if footer %>
22
- <%= render Primer::BaseComponent.new(**footer.system_arguments) do %>
23
- <%= footer.content %>
24
- <% end %>
25
- <% end %>
11
+ <%= footer %>
26
12
  <% end %>
@@ -3,30 +3,77 @@
3
3
  module Primer
4
4
  # BorderBox is a Box component with a border.
5
5
  class BorderBoxComponent < Primer::Component
6
- include ViewComponent::Slotable
6
+ include ViewComponent::SlotableV2
7
7
 
8
- with_slot :header, class_name: "Header"
9
- with_slot :body, class_name: "Body"
10
- with_slot :footer, class_name: "Footer"
11
- with_slot :row, collection: true, class_name: "Row"
8
+ # Optional Header.
9
+ #
10
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
11
+ renders_one :header, lambda { |**system_arguments|
12
+ system_arguments[:tag] = :div
13
+ system_arguments[:classes] = class_names(
14
+ "Box-header",
15
+ system_arguments[:classes]
16
+ )
17
+
18
+ Primer::BaseComponent.new(**system_arguments)
19
+ }
20
+
21
+ # Optional Body.
22
+ #
23
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
24
+ renders_one :body, lambda { |**system_arguments|
25
+ system_arguments[:tag] = :div
26
+ system_arguments[:classes] = class_names(
27
+ "Box-body",
28
+ system_arguments[:classes]
29
+ )
12
30
 
13
- # @example auto|Header, body, rows, and footer
31
+ Primer::BaseComponent.new(**system_arguments)
32
+ }
33
+
34
+ # Optional Footer.
35
+ #
36
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
37
+ renders_one :footer, lambda { |**system_arguments|
38
+ system_arguments[:tag] = :div
39
+ system_arguments[:classes] = class_names(
40
+ "Box-footer",
41
+ system_arguments[:classes]
42
+ )
43
+
44
+ Primer::BaseComponent.new(**system_arguments)
45
+ }
46
+
47
+ # Use Rows to add rows with borders and maintain the same padding.
48
+ #
49
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
50
+ renders_many :rows, lambda { |**system_arguments|
51
+ system_arguments[:tag] = :li
52
+ system_arguments[:classes] = class_names(
53
+ "Box-row",
54
+ system_arguments[:classes]
55
+ )
56
+
57
+ Primer::BaseComponent.new(**system_arguments)
58
+ }
59
+
60
+ # @example Header, body, rows, and footer
14
61
  # <%= render(Primer::BorderBoxComponent.new) do |component| %>
15
- # <% component.slot(:header) do %>
62
+ # <% component.header do %>
16
63
  # Header
17
64
  # <% end %>
18
- # <% component.slot(:body) do %>
65
+ # <% component.body do %>
19
66
  # Body
20
67
  # <% end %>
21
- # <% component.slot(:row) do %>
68
+ # <% component.row do %>
22
69
  # <% if true %>
23
70
  # Row one
24
71
  # <% end %>
25
72
  # <% end %>
26
- # <% component.slot(:row) do %>
73
+ # <% component.row do %>
27
74
  # Row two
28
75
  # <% end %>
29
- # <% component.slot(:footer) do %>
76
+ # <% component.footer do %>
30
77
  # Footer
31
78
  # <% end %>
32
79
  # <% end %>
@@ -45,61 +92,5 @@ module Primer
45
92
  def self.status
46
93
  Primer::Component::STATUSES[:beta]
47
94
  end
48
-
49
- # :nodoc:
50
- class Header < Primer::Slot
51
- attr_reader :system_arguments
52
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
53
- def initialize(**system_arguments)
54
- @system_arguments = system_arguments
55
- @system_arguments[:tag] = :div
56
- @system_arguments[:classes] = class_names(
57
- "Box-header",
58
- system_arguments[:classes]
59
- )
60
- end
61
- end
62
-
63
- # :nodoc:
64
- class Body < Primer::Slot
65
- attr_reader :system_arguments
66
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
67
- def initialize(**system_arguments)
68
- @system_arguments = system_arguments
69
- @system_arguments[:tag] = :div
70
- @system_arguments[:classes] = class_names(
71
- "Box-body",
72
- system_arguments[:classes]
73
- )
74
- end
75
- end
76
-
77
- # :nodoc:
78
- class Footer < Primer::Slot
79
- attr_reader :system_arguments
80
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
81
- def initialize(**system_arguments)
82
- @system_arguments = system_arguments
83
- @system_arguments[:tag] = :div
84
- @system_arguments[:classes] = class_names(
85
- "Box-footer",
86
- system_arguments[:classes]
87
- )
88
- end
89
- end
90
-
91
- # :nodoc:
92
- class Row < Primer::Slot
93
- attr_reader :system_arguments
94
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
95
- def initialize(**system_arguments)
96
- @system_arguments = system_arguments
97
- @system_arguments[:tag] = :li
98
- @system_arguments[:classes] = class_names(
99
- "Box-row",
100
- system_arguments[:classes]
101
- )
102
- end
103
- end
104
95
  end
105
96
  end
@@ -3,10 +3,10 @@
3
3
  module Primer
4
4
  # A basic wrapper component for most layout related needs.
5
5
  class BoxComponent < Primer::Component
6
- # @example auto|Default
6
+ # @example Default
7
7
  # <%= render(Primer::BoxComponent.new) { "Your content here" } %>
8
8
  #
9
- # @example auto|Color and padding
9
+ # @example Color and padding
10
10
  # <%= render(Primer::BoxComponent.new(bg: :gray, p: 3)) { "Hello world" } %>
11
11
  #
12
12
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>