sdr_view_components 0.18.1 → 0.19.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5de046f013212327fcf03eefd5dcbdaa0918dc20a8a33687036d6802ec5f98fe
4
- data.tar.gz: afe2f59fef8352750a73ee9327e5e39d253571dc7792aa887208b5b072465611
3
+ metadata.gz: 2022709968e8b976ee79e3e086b4a7e17210babd054ddb8167f8892a0381b02c
4
+ data.tar.gz: c55ccadec5da2a76b69cf9f3fb0ace9849fe102b3125458ee635cd3b399ae6c6
5
5
  SHA512:
6
- metadata.gz: 6452476e378e3df685166323eac91b36a6df362e9b2db163b2fd4dbc4365b7211cab17ede65438b82ad9a9a8133a027372aee706cf2acc24af544a301f803c32
7
- data.tar.gz: ad821a7e03619fb08e414ddcef5143e59399c11b4c3b6e2899334684cbbeba48a0b35ba62ea9b571c74e129435c57e20d37cba43ebe5cda2d543f3c0b3075c88
6
+ metadata.gz: 53dd2d4b2a4f20b8a1d820648acd667aa510b0273d9f86a40f036057c4a80a6c6ebcd17328f8fb453d2ce17294bcfc7fe7bf6182577a131b9f3efac572ac35cc
7
+ data.tar.gz: 2e4ed587465f79ec3d6544000e9bd2b1853d53c063f4c405a3119ddc278d69e3f4d27d47ea82eab0d41eb0db1a345393688d4d1cda93d8a027c25d818892fc07
data/README.md CHANGED
@@ -239,6 +239,17 @@ See the Lookbook preview for `SdrViewComponents::TabForm::TabListComponent` for
239
239
  <% end %>
240
240
  ```
241
241
 
242
+ Instead of `heading:`, the heading can be provided with the `heading_content` slot:
243
+
244
+ ```erb
245
+ <%= render SdrViewComponents::Elements::CollapsibleSectionComponent.new(id: 'pages') do |component| %>
246
+ <% component.with_heading_content do %>
247
+ Pages <span class="badge text-bg-secondary">12</span>
248
+ <% end %>
249
+ <p>Section content.</p>
250
+ <% end %>
251
+ ```
252
+
242
253
  ### Navigation components
243
254
 
244
255
  SdrViewComponents provides components for building navigation bar items and dropdown menus:
@@ -2,7 +2,7 @@
2
2
  <%= render SdrViewComponents::Elements::HeadingComponent.new(level:, classes: heading_classes) do %>
3
3
  <%= tag.button type: 'button', class: toggle_classes, data: { bs_toggle: 'collapse', bs_target: "##{id}" }, aria: { expanded:, controls: id } do %>
4
4
  <%= helpers.icon(icon_classes: 'bi bi-chevron-up', classes: 'collapsible-section-icon', aria: { hidden: true }) %>
5
- <%= heading %>
5
+ <%= heading || heading_content %>
6
6
  <% end %>
7
7
  <% end %>
8
8
  <%= tag.div id:, class: collapse_classes do %>
@@ -4,7 +4,9 @@ module SdrViewComponents
4
4
  module Elements
5
5
  # Component for a section whose heading toggles (Bootstrap collapse) the display of its content.
6
6
  class CollapsibleSectionComponent < BaseComponent
7
- def initialize(id:, heading:, level: :h2, expanded: true, classes: [], heading_classes: []) # rubocop:disable Metrics/ParameterLists
7
+ renders_one :heading_content # alternative to the heading argument
8
+
9
+ def initialize(id:, heading: nil, level: :h2, expanded: true, classes: [], heading_classes: []) # rubocop:disable Metrics/ParameterLists
8
10
  @id = id
9
11
  @heading = heading
10
12
  @level = level
@@ -16,6 +18,10 @@ module SdrViewComponents
16
18
 
17
19
  attr_reader :id, :heading, :level, :expanded, :heading_classes
18
20
 
21
+ def before_render
22
+ raise ArgumentError, 'Must provide heading or heading_content' unless heading.present? || heading_content?
23
+ end
24
+
19
25
  def classes
20
26
  merge_classes('collapsible-section', @classes)
21
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SdrViewComponents
4
- VERSION = '0.18.1'
4
+ VERSION = '0.19.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdr_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Collier