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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a25801cb5cccc05129ddee20be6d7613b6861725540fc35762abeb9533da688e
|
4
|
+
data.tar.gz: 8404505ce4e166979bacd59621d8354e40db54c7a9e582c0187a31d5e9101625
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
+
|
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.
|
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-
|
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:
|