bs5_expandable_list_group 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3cf656df05f0efc37c63c574dc62e39dfc143911398bc3346f5641a1ac14400
4
- data.tar.gz: 1122074157406c6c4a52aa579d59c64fe8162e3c320c5bb03d6dc56b8e5f9b12
3
+ metadata.gz: a25801cb5cccc05129ddee20be6d7613b6861725540fc35762abeb9533da688e
4
+ data.tar.gz: 8404505ce4e166979bacd59621d8354e40db54c7a9e582c0187a31d5e9101625
5
5
  SHA512:
6
- metadata.gz: 2e225cb6367f28f3e31123bf1a9af9d6735bf441ef64e5d2276f04ebbfbf6d6b7545f7e00fc64741ca81b293b6273a9363cb802832f39fbc426a7a22998b819e
7
- data.tar.gz: 3294f3b18925ebf3f7317bf07f67816e03e4fe54c700a8156de928675c88ec7183a1175de4aeebf738e0ecab9cda4bb0d5f8d971f0651e733121c67135671c3a
6
+ metadata.gz: 92876de97894c46e95299f40bc5ea069d1a0c8151da69c399c350e59573f71986e5a0534fe36308d651e0fb00f9b744b6b26a101a6f8f0e66b59a781e2144223
7
+ data.tar.gz: 807dbe554e7fb82bf8f29e6b69212f8afb2952110b23828703a5f0ce1b8dcf66a48a0dacd499bec41f2e5dcae97dafd9cd8b5342d8313af9623e2467cc492499
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/bazzel/Bs5ExpandableListGroup.svg?branch=main)](https://travis-ci.org/bazzel/Bs5ExpandableListGroup)
4
4
 
5
- **Bootstrap 5 expandable list group** gives you a simple API for creating expandable and stretchable list groups. A bit like [Bootstrap 5](https://getbootstrap.com/)'s [Accordion](https://getbootstrap.com/docs/5.0/components/accordion/), [Collapse](https://getbootstrap.com/docs/5.0/components/collapse/) and [List group](https://getbootstrap.com/docs/5.0/components/list-group/) components combined.
5
+ **Bootstrap 5 expandable list group** is a Ruby on Rails engine and gives you a simple API for creating expandable and stretchable list groups. A bit like [Bootstrap 5](https://getbootstrap.com/)'s [Accordion](https://getbootstrap.com/docs/5.0/components/accordion/), [Collapse](https://getbootstrap.com/docs/5.0/components/collapse/) and [List group](https://getbootstrap.com/docs/5.0/components/list-group/) components combined.
6
6
 
7
7
  https://user-images.githubusercontent.com/7672/120296188-27170580-c2c8-11eb-936a-a93c16326acb.mp4
8
8
 
@@ -55,7 +55,7 @@ $ bin/rails generate bs5_expandable_list_group:install
55
55
 
56
56
  This copies the required assets to your application directory:
57
57
 
58
- Stylesheets are copied to `app/javascript/stylesheets`. If needed, you can the following line to your `application.scss` to import them:
58
+ Stylesheets are copied to `app/javascript/stylesheets`. If needed, you can add the following line to your `application.scss` to import them:
59
59
 
60
60
  ```scss
61
61
  @import "bootstrap";
@@ -63,13 +63,11 @@ Stylesheets are copied to `app/javascript/stylesheets`. If needed, you can the f
63
63
  @import "stylesheets/stretchable-items";
64
64
  ```
65
65
 
66
- When you use Webpacker for your CSS, you should move these added stylesheets to the proper location (propably somewhere in `app/javascript` and import them in `application.scss` (or alike) located there.
67
-
68
66
  ## Usage
69
67
 
70
68
  To render a **Bootstrap 5 expandable list group** you use `render(Bs5::ExpandableListGroupComponent.new)` and pass it a block for rendering every list item.
71
69
 
72
- Let's say, in the `index` action of your `PostsController`, you have assigned `@posts` that contains a list of `Post` instances. To render these `@posts` in a **Bootstrap 5 expandable list group**, you put the following code in your `index.html.erb` template:
70
+ Given that you have assigned a list of `Post` instances to `@posts`, to render these `@posts` in a **Bootstrap 5 expandable list group**, you put the following code in your template:
73
71
 
74
72
  ```erb
75
73
  <%= render(Bs5::ExpandableListGroupComponent.new) do |c| %>
@@ -131,7 +129,7 @@ To show one set:
131
129
  <% end %>
132
130
  <% i.actions do %>
133
131
  <%= link_to 'Delete', post, method: :delete, class: 'btn btn-sm btn-outline-danger' %>
134
- <%= link_to 'Edit', edit_post_path(post), class: 'btn btn-sm btn-outline-secondary' %>
132
+ <%= link_to 'Edit', edit_post_path(post), class: 'btn btn-sm btn-outline-secondary' %>
135
133
  <% end %>
136
134
  <%= i.body { ... } %>
137
135
  <% end %>
@@ -161,6 +159,28 @@ To show a different set on hovering:
161
159
  <% end %>
162
160
  ```
163
161
 
162
+ ### Omitting the `item` methods
163
+
164
+ Instead of using the `item`'s methods `title`, `body` and/or `actions` you can just use (HTML-) text as a block.
165
+ This will render just a [list group item](https://getbootstrap.com/docs/5.0/components/list-group/#basic-example), but will come in handy when you, i.e. show the first 25 items of a longer list and want to present a "Load more" link as last item of the list (for simplicity sake the sample uses a non-working `link_to_next_page` although this is [part of Kaminari](https://github.com/kaminari/kaminari#the-link_to_next_page-and-link_to_previous_page-aliased-to-link_to_prev_page-helper-methods)):
166
+
167
+ ```erb
168
+ <%= render(Bs5::ExpandableListGroupComponent.new) do |c| %>
169
+ <% @posts.each do |post| %>
170
+ <% c.item do |i| %>
171
+ <%= i.title { post.title } %>
172
+ <%= i.body { post.text } %>
173
+ <% end %>
174
+ <% end %>
175
+ <% if @companies.next_page %>
176
+ <% c.item %>
177
+ <%= link_to_next_page @posts "Load more" %>
178
+ <% end %>
179
+ <% end %>
180
+ <% end %>
181
+ ```
182
+
183
+
164
184
  ### Passing options
165
185
 
166
186
  The following options can be passed to `Bs5::ExpandableListGroupComponent.new`:
@@ -1,9 +1,15 @@
1
- <%= tag.div(class: "list-group-item expandable-item", data: component_data_options) do %>
2
- <div class="expandable-item-header">
3
- <%= title %>
4
- <%= actions %>
5
- </div>
6
- <%= tag.div(id: target_id, class: "expandable-item-body collapse", data: body_data_options) do %>
7
- <%= body %>
1
+
2
+ <% if simple_content? %>
3
+ <%= tag.div(content, class: "list-group-item") %>
4
+ <% else %>
5
+ <%= tag.div(class: "list-group-item expandable-item", data: component_data_options) do %>
6
+ <div class="expandable-item-header">
7
+ <%= title %>
8
+ <%= actions %>
9
+ </div>
10
+ <%= tag.div(id: target_id, class: "expandable-item-body collapse", data: body_data_options) do %>
11
+ <%= body %>
12
+ <% end %>
8
13
  <% end %>
9
14
  <% end %>
15
+
@@ -18,6 +18,10 @@ module Bs5
18
18
 
19
19
  private
20
20
 
21
+ def simple_content?
22
+ title.nil? && body.nil? && actions.nil?
23
+ end
24
+
21
25
  def target_id
22
26
  "expandable-list-item-#{object_id}"
23
27
  end
@@ -1,3 +1,3 @@
1
1
  module Bs5ExpandableListGroup
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bs5_expandable_list_group
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Baselier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-01 00:00:00.000000000 Z
11
+ date: 2021-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -129,7 +129,7 @@ licenses:
129
129
  metadata:
130
130
  homepage_uri: https://github.com/bazzel/Bs5ExpandableListGroup
131
131
  source_code_uri: https://github.com/bazzel/Bs5ExpandableListGroup
132
- changelog_uri: https://github.com/bazzel/Bs5ExpandableListGroup/CHANGELOG.md
132
+ changelog_uri: https://github.com/bazzel/Bs5ExpandableListGroup/blob/main/CHANGELOG.md
133
133
  post_install_message:
134
134
  rdoc_options: []
135
135
  require_paths: