bs5 0.0.13 → 0.0.14
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 +4 -4
- data/app/components/bs5/accordion_component.html.erb +3 -10
- data/app/components/bs5/accordion_component.rb +1 -0
- data/app/helpers/bs5/components_helper.rb +4 -0
- data/app/service/bs5/collapse_service.rb +47 -0
- data/app/views/bs5/examples/collapse/default/_example.html.erb +4 -0
- data/app/views/bs5/examples/collapse/default/multiple_targets.html.erb +21 -0
- data/app/views/bs5/examples/collapse/default/snippet.html.erb +9 -0
- data/app/views/bs5/pages/collapse.html.erb +2 -0
- data/app/views/layouts/bs5/pages.html.erb +1 -0
- data/lib/bs5/version.rb +1 -1
- metadata +6 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: fe7d17d9f86d5887ab9e3a9cbc86212c19a6ed20526ac905339f6b997c044096
         | 
| 4 | 
            +
              data.tar.gz: 4d2df678ad8595ebff4a123325a84593dee109fe57a614aaa2473a7d88fb5e9c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f9a8d6249245234d557749abeecbe37feda5e13cbdf2e749baa96f77ffab0cb1b82d7c9c7e00f6751eda8860b396efb333ef8a7a69ca56908c9cd3f1570b9400
         | 
| 7 | 
            +
              data.tar.gz: 8d4de475b7f904a29ec63bc1845b58a7122fccd366f787616e9f7b7c36e1bba1d4886adc31d0e506de223fea7c84afbaddec553d7d307164adf0c79d949ddb45
         | 
| @@ -6,16 +6,9 @@ | |
| 6 6 | 
             
                      id="<%= item.header_id %>"
         | 
| 7 7 | 
             
                      class="accordion-header"
         | 
| 8 8 | 
             
                    >
         | 
| 9 | 
            -
                       | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
                        data-toggle="collapse"
         | 
| 13 | 
            -
                        data-target="#<%= item.collapse_id %>"
         | 
| 14 | 
            -
                        aria-expanded="true"
         | 
| 15 | 
            -
                        aria-controls="<%= item.collapse_id %>"
         | 
| 16 | 
            -
                      >
         | 
| 17 | 
            -
                          <%= item.title %>
         | 
| 18 | 
            -
                      </button>
         | 
| 9 | 
            +
                      <%= button_tag item.title,
         | 
| 10 | 
            +
                          bs5_collapse(target: "##{item.collapse_id}", expanded: !item.collapsed?)
         | 
| 11 | 
            +
                            .merge(type: :button, class: item.button_class) %>
         | 
| 19 12 | 
             
                    </h2>
         | 
| 20 13 | 
             
                    <div
         | 
| 21 14 | 
             
                      id="<%= item.collapse_id %>"
         | 
| @@ -0,0 +1,47 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Bs5
         | 
| 4 | 
            +
              class CollapseService
         | 
| 5 | 
            +
                CONTROLS_ERR_MSG = 'Please provide either a `controls` option' \
         | 
| 6 | 
            +
                                   ' containing the id of the collapsible element' \
         | 
| 7 | 
            +
                                   ' or an ID selector as `target` options.'
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                attr_reader :expanded, :target, :controls
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                def initialize(expanded: false, target: nil, controls: nil)
         | 
| 12 | 
            +
                  @expanded = expanded
         | 
| 13 | 
            +
                  @target = target
         | 
| 14 | 
            +
                  @controls = controls
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                def to_hash
         | 
| 18 | 
            +
                  {
         | 
| 19 | 
            +
                    data: data_options,
         | 
| 20 | 
            +
                    aria: aria_options
         | 
| 21 | 
            +
                  }
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                private
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                def data_options
         | 
| 27 | 
            +
                  options = { toggle: :collapse }
         | 
| 28 | 
            +
                  options[:target] = target if target
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  options
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                def aria_options
         | 
| 34 | 
            +
                  options = { expanded: expanded }
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  if controls
         | 
| 37 | 
            +
                    options[:controls] = controls
         | 
| 38 | 
            +
                  elsif target&.start_with?('#')
         | 
| 39 | 
            +
                    options[:controls] = target.delete_prefix('#')
         | 
| 40 | 
            +
                  else
         | 
| 41 | 
            +
                    raise CONTROLS_ERR_MSG
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  options
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
            end
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            <p>
         | 
| 2 | 
            +
              <%= link_to 'Toggle first element', '#multiCollapseExample1', bs5_collapse(controls: 'multiCollapseExample1 multiCollapseExample2').merge(class: 'btn btn-primary', role: :button) %>
         | 
| 3 | 
            +
              <%= bs5_button_tag 'Toggle second element', bs5_collapse(target: '#multiCollapseExample2', controls: 'multiCollapseExample1 multiCollapseExample2') %>
         | 
| 4 | 
            +
              <%= bs5_button_tag 'Toggle both elements', bs5_collapse(target: '.multi-collapse', controls: 'multiCollapseExample1 multiCollapseExample2') %>
         | 
| 5 | 
            +
            </p>
         | 
| 6 | 
            +
            <div class="row">
         | 
| 7 | 
            +
              <div class="col">
         | 
| 8 | 
            +
                <div class="collapse multi-collapse" id="multiCollapseExample1">
         | 
| 9 | 
            +
                  <div class="card card-body">
         | 
| 10 | 
            +
                    Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
         | 
| 11 | 
            +
                  </div>
         | 
| 12 | 
            +
                </div>
         | 
| 13 | 
            +
              </div>
         | 
| 14 | 
            +
              <div class="col">
         | 
| 15 | 
            +
                <div class="collapse multi-collapse" id="multiCollapseExample2">
         | 
| 16 | 
            +
                  <div class="card card-body">
         | 
| 17 | 
            +
                    Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
         | 
| 18 | 
            +
                  </div>
         | 
| 19 | 
            +
                </div>
         | 
| 20 | 
            +
              </div>
         | 
| 21 | 
            +
            </div>
         | 
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            <p>
         | 
| 2 | 
            +
              <%= link_to 'Link with href', '#collapseExample', bs5_collapse(controls: 'collapseExample').merge(class: 'btn btn-primary', role: :button) %>
         | 
| 3 | 
            +
              <%= bs5_button_tag 'Button with data-target', bs5_collapse(target: '#collapseExample').merge(type: :button) %>
         | 
| 4 | 
            +
            </p>
         | 
| 5 | 
            +
            <div class="collapse" id="collapseExample">
         | 
| 6 | 
            +
              <div class="card card-body">
         | 
| 7 | 
            +
                Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
         | 
| 8 | 
            +
              </div>
         | 
| 9 | 
            +
            </div>
         | 
| @@ -18,6 +18,7 @@ | |
| 18 18 | 
             
                        <% lg.slot(:item, active: current_page?(pages_path('breadcrumb'))) do %><%= link_to 'Breadcrumb', pages_path('breadcrumb') %><% end %>
         | 
| 19 19 | 
             
                        <% lg.slot(:item, active: current_page?(pages_path('buttons'))) do %><%= link_to 'Buttons', pages_path('buttons') %><% end %>
         | 
| 20 20 | 
             
                        <% lg.slot(:item, active: current_page?(pages_path('close_button'))) do %><%= link_to 'Close button', pages_path('close_button') %><% end %>
         | 
| 21 | 
            +
                        <% lg.slot(:item, active: current_page?(pages_path('collapse'))) do %><%= link_to 'Collapse', pages_path('collapse') %><% end %>
         | 
| 21 22 | 
             
                        <% lg.slot(:item, active: current_page?(pages_path('list_group'))) do %><%= link_to 'List group', pages_path('list_group') %><% end %>
         | 
| 22 23 | 
             
                        <% lg.slot(:item, active: current_page?(pages_path('tooltips'))) do %><%= link_to 'Tooltips', pages_path('tooltips') %><% end %>
         | 
| 23 24 | 
             
                      <%- end %>
         | 
    
        data/lib/bs5/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: bs5
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.14
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Patrick Baselier
         | 
| @@ -162,6 +162,7 @@ files: | |
| 162 162 | 
             
            - app/helpers/bs5/components_helper.rb
         | 
| 163 163 | 
             
            - app/helpers/bs5/examples_helper.rb
         | 
| 164 164 | 
             
            - app/models/bs5/application_record.rb
         | 
| 165 | 
            +
            - app/service/bs5/collapse_service.rb
         | 
| 165 166 | 
             
            - app/validators/style_validator.rb
         | 
| 166 167 | 
             
            - app/views/bs5/examples/accordion/default/_example.html.erb
         | 
| 167 168 | 
             
            - app/views/bs5/examples/accordion/default/snippet.html.erb
         | 
| @@ -207,6 +208,9 @@ files: | |
| 207 208 | 
             
            - app/views/bs5/examples/close_button/disabled/snippet.html.erb
         | 
| 208 209 | 
             
            - app/views/bs5/examples/close_button/white/_example.html.erb
         | 
| 209 210 | 
             
            - app/views/bs5/examples/close_button/white/snippet.html.erb
         | 
| 211 | 
            +
            - app/views/bs5/examples/collapse/default/_example.html.erb
         | 
| 212 | 
            +
            - app/views/bs5/examples/collapse/default/multiple_targets.html.erb
         | 
| 213 | 
            +
            - app/views/bs5/examples/collapse/default/snippet.html.erb
         | 
| 210 214 | 
             
            - app/views/bs5/examples/list_group/actionable/_example.html.erb
         | 
| 211 215 | 
             
            - app/views/bs5/examples/list_group/actionable/button.html.erb
         | 
| 212 216 | 
             
            - app/views/bs5/examples/list_group/actionable/snippet.html.erb
         | 
| @@ -240,6 +244,7 @@ files: | |
| 240 244 | 
             
            - app/views/bs5/pages/breadcrumb.html.erb
         | 
| 241 245 | 
             
            - app/views/bs5/pages/buttons.html.erb
         | 
| 242 246 | 
             
            - app/views/bs5/pages/close_button.html.erb
         | 
| 247 | 
            +
            - app/views/bs5/pages/collapse.html.erb
         | 
| 243 248 | 
             
            - app/views/bs5/pages/list_group.html.erb
         | 
| 244 249 | 
             
            - app/views/bs5/pages/tooltips.html.erb
         | 
| 245 250 | 
             
            - app/views/layouts/bs5/application.html.erb
         |