bs5 0.0.11 → 0.0.12

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: 5d45e3e9d6c5303c22f72e3637abc45b8302a2834956d9213a3cbe3300320658
4
- data.tar.gz: 0c9d8ed8656a427932ba2fae5a49bb6f8110bd0a86d7af8a0f95020ae0cafd6f
3
+ metadata.gz: 74aab58d89e345e58ed93c1960217477600d6c0bb9c3e9af1dcb3b3542ec55f0
4
+ data.tar.gz: 79c1ddc04689b15bb773de0b99751045f30ffb101acd8ed62e8d816263723f8d
5
5
  SHA512:
6
- metadata.gz: 149b6ad2c77ad23fcef6c02d0a6e6b147dd32e0d1299807484233b207dc7280c90d3bf2fce397c02b64376478ace48bcc30aea57de654fa9ce0a6c4a715ccc7d
7
- data.tar.gz: 59471a7a2b75588e27d203e982ae52f1b1e54498ca0e26c6776bf7b5ef34166cbd7f644a80302f6ec1034b747b34f5b144d03bca836c07f84ba5808f3dbfa999
6
+ metadata.gz: 623342435dddb84001b2d70dfd1abc6cf6088b278d2f7c8deb0b11793778fcfcb7e531f5e6c32dcb18865ce918d5bb7a209496577ae486e85304e0d98fc590f3
7
+ data.tar.gz: ba822b14f63cce1ea2be57273aef6014618d1cdab09050a6e842ac8719bf68f7d40b5f04d8a27991f7905700fe35a30b75640d805460599242449b9b7d36cbf6
@@ -18,15 +18,7 @@ module Bs5
18
18
  @options = options
19
19
  @html_options = html_options
20
20
 
21
- if @name.is_a? Hash
22
- self.button_to_options = @name
23
- elsif @options.is_a? Hash
24
- self.button_to_options = @options
25
- else
26
- @html_options ||= {}
27
- self.button_to_options = @html_options
28
- end
29
-
21
+ set_button_to_options
30
22
  extract_custom_options
31
23
  merge_default_options
32
24
  end
@@ -45,6 +37,17 @@ module Bs5
45
37
 
46
38
  private
47
39
 
40
+ def set_button_to_options
41
+ if @name.is_a? Hash
42
+ self.button_to_options = @name
43
+ elsif @options.is_a? Hash
44
+ self.button_to_options = @options
45
+ else
46
+ @html_options ||= {}
47
+ self.button_to_options = @html_options
48
+ end
49
+ end
50
+
48
51
  def button_to_options=(hash)
49
52
  @button_to_options = hash.symbolize_keys!
50
53
  end
@@ -11,6 +11,15 @@ module Bs5
11
11
  end
12
12
  end
13
13
 
14
+ def bs5_tooltip(title, options = nil)
15
+ default_options = { toggle: :tooltip }
16
+ options = Hash(options).symbolize_keys.merge(default_options)
17
+ {
18
+ title: title,
19
+ data: options
20
+ }
21
+ end
22
+
14
23
  private
15
24
 
16
25
  def render_component(component_clazz, *args)
@@ -0,0 +1,2 @@
1
+ <h2>Tooltips</h2>
2
+ <%= render 'bs5/examples/tooltips/default/example' %>
@@ -8,6 +8,7 @@
8
8
  <li>Close button</li>
9
9
  <li>Breadcrumb</li>
10
10
  <li>Buttons</li>
11
+ <li>Tooltips</li>
11
12
  </ul>
12
13
  </div>
13
14
  </div>
@@ -19,5 +20,6 @@
19
20
  <%= render 'close_button' %>
20
21
  <%= render 'breadcrumb' %>
21
22
  <%= render 'buttons' %>
23
+ <%= render 'tooltips' %>
22
24
  </div>
23
25
  </div>
@@ -0,0 +1,4 @@
1
+ <h3>Default</h3>
2
+ <%= bs5_example(snippet: 'tooltips/default/snippet') %>
3
+ <%= bs5_example(snippet: 'tooltips/default/buttons') %>
4
+ <%= bs5_example(snippet: 'tooltips/default/disabled_elements') %>
@@ -0,0 +1,9 @@
1
+ <%= bs5_button_tag('Tooltip on top', bs5_tooltip('Tooltip on top', placement: :top).merge(style: :secondary)) %>
2
+
3
+ <%= bs5_button_tag('Tooltip on right', bs5_tooltip('Tooltip on right', placement: :right).merge(style: :secondary)) %>
4
+
5
+ <%= bs5_button_tag('Tooltip on bottom', bs5_tooltip('Tooltip on bottom', placement: :bottom).merge(style: :secondary)) %>
6
+
7
+ <%= bs5_button_tag('Tooltip on left', bs5_tooltip('Tooltip on left', placement: :left).merge(style: :secondary)) %>
8
+
9
+ <%= bs5_button_tag('Tooltip with HTML', bs5_tooltip('<em>Tooltip</em> <u>with</u> <b>HTML</b>', html: :true).merge(style: :secondary)) %>
@@ -0,0 +1,3 @@
1
+ <%= tag.span(bs5_tooltip('Disabled tooltip').merge(class: 'd-inline-block', tabindex: 0)) do %>
2
+ <%= bs5_button_tag('Disabled button', disabled: true) %>
3
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <p class="muted">
2
+ Tight pants next level keffiyeh <%= link_to('you probably', '#', bs5_tooltip('Default tooltip')) %> haven't heard of them.
3
+ Photo booth beard raw denim letterpress vegan messenger bag stumptown.
4
+ Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel <%= link_to('have a', '#', bs5_tooltip('Another tooltip')) %> terry richardson vinyl chambray.
5
+ Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray.
6
+ A really ironic artisan <%= link_to('whatever keytar', '#', bs5_tooltip('Another one here too')) %>, scenester farm-to-table banksy Austin <%= link_to('twitter handle', '#', bs5_tooltip('The last tip!')) %> freegan cred raw denim single-origin coffee viral.
7
+ </p>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bs5
4
- VERSION = '0.0.11'
4
+ VERSION = '0.0.12'
5
5
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Bs5
4
4
  class InstallGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('templates', __dir__)
6
+
5
7
  def add_bootstrap # rubocop:disable Metrics/MethodLength
6
8
  run 'yarn add bootstrap@next popper.js'
7
9
 
@@ -9,6 +11,16 @@ module Bs5
9
11
  @import "~bootstrap/scss/bootstrap";
10
12
  HEREDOC
11
13
 
14
+ copy_file 'bs5.js', 'app/javascript/bs5.js'
15
+
16
+ append_file 'app/javascript/packs/application.js', <<~HEREDOC
17
+ import * as bs5 from "bs5";
18
+
19
+ document.addEventListener("turbolinks:load", function () {
20
+ bs5.start();
21
+ });
22
+ HEREDOC
23
+
12
24
  inject_into_file 'app/views/layouts/application.html.erb', before: '</head>' do
13
25
  <<~HEREDOC
14
26
  <%= stylesheet_pack_tag 'styles', media: 'all', 'data-turbolinks-track': 'reload' %>
@@ -27,10 +39,6 @@ module Bs5
27
39
  HEREDOC
28
40
  end
29
41
 
30
- append_file 'app/javascript/packs/application.js', <<~HEREDOC
31
- import "bootstrap";
32
- HEREDOC
33
-
34
42
  gsub_file 'config/webpacker.yml', 'extract_css: false', 'extract_css: true'
35
43
  end
36
44
  end
@@ -0,0 +1,14 @@
1
+ import * as bootstrap from "bootstrap";
2
+
3
+ function tooltipify() {
4
+ const tooltipTriggerList = [].slice.call(
5
+ document.querySelectorAll('[data-toggle="tooltip"]')
6
+ );
7
+ tooltipTriggerList.map(function (tooltipTriggerEl) {
8
+ return new bootstrap.Tooltip(tooltipTriggerEl);
9
+ });
10
+ }
11
+
12
+ export function start() {
13
+ tooltipify();
14
+ }
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.11
4
+ version: 0.0.12
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-27 00:00:00.000000000 Z
11
+ date: 2020-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -153,6 +153,7 @@ files:
153
153
  - app/views/bs5/examples/_breadcrumb.html.erb
154
154
  - app/views/bs5/examples/_buttons.html.erb
155
155
  - app/views/bs5/examples/_close_button.html.erb
156
+ - app/views/bs5/examples/_tooltips.html.erb
156
157
  - app/views/bs5/examples/accordion/default/_example.html.erb
157
158
  - app/views/bs5/examples/accordion/default/snippet.html.erb
158
159
  - app/views/bs5/examples/accordion/flush/_example.html.erb
@@ -198,6 +199,10 @@ files:
198
199
  - app/views/bs5/examples/close_button/white/_example.html.erb
199
200
  - app/views/bs5/examples/close_button/white/snippet.html.erb
200
201
  - app/views/bs5/examples/index.html.erb
202
+ - app/views/bs5/examples/tooltips/default/_example.html.erb
203
+ - app/views/bs5/examples/tooltips/default/buttons.html.erb
204
+ - app/views/bs5/examples/tooltips/default/disabled_elements.html.erb
205
+ - app/views/bs5/examples/tooltips/default/snippet.html.erb
201
206
  - app/views/layouts/bs5/application.html.erb
202
207
  - config/definitions.rb
203
208
  - config/locales/en.yml
@@ -207,6 +212,7 @@ files:
207
212
  - lib/bs5/version.rb
208
213
  - lib/generators/bs5/install/USAGE
209
214
  - lib/generators/bs5/install/install_generator.rb
215
+ - lib/generators/bs5/install/templates/bs5.js
210
216
  - lib/tasks/bs5_tasks.rake
211
217
  - lib/tasks/ci.rake
212
218
  - lib/tasks/rubocop.rake