primer_view_components 0.0.21 → 0.0.22

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -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 +1 -1
  8. data/app/components/primer/blankslate_component.html.erb +2 -2
  9. data/app/components/primer/blankslate_component.rb +7 -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.rb +1 -1
  14. data/app/components/primer/button_component.rb +2 -2
  15. data/app/components/primer/button_group_component.rb +1 -1
  16. data/app/components/primer/button_marketing_component.rb +2 -2
  17. data/app/components/primer/component.rb +4 -0
  18. data/app/components/primer/counter_component.rb +1 -1
  19. data/app/components/primer/details_component.html.erb +2 -6
  20. data/app/components/primer/details_component.rb +22 -35
  21. data/app/components/primer/dropdown_component.html.erb +2 -2
  22. data/app/components/primer/dropdown_component.rb +4 -6
  23. data/app/components/primer/dropdown_menu_component.rb +4 -4
  24. data/app/components/primer/flash_component.html.erb +2 -2
  25. data/app/components/primer/flash_component.rb +5 -5
  26. data/app/components/primer/flex_component.rb +4 -4
  27. data/app/components/primer/flex_item_component.rb +1 -1
  28. data/app/components/primer/heading_component.rb +3 -1
  29. data/app/components/primer/label_component.rb +2 -2
  30. data/app/components/primer/layout_component.rb +2 -2
  31. data/app/components/primer/link_component.rb +2 -2
  32. data/app/components/primer/markdown_component.rb +8 -8
  33. data/app/components/primer/menu_component.rb +1 -1
  34. data/app/components/primer/octicon_component.rb +5 -3
  35. data/app/components/primer/popover_component.rb +3 -3
  36. data/app/components/primer/primer.js +1 -0
  37. data/app/components/primer/primer.ts +1 -0
  38. data/app/components/primer/progress_bar_component.rb +4 -4
  39. data/app/components/primer/spinner_component.rb +3 -3
  40. data/app/components/primer/state_component.rb +21 -10
  41. data/app/components/primer/subhead_component.rb +3 -3
  42. data/app/components/primer/tab_container_component.js +1 -0
  43. data/app/components/primer/tab_container_component.rb +41 -0
  44. data/app/components/primer/tab_container_component.ts +1 -0
  45. data/app/components/primer/tab_nav_component.html.erb +17 -0
  46. data/app/components/primer/tab_nav_component.rb +108 -0
  47. data/app/components/primer/text_component.rb +1 -1
  48. data/app/components/primer/timeline_item_component.rb +1 -1
  49. data/app/components/primer/tooltip_component.rb +5 -5
  50. data/app/components/primer/truncate_component.rb +4 -4
  51. data/app/components/primer/underline_nav_component.rb +2 -2
  52. data/{lib → app/lib}/primer/class_name_helper.rb +0 -0
  53. data/{lib → app/lib}/primer/classify.rb +0 -2
  54. data/{lib → app/lib}/primer/classify/cache.rb +0 -0
  55. data/{lib → app/lib}/primer/fetch_or_fallback_helper.rb +0 -0
  56. data/{lib → app/lib}/primer/join_style_arguments_helper.rb +0 -0
  57. data/app/lib/primer/view_helper.rb +22 -0
  58. data/app/lib/primer/view_helper/dsl.rb +34 -0
  59. data/lib/primer/view_components/engine.rb +10 -2
  60. data/lib/primer/view_components/version.rb +5 -1
  61. data/static/statuses.json +1 -1
  62. metadata +18 -8
  63. 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: 3155227cd7ba3d3c02063d1021e1430df8d514a7feabe0b5fad0680c593ffc3c
4
+ data.tar.gz: 344362c292977c1dd6b84d283b1a5b5fea8894d2dd0aa5be0c1007fdbf4bf397
5
5
  SHA512:
6
- metadata.gz: f6ad3831ccbb77616d668036954108e3642ffe747ee2837714761ebc54ca353b654813cad3396bb31e4a94f03f6e84f5ae52c75cf07387fffd24758d73967b70
7
- data.tar.gz: 79d4aca35c8556fcbbcbab8fb6cf5d4e5440f920508af5ed880bb200a03820869a576ebafd3200ff756a3b7a580855c8b1c77ba71a65f085367fc80ac063e49f
6
+ metadata.gz: 76e300f1f5cd3cf5e861f48246f6124ad2432014a003b4b8dffe3b373415d47c43af118965c879f8fe58bfd111dded1a9270c7e2f824020022b14990028210dd
7
+ data.tar.gz: 899f5cf473acde6ff778bd2a86ded0bbb90aea6d8bce9fca0483c455aefc3b8c68388cb0eec578129d6b5703ae53eeeacc14701d4b2fcbdaaba47fd447b117f6
data/CHANGELOG.md CHANGED
@@ -1,6 +1,32 @@
1
1
  # CHANGELOG
2
2
 
3
3
  ## main
4
+
5
+ ## 0.0.22
6
+
7
+ * Add view helpers to easily render Primer components.
8
+
9
+ *Manuel Puyol*
10
+
11
+ * Add `TabContainer` and `TabNav` components.
12
+
13
+ *Manuel Puyol*
14
+
15
+ * Promote `StateComponent` to beta.
16
+
17
+ *Simon Taranto*
18
+
19
+ * **Breaking change**: Upgrade `BorderBoxComponent` to use Slots V2.
20
+
21
+ *Manuel Puyol*
22
+
23
+ * **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.
24
+
25
+ *Simon Taranto*
26
+
27
+ * **Breaking change**: Upgrade `DetailsComponent` to use Slots V2.
28
+
29
+ *Simon Taranto*
4
30
 
5
31
  ## 0.0.21
6
32
 
@@ -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") %>
@@ -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) %>
@@ -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!",
@@ -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 %>
@@ -7,7 +7,7 @@ module Primer
7
7
 
8
8
  with_slot :item, collection: true, class_name: "BreadcrumbItem"
9
9
 
10
- # @example auto|Basic
10
+ # @example Basic
11
11
  # <%= render(Primer::BreadcrumbComponent.new) do |component| %>
12
12
  # <% component.slot(:item, href: "/") do %>Home<% end %>
13
13
  # <% component.slot(:item, href: "/about") do %>About<% end %>
@@ -26,13 +26,13 @@ module Primer
26
26
  DEFAULT_TYPE = :button
27
27
  TYPE_OPTIONS = [DEFAULT_TYPE, :reset, :submit].freeze
28
28
 
29
- # @example auto|Button types
29
+ # @example Button types
30
30
  # <%= render(Primer::ButtonComponent.new) { "Default" } %>
31
31
  # <%= render(Primer::ButtonComponent.new(button_type: :primary)) { "Primary" } %>
32
32
  # <%= render(Primer::ButtonComponent.new(button_type: :danger)) { "Danger" } %>
33
33
  # <%= render(Primer::ButtonComponent.new(button_type: :outline)) { "Outline" } %>
34
34
  #
35
- # @example auto|Variants
35
+ # @example Variants
36
36
  # <%= render(Primer::ButtonComponent.new(variant: :small)) { "Small" } %>
37
37
  # <%= render(Primer::ButtonComponent.new(variant: :medium)) { "Medium" } %>
38
38
  # <%= render(Primer::ButtonComponent.new(variant: :large)) { "Large" } %>
@@ -10,7 +10,7 @@ module Primer
10
10
  # @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::ButtonComponent) %>.
11
11
  renders_many :buttons, ->(**kwargs) { Primer::ButtonComponent.new(group_item: true, **kwargs) }
12
12
 
13
- # @example auto|Default
13
+ # @example Default
14
14
  # <%= render(Primer::ButtonGroupComponent.new) do |component|
15
15
  # component.button { "Default" }
16
16
  # component.button(button_type: :primary) { "Primary" }
@@ -25,7 +25,7 @@ module Primer
25
25
  DEFAULT_TYPE = :button
26
26
  TYPE_OPTIONS = [DEFAULT_TYPE, :submit].freeze
27
27
 
28
- # @example auto|Button types
28
+ # @example Button types
29
29
  # <%= render(Primer::ButtonMarketingComponent.new(mr: 2)) { "Default" } %>
30
30
  # <%= render(Primer::ButtonMarketingComponent.new(button_type: :primary, mr: 2)) { "Primary" } %>
31
31
  # <%= render(Primer::ButtonMarketingComponent.new(button_type: :outline)) { "Outline" } %>
@@ -33,7 +33,7 @@ module Primer
33
33
  # <%= render(Primer::ButtonMarketingComponent.new(button_type: :transparent)) { "Transparent" } %>
34
34
  # </div>
35
35
  #
36
- # @example auto|Sizes
36
+ # @example Sizes
37
37
  # <%= render(Primer::ButtonMarketingComponent.new(mr: 2)) { "Default" } %>
38
38
  # <%= render(Primer::ButtonMarketingComponent.new(variant: :large)) { "Large" } %>
39
39
  #
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "octicons_helper/helper"
4
+
3
5
  module Primer
4
6
  # @private
5
7
  class Component < ViewComponent::Base
@@ -7,6 +9,8 @@ module Primer
7
9
  include FetchOrFallbackHelper
8
10
  include OcticonsHelper
9
11
  include JoinStyleArgumentsHelper
12
+ include ViewHelper::DSL
13
+ include ViewHelper
10
14
 
11
15
  # sourced from https://primer.style/doctocat/usage/front-matter#status
12
16
  STATUSES = {