bs5 0.0.2 → 0.0.3

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: 37f7ba7e614cc623e4041e6caf107313059069c11915bcaaa0b00b2a95ad9810
4
- data.tar.gz: 7f150ed58e6820999d63483763cf17b4f836980acd7b6d63b3a3aef272d05067
3
+ metadata.gz: c59051b95e71e72c78e941b4fb15915dedfdf4e46564f83bfab206605c84fdc1
4
+ data.tar.gz: 7d0de3b478c43f569583b2df7937fdc83aa4264bbcf8bc222c3b3fd5f50a99e1
5
5
  SHA512:
6
- metadata.gz: 7f7c2230879f59f7743bc0b89d4fadf09ea9bf887cb8b0bb68bd1f8a9617123dc9a47f6a5d2ee783ce57d6a11a6457d3e3b4796ce146bb09d639d6c5fd9a4c8c
7
- data.tar.gz: 4a69710e2d7129473e5f0423dc27a7d359ee43982190d25f31e7da3167851f133ea3829a4151b75259b6717d29d9faa0bb1416eae31ea33813283139e5d00825
6
+ metadata.gz: 33d60944d67212152aab1a2e4880fe30fd44e8e9028e8ad227d437bab2b7c18780592b1cc5c4ce636cf9defeea7994c87a0edf311f3307d6dc0ebab7ae2bf301
7
+ data.tar.gz: 517cdbda7eff4f44f4db1b3e62679326c07465c0eb857105905e605ae8535b312fb096d97453b0e92a094431a56d9974cfb56a4a39937eab95a86ef6cba53b67
data/README.md CHANGED
@@ -36,20 +36,56 @@ Run the following command to setup your project to use Bootstrap 5.
36
36
 
37
37
  ## Components
38
38
 
39
- ### Alert 🖌
39
+ ### [Accordion](https://v5.getbootstrap.com/docs/5.0/components/accordion/)
40
40
 
41
41
  ```
42
- <%= render Bs5::AlertComponent.new do %>
42
+ <%= bs5_accordion do |accordion| %>
43
+ <% accordion.slot(:item, title: 'Accordion Item #1', collapsed: false) do %>
44
+ <strong>This is the first item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
45
+ <% end %>
46
+ <% accordion.slot(:item, title: 'Accordion Item #2') do %>
47
+ <strong>This is the second item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
48
+ <% end %>
49
+ <% accordion.slot(:item, title: 'Accordion Item #3') do %>
50
+ <strong>This is the third item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
51
+ <% end %>
52
+ <%- end %>
53
+ ```
54
+ ```
55
+ <%= bs5_accordion(flush: true) do |accordion| %>
56
+ <% accordion.slot(:item, title: 'Accordion Item #1') do %>
57
+ Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
58
+ <% end %>
59
+ <% accordion.slot(:item, title: 'Accordion Item #2') do %>
60
+ Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
61
+ <% end %>
62
+ <% accordion.slot(:item, title: 'Accordion Item #3') do %>
63
+ Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
64
+ <% end %>
65
+ <%- end %>
66
+ ```
67
+
68
+ ### [Alert](https://v5.getbootstrap.com/docs/5.0/components/alerts/) ✅
69
+
70
+ ```
71
+ <%= bs5_alert do %>
43
72
  A simple primary alert—check it out!
44
73
  <%- end %>
45
74
  ```
46
75
 
47
76
  ```
48
- <%= render Bs5::AlertComponent.new(type: :warning, is_dismissable: true) do %>
77
+ <%= bs5_alert(type: :warning, is_dismissable: true) do %>
49
78
  <strong>Holy guacamole!</strong> You should check in on some of those fields below.
50
79
  <%- end %>
51
80
  ```
52
81
 
82
+ ### [Badge](https://v5.getbootstrap.com/docs/5.0/components/badge/)
83
+
84
+ ### [Breadcrumb](https://v5.getbootstrap.com/docs/5.0/components/breadcrumb/)
85
+
86
+ ###[Button](https://v5.getbootstrap.com/docs/5.0/components/buttons/)
87
+
88
+
53
89
  ## Previewing components
54
90
 
55
91
  * http://localhost:3000/rails/view_components
@@ -0,0 +1,33 @@
1
+ <% if items.any? %>
2
+ <div class="<%= component_class %>" id="<%= id %>">
3
+ <% items.each do |item| %>
4
+ <div class="accordion-item">
5
+ <h2
6
+ id="<%= item.header_id %>"
7
+ class="accordion-header"
8
+ >
9
+ <button
10
+ class="<%= item.button_class %>"
11
+ type="button"
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>
19
+ </h2>
20
+ <div
21
+ id="<%= item.collapse_id %>"
22
+ class="<%= item.collapse_class %>"
23
+ aria-labelledby="<%= item.header_id %>"
24
+ data-parent="#<%= id %>"
25
+ >
26
+ <div class="accordion-body">
27
+ <%= item.content %>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ <% end %>
32
+ </div>
33
+ <% end %>
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bs5
4
+ class AccordionComponent < ViewComponent::Base
5
+ include ViewComponent::Slotable
6
+
7
+ with_slot :item, collection: true, class_name: 'Item'
8
+
9
+ def initialize(flush: false)
10
+ @flush = flush
11
+ end
12
+
13
+ def flush?
14
+ @flush
15
+ end
16
+
17
+ def id
18
+ "accordion-#{object_id}"
19
+ end
20
+
21
+ def component_class
22
+ class_names = ['accordion']
23
+ class_names << %w[accordion-flush] if flush?
24
+ class_names.join(' ')
25
+ end
26
+
27
+ class Item < ViewComponent::Slot
28
+ attr_reader :title
29
+
30
+ def initialize(title:, collapsed: true)
31
+ @title = title
32
+ @collapsed = collapsed
33
+ end
34
+
35
+ def id
36
+ object_id
37
+ end
38
+
39
+ def header_id
40
+ "header-#{id}"
41
+ end
42
+
43
+ def collapse_id
44
+ "collapse-#{id}"
45
+ end
46
+
47
+ def collapsed?
48
+ @collapsed
49
+ end
50
+
51
+ def button_class
52
+ class_names = ['accordion-button']
53
+ class_names << %w[collapsed] if collapsed?
54
+ class_names.join(' ')
55
+ end
56
+
57
+ def collapse_class
58
+ class_names = %w[accordion-collapse collapse]
59
+ class_names << %w[show] unless collapsed?
60
+ class_names.join(' ')
61
+ end
62
+ end
63
+ end
64
+ end
@@ -21,6 +21,10 @@ module Bs5
21
21
  raise errors.full_messages.to_sentence if invalid?
22
22
  end
23
23
 
24
+ def render?
25
+ content.present?
26
+ end
27
+
24
28
  private
25
29
 
26
30
  def component_class
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bs5
4
+ module ComponentsHelper
5
+ def bs5_alert(*args)
6
+ render AlertComponent.new(*args) do
7
+ yield if block_given?
8
+ end
9
+ end
10
+
11
+ def bs5_accordion(*args)
12
+ render AccordionComponent.new(*args) do |accordion|
13
+ yield accordion if block_given?
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bs5
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
@@ -14,6 +14,12 @@ class Bs5::InstallGenerator < Rails::Generators::Base
14
14
  HEREDOC
15
15
  end
16
16
 
17
+ inject_into_file 'app/controllers/application_controller.rb', after: "ActionController::Base\n" do
18
+ <<~HEREDOC
19
+ helper Bs5::Engine.helpers
20
+ HEREDOC
21
+ end
22
+
17
23
  append_file 'app/javascript/packs/application.js', <<~HEREDOC
18
24
  import "bootstrap";
19
25
  HEREDOC
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bs5
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Baselier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-15 00:00:00.000000000 Z
11
+ date: 2020-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -96,13 +96,15 @@ files:
96
96
  - MIT-LICENSE
97
97
  - README.md
98
98
  - Rakefile
99
- - app/CHANGELOG.md
100
99
  - app/assets/config/bs5_manifest.js
101
100
  - app/assets/stylesheets/bs5/application.css
101
+ - app/components/bs5/accordion_component.html.erb
102
+ - app/components/bs5/accordion_component.rb
102
103
  - app/components/bs5/alert_component.html.erb
103
104
  - app/components/bs5/alert_component.rb
104
105
  - app/controllers/bs5/application_controller.rb
105
106
  - app/helpers/bs5/application_helper.rb
107
+ - app/helpers/bs5/components_helper.rb
106
108
  - app/jobs/bs5/application_job.rb
107
109
  - app/mailers/bs5/application_mailer.rb
108
110
  - app/models/bs5/application_record.rb
@@ -1,13 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [Unreleased]
9
-
10
- ### Added
11
-
12
- - Add generator for installing `bs5`.
13
- - Add ViewComponent for Alert component.