rails_accordion 0.1.11.pre.beta → 0.1.12.pre.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -1
- data/app/assets/builds/rails_accordion.css +5 -1
- data/app/assets/builds/rails_accordion.js +9 -13
- data/app/assets/builds/rails_accordion.js.map +2 -2
- data/app/assets/stylesheets/rails_accordion.css +5 -1
- data/app/components/item_component.rb +9 -1
- data/app/javascript/controllers/accordion_controller.js +9 -13
- data/lib/generators/rails_accordion/install_generator.rb +2 -2
- data/lib/generators/rails_accordion/templates/rails_accordion.tt +4 -0
- data/lib/rails_accordion/configuration.rb +22 -0
- data/lib/rails_accordion/version.rb +1 -1
- data/lib/rails_accordion.rb +2 -0
- data/vendor/assets/stylesheets/rails_accordion.css +8 -1
- metadata +3 -2
- data/lib/generators/rails_accordion/templates/accordion_controller.js.tt +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c244471d0787356eefa06399b40b2b04976031b8f8cf2e9f3f4963e4d21d9d33
|
4
|
+
data.tar.gz: ec849e00e61d79708ac48f7e4a9ab542a1db6f0cca8a1758080ffc67bf914ec9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 509645eec227f7f356a587a5548a2f699bbae8529fc318d6a973503eadb2f67beb826f65404747d977e1fa354c00052f338f57b0e691875fd0c72ba5f0c57d4b
|
7
|
+
data.tar.gz: c50a9e77ba5d477464f3976e39e2fde7e4a8d6dfddcd79f3ef0b7599da80561740e3f6ae41429734c9dd3a4d2be572bbd2ddee3a6e07bfcbe20e11d181169149
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -5,13 +5,17 @@ rails_accordion is a Ruby gem that provides an easy-to-use accordion component f
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
```rb
|
8
|
-
gem 'rails_accordion', '~> 0.1.
|
8
|
+
gem 'rails_accordion', '~> 0.1.12.pre.beta'
|
9
9
|
```
|
10
10
|
|
11
11
|
```shell
|
12
12
|
bundle install
|
13
13
|
```
|
14
14
|
|
15
|
+
```shell
|
16
|
+
rails generate rails_accordion:install
|
17
|
+
```
|
18
|
+
|
15
19
|
In config/importmap.rb, add:
|
16
20
|
|
17
21
|
```rb
|
@@ -23,6 +27,11 @@ And in app/javascript/application.js, add:
|
|
23
27
|
import 'rails_accordion'
|
24
28
|
```
|
25
29
|
|
30
|
+
in application.scss, add:
|
31
|
+
```scss
|
32
|
+
@import 'rails_accordion'
|
33
|
+
```
|
34
|
+
|
26
35
|
## Usage
|
27
36
|
|
28
37
|
```erb
|
@@ -518,10 +518,14 @@ video {
|
|
518
518
|
width: 100%;
|
519
519
|
overflow: hidden;
|
520
520
|
transition-property: all;
|
521
|
-
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
522
521
|
transition-duration: 300ms;
|
522
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
523
523
|
}
|
524
524
|
|
525
525
|
.accordion_toggle {
|
526
526
|
cursor: pointer;
|
527
527
|
}
|
528
|
+
|
529
|
+
.accordion_content-container {
|
530
|
+
height: max-content;
|
531
|
+
}
|
@@ -19672,30 +19672,26 @@
|
|
19672
19672
|
const items = this.element.querySelectorAll(".accordion_item");
|
19673
19673
|
items.forEach((item) => {
|
19674
19674
|
const toggle = item.querySelector(".accordion_toggle");
|
19675
|
+
const content = item.querySelector(".accordion_content");
|
19675
19676
|
toggle.addEventListener("click", (e) => {
|
19676
|
-
if (
|
19677
|
-
this.hide(
|
19677
|
+
if (content.classList.contains("accordion_active")) {
|
19678
|
+
this.hide(content);
|
19678
19679
|
} else {
|
19679
|
-
this.
|
19680
|
-
this.open(item);
|
19680
|
+
this.open(content);
|
19681
19681
|
}
|
19682
19682
|
});
|
19683
19683
|
});
|
19684
19684
|
}
|
19685
19685
|
hideAll(items) {
|
19686
|
-
items.forEach((item) => this.hide(item));
|
19686
|
+
items.forEach((item) => this.hide(item.querySelector(".accordion_content")));
|
19687
19687
|
}
|
19688
19688
|
hide(item) {
|
19689
|
-
item.classList.remove("
|
19690
|
-
|
19691
|
-
content.style.height = "0px";
|
19689
|
+
item.classList.remove("accordion_active");
|
19690
|
+
item.style.height = 0;
|
19692
19691
|
}
|
19693
19692
|
open(item) {
|
19694
|
-
item.classList.add("
|
19695
|
-
|
19696
|
-
content.style.height = "auto";
|
19697
|
-
const contentHeight = content.style.height;
|
19698
|
-
content.animate({ height: contentHeight + "px" }, 50);
|
19693
|
+
item.classList.add("accordion_active");
|
19694
|
+
item.style.height = item.scrollHeight + "px";
|
19699
19695
|
}
|
19700
19696
|
};
|
19701
19697
|
|