bs5 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f868555ef8de05ff2a59b42efd77e1e43a4322d896ba468075131178f0dc1a7
4
- data.tar.gz: adbcd1e63ac16714e3b4ee5c5d72266fe687685449b08dbf87aa3b0ea359a8a7
3
+ metadata.gz: ba1fb14f4e08a3c9b6e8196fd306954c3e2bbe5e7f074ff018dbcf5adb9554cb
4
+ data.tar.gz: c7d797b046934929781283e825fcb74b3e9780faf544ce92dd2ca1b38cfbc60f
5
5
  SHA512:
6
- metadata.gz: 46c4e2e6bcb0d65824c993daea510e230c891e3bf7808ed98bbbf9d57997c36b5d01b83864cda9e4bcfa26b6aaff2460ab7d3c153510f852e8c526b58855481b
7
- data.tar.gz: 43a3f21f7527666fd7499a1e05d14f442976e9a1465f8a4f91d1e3b967f5eb3cff1a0bb8a42c9e4efd8486710039e723c03369df33a28236b83d36bdb26a6a00
6
+ metadata.gz: f11d2a95bc6dcfe8539feeb6eba85eaa873096c0cf725aa4d800b72f86e29c39817ae867739422f549f0c3a6be0b1f378de57e8d2e03ae62daa5d4594de6ee64
7
+ data.tar.gz: 1de41edf38036562b6fde14f20242926d557344875a4efdfc5a552d9a8cf7d2cc5d68fbe9cd2d815178fb2ae75f57a13be92aaf72fd9c19416ba8ee214967a4a
@@ -11,13 +11,12 @@ 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
- }
14
+ def bs5_tooltip(*args)
15
+ TooltipService.new(*args).to_hash
16
+ end
17
+
18
+ def bs5_popover(*args)
19
+ PopoverService.new(*args).to_hash
21
20
  end
22
21
 
23
22
  def bs5_collapse(*args)
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Bs5
4
4
  class CollapseService
5
+ using HashRefinement
6
+
5
7
  CONTROLS_ERR_MSG = 'Please provide either a `controls` option' \
6
8
  ' containing the id of the collapsible element' \
7
9
  ' or an ID selector as `target` options.'
@@ -24,10 +26,10 @@ module Bs5
24
26
  private
25
27
 
26
28
  def data_options
27
- options = { 'bs-toggle': :collapse }
28
- options[:'bs-target'] = target if target
29
+ options = { toggle: :collapse }
30
+ options[:target] = target if target
29
31
 
30
- options
32
+ options.prefix_keys_with_bs
31
33
  end
32
34
 
33
35
  def aria_options
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bs5
4
+ class PopoverService
5
+ using HashRefinement
6
+
7
+ attr_reader :title
8
+
9
+ def initialize(options = {})
10
+ @title = options.delete(:title)
11
+ @options = options
12
+ end
13
+
14
+ def to_hash
15
+ {
16
+ title: title,
17
+ data: options
18
+ }.compact
19
+ end
20
+
21
+ private
22
+
23
+ def options
24
+ @options.symbolize_keys.merge(default_options).prefix_keys_with_bs
25
+ end
26
+
27
+ def default_options
28
+ { toggle: :popover }
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bs5
4
+ class TooltipService
5
+ using HashRefinement
6
+
7
+ attr_reader :title
8
+
9
+ def initialize(title, options = {})
10
+ @title = title
11
+ @options = options
12
+ end
13
+
14
+ def to_hash
15
+ {
16
+ title: title,
17
+ data: options
18
+ }
19
+ end
20
+
21
+ private
22
+
23
+ def options
24
+ @options.symbolize_keys.merge(default_options).prefix_keys_with_bs
25
+ end
26
+
27
+ def default_options
28
+ { toggle: :tooltip }
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,2 @@
1
+ <h2>Example</h2>
2
+ <%= bs5_example(snippet: 'popovers/default/snippet') %>
@@ -0,0 +1 @@
1
+ <%= bs5_button_tag('Click to toggle popover', bs5_popover(title: 'Popover title', content: "And here's some amazing content. It's very engaging. Right?").merge(type: 'button', style: :danger, size: :large)) %>
@@ -0,0 +1,2 @@
1
+ <h2>Disabled elements</h2>
2
+ <%= bs5_example(snippet: 'popovers/disabled_elements/snippet') %>
@@ -0,0 +1,3 @@
1
+ <%= tag.span(bs5_popover(content: 'Disabled popover').merge(class: 'd-inline-block')) do %>
2
+ <%= bs5_button_tag('Disabled button', disabled: true) %>
3
+ <% end %>
@@ -0,0 +1,2 @@
1
+ <h2>Dismissable on next click</h2>
2
+ <%= bs5_example(snippet: 'popovers/dismissable_on_next_click/snippet') %>
@@ -0,0 +1 @@
1
+ <%= tag.a 'Dismissible popover', bs5_popover(title: 'Dismissible popover', content: "And here's some amazing content. It's very engaging. Right?", trigger: :focus).merge(class: 'btn btn-lg btn-danger', role: :button, tabindex: 0) %>
@@ -0,0 +1,2 @@
1
+ <h2>Four directions</h2>
2
+ <%= bs5_example(snippet: 'popovers/four_directions/snippet') %>
@@ -0,0 +1,7 @@
1
+ <%= bs5_button_tag('Popover on top', bs5_popover(content: "Vivamus sagittis lacus vel augue laoreet rutrum faucibus.", container: :body, placement: :top).merge(type: 'button', style: :secondary)) %>
2
+
3
+ <%= bs5_button_tag('Popover on right', bs5_popover(content: "Vivamus sagittis lacus vel augue laoreet rutrum faucibus.", container: :body, placement: :right).merge(type: 'button', style: :secondary)) %>
4
+
5
+ <%= bs5_button_tag('Popover on bottom', bs5_popover(content: "Vivamus sagittis lacus vel augue laoreet rutrum faucibus.", container: :body, placement: :bottom).merge(type: 'button', style: :secondary)) %>
6
+
7
+ <%= bs5_button_tag('Popover on left', bs5_popover(content: "Vivamus sagittis lacus vel augue laoreet rutrum faucibus.", container: :body, placement: :left).merge(type: 'button', style: :secondary)) %>
@@ -0,0 +1,2 @@
1
+ <h1>Popovers</h1>
2
+ <%= render 'bs5/examples/popovers/default/example' %>
@@ -21,6 +21,7 @@
21
21
  <% lg.slot(:item, active: current_page?(pages_path('close_button'))) do %><%= link_to 'Close button', pages_path('close_button') %><% end %>
22
22
  <% lg.slot(:item, active: current_page?(pages_path('collapse'))) do %><%= link_to 'Collapse', pages_path('collapse') %><% end %>
23
23
  <% lg.slot(:item, active: current_page?(pages_path('list_group'))) do %><%= link_to 'List group', pages_path('list_group') %><% end %>
24
+ <% lg.slot(:item, active: current_page?(pages_path('popovers'))) do %><%= link_to 'Popovers', pages_path('popovers') %><% end %>
24
25
  <% lg.slot(:item, active: current_page?(pages_path('tooltips'))) do %><%= link_to 'Tooltips', pages_path('tooltips') %><% end %>
25
26
  <%- end %>
26
27
  </div>
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HashRefinement
4
+ refine Hash do
5
+ def prefix_keys_with_bs
6
+ transform_keys! { |k| "bs_#{k}".to_sym }
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bs5
4
- VERSION = '0.0.15'
4
+ VERSION = '0.0.16'
5
5
  end
@@ -2,13 +2,23 @@ import * as bootstrap from "bootstrap";
2
2
 
3
3
  function tooltipify() {
4
4
  const tooltipTriggerList = [].slice.call(
5
- document.querySelectorAll('[data-toggle="tooltip"]')
5
+ document.querySelectorAll('[data-bs-toggle="tooltip"]')
6
6
  );
7
7
  tooltipTriggerList.map(function (tooltipTriggerEl) {
8
8
  return new bootstrap.Tooltip(tooltipTriggerEl);
9
9
  });
10
10
  }
11
11
 
12
+ function popoverify() {
13
+ const popoverTriggerList = [].slice.call(
14
+ document.querySelectorAll('[data-bs-toggle="popover"]')
15
+ );
16
+ popoverTriggerList.map(function (popoverTriggerEl) {
17
+ return new bootstrap.Popover(popoverTriggerEl);
18
+ });
19
+ }
20
+
12
21
  export function start() {
22
+ popoverify();
13
23
  tooltipify();
14
24
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bs5
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Baselier
@@ -163,6 +163,8 @@ files:
163
163
  - app/helpers/bs5/examples_helper.rb
164
164
  - app/models/bs5/application_record.rb
165
165
  - app/service/bs5/collapse_service.rb
166
+ - app/service/bs5/popover_service.rb
167
+ - app/service/bs5/tooltip_service.rb
166
168
  - app/validators/style_validator.rb
167
169
  - app/views/bs5/examples/accordion/default/_example.html.erb
168
170
  - app/views/bs5/examples/accordion/default/snippet.html.erb
@@ -234,6 +236,14 @@ files:
234
236
  - app/views/bs5/examples/list_group/style/default.html.erb
235
237
  - app/views/bs5/examples/list_group/with_badges/_example.html.erb
236
238
  - app/views/bs5/examples/list_group/with_badges/default.html.erb
239
+ - app/views/bs5/examples/popovers/default/_example.html.erb
240
+ - app/views/bs5/examples/popovers/default/snippet.html.erb
241
+ - app/views/bs5/examples/popovers/disabled_elements/_example.html.erb
242
+ - app/views/bs5/examples/popovers/disabled_elements/snippet.html.erb
243
+ - app/views/bs5/examples/popovers/dismissable_on_next_click/_example.html.erb
244
+ - app/views/bs5/examples/popovers/dismissable_on_next_click/snippet.html.erb
245
+ - app/views/bs5/examples/popovers/four_directions/_example.html.erb
246
+ - app/views/bs5/examples/popovers/four_directions/snippet.html.erb
237
247
  - app/views/bs5/examples/tooltips/default/_example.html.erb
238
248
  - app/views/bs5/examples/tooltips/default/buttons.html.erb
239
249
  - app/views/bs5/examples/tooltips/default/disabled_elements.html.erb
@@ -246,10 +256,12 @@ files:
246
256
  - app/views/bs5/pages/close_button.html.erb
247
257
  - app/views/bs5/pages/collapse.html.erb
248
258
  - app/views/bs5/pages/list_group.html.erb
259
+ - app/views/bs5/pages/popovers.html.erb
249
260
  - app/views/bs5/pages/tooltips.html.erb
250
261
  - app/views/layouts/bs5/application.html.erb
251
262
  - app/views/layouts/bs5/pages.html.erb
252
263
  - config/definitions.rb
264
+ - config/initializers/hash_refinement.rb
253
265
  - config/locales/en.yml
254
266
  - config/routes.rb
255
267
  - lib/bs5.rb