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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 284d8cf2918779c43bc9ad68ee5d7e34d0a6b88b518f1477afd8b1d8311f2b81
4
- data.tar.gz: c00f66ee4f7017135e24604d363bb9bfa02f3173d2f0bd7cc6eac60327b0afe2
3
+ metadata.gz: c244471d0787356eefa06399b40b2b04976031b8f8cf2e9f3f4963e4d21d9d33
4
+ data.tar.gz: ec849e00e61d79708ac48f7e4a9ab542a1db6f0cca8a1758080ffc67bf914ec9
5
5
  SHA512:
6
- metadata.gz: c0a1cbbc177318dbfbfcfdc8e196c02a49467288406c5ba9a38e338b0dffd33fa1e98a0c75235a997df031818779b65a8d811979e1f07335f0f4f63266651ef3
7
- data.tar.gz: 216f76b79299ac8e6f5a899db55420cbee4743f1fdafa7872ccacd6ae762d85080978a48b8cdc030c0e7a0ddccc4360545f5d8438ed86fab73afef6498d2c49a
6
+ metadata.gz: 509645eec227f7f356a587a5548a2f699bbae8529fc318d6a973503eadb2f67beb826f65404747d977e1fa354c00052f338f57b0e691875fd0c72ba5f0c57d4b
7
+ data.tar.gz: c50a9e77ba5d477464f3976e39e2fde7e4a8d6dfddcd79f3ef0b7599da80561740e3f6ae41429734c9dd3a4d2be572bbd2ddee3a6e07bfcbe20e11d181169149
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_accordion (0.1.11.pre.beta)
4
+ rails_accordion (0.1.12.pre.beta)
5
5
  stimulus-rails (~> 1.2)
6
6
  view_component (~> 2.52)
7
7
  zeitwerk (~> 2.6)
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.10.pre.beta'
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 (item.classList.contains("active")) {
19677
- this.hide(item);
19677
+ if (content.classList.contains("accordion_active")) {
19678
+ this.hide(content);
19678
19679
  } else {
19679
- this.hideAll(items);
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("active");
19690
- const content = item.querySelector(".accordion_content");
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("active");
19695
- const content = item.querySelector(".accordion_content");
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