bs5 0.0.20 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/bs5_manifest.js +1 -0
  3. data/app/assets/javascripts/bs5/application.js +13 -0
  4. data/app/components/bs5/alert_component.html.erb +1 -1
  5. data/app/components/bs5/alert_component.rb +1 -0
  6. data/app/components/bs5/button_tag_component.rb +10 -1
  7. data/app/components/bs5/close_button_component.rb +14 -6
  8. data/app/components/bs5/example_component.html.erb +2 -1
  9. data/app/components/bs5/toast/body_component.html.erb +3 -0
  10. data/app/components/bs5/toast/body_component.rb +8 -0
  11. data/app/components/bs5/toast/header_component.html.erb +4 -0
  12. data/app/components/bs5/toast/header_component.rb +9 -0
  13. data/app/components/bs5/toast_component.html.erb +8 -0
  14. data/app/components/bs5/toast_component.rb +72 -0
  15. data/app/components/bs5/toast_container_component.html.erb +3 -0
  16. data/app/components/bs5/toast_container_component.rb +19 -0
  17. data/app/helpers/bs5/components_helper.rb +1 -1
  18. data/app/views/bs5/examples/toasts/color_schemes/_example.html.erb +2 -0
  19. data/app/views/bs5/examples/toasts/color_schemes/snippet.html.erb +33 -0
  20. data/app/views/bs5/examples/toasts/custom_content/_example.html.erb +3 -0
  21. data/app/views/bs5/examples/toasts/custom_content/snippet1.html.erb +3 -0
  22. data/app/views/bs5/examples/toasts/custom_content/snippet2.html.erb +9 -0
  23. data/app/views/bs5/examples/toasts/default/_example.html.erb +2 -0
  24. data/app/views/bs5/examples/toasts/default/snippet.html.erb +17 -0
  25. data/app/views/bs5/examples/toasts/js_options/_example.html.erb +2 -0
  26. data/app/views/bs5/examples/toasts/js_options/snippet.html.erb +23 -0
  27. data/app/views/bs5/examples/toasts/placement/_example.html.erb +3 -0
  28. data/app/views/bs5/examples/toasts/placement/snippet1.html.erb +44 -0
  29. data/app/views/bs5/examples/toasts/placement/snippet2.html.erb +24 -0
  30. data/app/views/bs5/examples/toasts/stacking/_example.html.erb +2 -0
  31. data/app/views/bs5/examples/toasts/stacking/snippet.html.erb +37 -0
  32. data/app/views/bs5/pages/toasts.html.erb +7 -0
  33. data/app/views/layouts/bs5/pages.html.erb +2 -0
  34. data/lib/bs5/engine.rb +6 -0
  35. data/lib/bs5/version.rb +1 -1
  36. data/lib/generators/bs5/install/templates/bs5.js +24 -13
  37. data/lib/tasks/rubocop.rake +2 -0
  38. metadata +26 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a10864e2e8d54471af721b35c4cee8710a704ddeb49e54c71296d68acf695ca
4
- data.tar.gz: b058adbe641f350fecb63df04974e81c9685de959aae26a00f5ca6b081662f35
3
+ metadata.gz: 93ea7a16c5cb16edd48cabe938083b466af2171b895c9bfb7ca3da0e7bd9cf6a
4
+ data.tar.gz: 35bb524562a071eaf46e05da49b951e1606b27524f6e242d10be7a5cb6a4eeca
5
5
  SHA512:
6
- metadata.gz: 94b73504ea5d6227856deb460dd5feefc763fa5eeeb177a4d4274af42f1a84fded595763bfeff7d0e65df736ee8934187dc76fa4a049313b83108f3d5ab0f47f
7
- data.tar.gz: 6242ebac4cd0789d8bf2d6e66adc431dd081fda8381c186ccc039bc5f9bc0d9ac737501426ff8d1252c5a9ecb63e3c2b1e8e404ca7f5e8f0fd3c89f192872a01
6
+ metadata.gz: 011e84f5073b6cd7c6d9b3d2de76f077fedaeaa87f0e8c2aba6efa48457ffe271e8f3d589ec2b2d59eacccdf0a088e968921f3db682c1a846acb94e6ea7c2815
7
+ data.tar.gz: 66f86657bfd99ce53af4ea76123b72eed77454ed885b8c033a16fe6e579b67d20be9aa187a982687c80a80e49921577e107b249d081a8fa538b6bdbbef7080fc
@@ -1 +1,2 @@
1
1
  //= link_directory ../stylesheets/bs5 .css
2
+ //= link_directory ../javascripts/bs5 .js
@@ -0,0 +1,13 @@
1
+ window.addEventListener("load", initBs5);
2
+ window.addEventListener("turbolinks:load", initBs5);
3
+
4
+ function initBs5(event) {
5
+ document.querySelectorAll('[data-bs5="copy"]').forEach(function (item) {
6
+ item.addEventListener("click", handleBs5CopyButtonClick);
7
+ });
8
+ }
9
+
10
+ function handleBs5CopyButtonClick(event) {
11
+ var code = event.target.closest("div").querySelector("code").innerText;
12
+ navigator.clipboard.writeText(code);
13
+ }
@@ -1,6 +1,6 @@
1
1
  <div class="<%= component_class %>" role="alert">
2
2
  <%= content %>
3
3
  <%- if is_dismissable %>
4
- <%= render Bs5::CloseButtonComponent.new(data: { 'bs-dismiss': :alert }) %>
4
+ <%= bs5_close_button(dismiss: :alert) %>
5
5
  <%- end %>
6
6
  </div>
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Bs5
4
4
  class AlertComponent < ViewComponent::Base
5
+ include ComponentsHelper
5
6
  STYLES = %i[primary secondary success danger warning info light dark].freeze
6
7
 
7
8
  attr_reader :color, :is_dismissable
@@ -47,6 +47,7 @@ module Bs5
47
47
  extract_color
48
48
  extract_outline
49
49
  extract_size
50
+ extract_dismiss
50
51
  end
51
52
 
52
53
  def extract_color
@@ -61,6 +62,10 @@ module Bs5
61
62
  @size = @options.delete(:size)
62
63
  end
63
64
 
65
+ def extract_dismiss
66
+ @dismiss = @options.delete(:dismiss)
67
+ end
68
+
64
69
  def merge_default_options
65
70
  @options.deep_merge!(default_options) do |_key, this_val, other_val|
66
71
  [this_val, other_val].join(' ').strip
@@ -68,7 +73,11 @@ module Bs5
68
73
  end
69
74
 
70
75
  def default_options
71
- { class: button_class }
76
+ default_options = { class: button_class }
77
+
78
+ default_options[:data] = { 'bs-dismiss': @dismiss } if @dismiss
79
+
80
+ default_options
72
81
  end
73
82
 
74
83
  def button_class
@@ -2,12 +2,19 @@
2
2
 
3
3
  module Bs5
4
4
  class CloseButtonComponent < ViewComponent::Base
5
- attr_reader :data
5
+ def initialize(options = {})
6
+ @options = options.symbolize_keys
6
7
 
7
- def initialize(disabled: false, white: false, data: nil)
8
- @disabled = disabled
9
- @white = white
10
- @data = data
8
+ @disabled = options.delete(:disabled)
9
+ @white = options.delete(:white)
10
+ @dismiss = options.delete(:dismiss)
11
+ @data = options.fetch(:data, {})
12
+ end
13
+
14
+ def data
15
+ @data['bs-dismiss'] = @dismiss if @dismiss
16
+
17
+ @data
11
18
  end
12
19
 
13
20
  private
@@ -21,7 +28,8 @@ module Bs5
21
28
  end
22
29
 
23
30
  def component_class
24
- class_names = ['btn-close']
31
+ class_names = Array(@options[:class])
32
+ class_names << 'btn-close'
25
33
  class_names << %w[btn-close-white] if white?
26
34
  class_names.join(' ')
27
35
  end
@@ -2,7 +2,8 @@
2
2
  <div class="border rounded-2 p-4">
3
3
  <%= render template: snippet %>
4
4
  </div>
5
- <div class="highlight p-4">
5
+ <div class="highlight p-4 position-relative">
6
+ <%= bs5_button_tag('Copy', color: :primary, outline: true, size: :small, class: 'position-absolute top-0 end-0 mt-2 me-2', data: { bs5: 'copy' }) %>
6
7
  <pre class='mb-0'><code><%= highlight %></code></pre>
7
8
  </div>
8
9
  </div>
@@ -0,0 +1,3 @@
1
+ <div class="toast-body">
2
+ <%= content %>
3
+ </div>
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bs5
4
+ module Toast
5
+ class BodyComponent < ViewComponent::Base
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ <div class="toast-header">
2
+ <%= content %>
3
+ <%= bs5_close_button(dismiss: :toast) %>
4
+ </div>
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bs5
4
+ module Toast
5
+ class HeaderComponent < ViewComponent::Base
6
+ include ComponentsHelper
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ <%= tag.div(component_attributes) do %>
2
+ <%= header %>
3
+ <%= body %>
4
+
5
+ <%- if close_button? && !header? %>
6
+ <%= bs5_close_button(white: white_text?, class: 'ms-auto me-2', dismiss: :toast) %>
7
+ <% end %>
8
+ <% end %>
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bs5
4
+ class ToastComponent < ViewComponent::Base
5
+ include ViewComponent::SlotableV2
6
+ include ComponentsHelper
7
+ using HashRefinement
8
+
9
+ attr_reader :color
10
+
11
+ renders_one :header, Bs5::Toast::HeaderComponent
12
+ renders_one :body, Bs5::Toast::BodyComponent
13
+
14
+ def initialize(options = {})
15
+ @options = options.symbolize_keys
16
+ @color = @options.delete(:color)
17
+ @close_button = @options.fetch(:close_button, true)
18
+ @data_options = @options.extract!(:animation, :autohide, :delay)
19
+ end
20
+
21
+ def header?
22
+ !!header
23
+ end
24
+
25
+ def component_attributes
26
+ default_options = {
27
+ role: :alert,
28
+ aria: { live: 'assertive', atomic: true },
29
+ data: data_options
30
+ }
31
+
32
+ @options[:class] = component_class
33
+
34
+ @options.merge(default_options)
35
+ end
36
+
37
+ def white_text?
38
+ color? && color.in?(%i[primary secondary success danger dark])
39
+ end
40
+
41
+ private
42
+
43
+ def data_options
44
+ @data_options.prefix_keys_with_bs
45
+ end
46
+
47
+ def component_class
48
+ class_names = Array(@options[:class])
49
+ class_names << 'toast'
50
+ class_names << contextual_class
51
+ class_names.compact.join(' ')
52
+ end
53
+
54
+ def contextual_class
55
+ return unless color?
56
+
57
+ class_names = ['border-0']
58
+ class_names << "bg-#{color}"
59
+ class_names << 'text-white' if white_text?
60
+
61
+ class_names
62
+ end
63
+
64
+ def color?
65
+ !!color
66
+ end
67
+
68
+ def close_button?
69
+ @close_button
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,3 @@
1
+ <div class="<%= component_class %>"">
2
+ <%= content %>
3
+ </div>
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bs5
4
+ class ToastContainerComponent < ViewComponent::Base
5
+ def initialize(options = {})
6
+ @options = options.symbolize_keys
7
+ end
8
+
9
+ def component_class
10
+ class_names = Array(@options[:class])
11
+ class_names << 'toast-container'
12
+ class_names.compact.join(' ')
13
+ end
14
+
15
+ def render?
16
+ content.present?
17
+ end
18
+ end
19
+ end
@@ -3,7 +3,7 @@
3
3
  module Bs5
4
4
  module ComponentsHelper
5
5
  COMPONENTS = %w[accordion alert badge close_button breadcrumb button_group button_tag button_to button_toolbar
6
- list_group spinner].freeze
6
+ list_group spinner toast toast_container].freeze
7
7
 
8
8
  COMPONENTS.each do |name|
9
9
  define_method("bs5_#{name}") do |*args, &block|
@@ -0,0 +1,2 @@
1
+ <h2>Color schemes</h2>
2
+ <%= bs5_example(snippet: 'toasts/color_schemes/snippet') %>
@@ -0,0 +1,33 @@
1
+ <%= bs5_toast_container do %>
2
+ <%= bs5_toast(color: :primary, class: 'd-flex align-items-center') do |t| %>
3
+ <%= t.body do %>Hello, world! This is a toast message.<% end %>
4
+ <% end %>
5
+
6
+ <%= bs5_toast(color: :secondary, class: 'd-flex align-items-center') do |t| %>
7
+ <%= t.body do %>Hello, world! This is a toast message.<% end %>
8
+ <% end %>
9
+
10
+ <%= bs5_toast(color: :success, class: 'd-flex align-items-center') do |t| %>
11
+ <%= t.body do %>Hello, world! This is a toast message.<% end %>
12
+ <% end %>
13
+
14
+ <%= bs5_toast(color: :danger, class: 'd-flex align-items-center') do |t| %>
15
+ <%= t.body do %>Hello, world! This is a toast message.<% end %>
16
+ <% end %>
17
+
18
+ <%= bs5_toast(color: :warning, class: 'd-flex align-items-center') do |t| %>
19
+ <%= t.body do %>Hello, world! This is a toast message.<% end %>
20
+ <% end %>
21
+
22
+ <%= bs5_toast(color: :info, class: 'd-flex align-items-center') do |t| %>
23
+ <%= t.body do %>Hello, world! This is a toast message.<% end %>
24
+ <% end %>
25
+
26
+ <%= bs5_toast(color: :light, class: 'd-flex align-items-center') do |t| %>
27
+ <%= t.body do %>Hello, world! This is a toast message.<% end %>
28
+ <% end %>
29
+
30
+ <%= bs5_toast(color: :dark, class: 'd-flex align-items-center') do |t| %>
31
+ <%= t.body do %>Hello, world! This is a toast message.<% end %>
32
+ <% end %>
33
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <h2>Custom content</h2>
2
+ <%= bs5_example(snippet: 'toasts/custom_content/snippet1') %>
3
+ <%= bs5_example(snippet: 'toasts/custom_content/snippet2') %>
@@ -0,0 +1,3 @@
1
+ <%= bs5_toast(class: 'd-flex align-items-center') do |t| %>
2
+ <%= t.body do %>Hello, world! This is a toast message.<% end %>
3
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <%= bs5_toast(close_button: false) do |t| %>
2
+ <%= t.body do %>
3
+ Hello, world! This is a toast message.
4
+ <div class="mt-2 pt-2 border-top">
5
+ <%= bs5_button_tag('Take action', color: :primary, size: :small) %>
6
+ <%= bs5_button_tag('Close', color: :secondary, size: :small, dismiss: :toast) %>
7
+ </div>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,2 @@
1
+ <h2>Default</h2>
2
+ <%= bs5_example(snippet: 'toasts/default/snippet') %>
@@ -0,0 +1,17 @@
1
+ <%= bs5_toast do |t| %>
2
+ <%= t.header do %>
3
+ <svg
4
+ class="bd-placeholder-img rounded me-2"
5
+ width="20"
6
+ height="20"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ aria-hidden="true"
9
+ focusable="false"
10
+ >
11
+ <rect width="100%" height="100%" fill="#007aff"></rect>
12
+ </svg>
13
+ <strong class="me-auto">Bootstrap</strong>
14
+ <small>11 mins ago</small>
15
+ <% end %>
16
+ <%= t.body do %>Hello, world! This is a toast message.<% end %>
17
+ <% end %>
@@ -0,0 +1,2 @@
1
+ <h2>Options</h2>
2
+ <%= bs5_example(snippet: 'toasts/js_options/snippet') %>
@@ -0,0 +1,23 @@
1
+ <%= bs5_toast_container do %>
2
+ <%= bs5_toast(autohide: true, delay: 10_000, animation: false) do |t| %>
3
+ <%= t.header do %>
4
+ <svg
5
+ class="bd-placeholder-img rounded me-2"
6
+ width="20"
7
+ height="20"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ aria-hidden="true"
10
+ focusable="false"
11
+ >
12
+ <rect width="100%" height="100%" fill="#007aff"></rect>
13
+ </svg>
14
+ <strong class="me-auto">Bootstrap</strong>
15
+ <small>11 mins ago</small>
16
+ <% end %>
17
+ <%= t.body do %>Hello, world! This is a toast message.<% end %>
18
+ <% end %>
19
+
20
+ <%= bs5_toast(close_button: false, autohide: true, delay: 11_000) do |t| %>
21
+ <%= t.body do %>Hello, world! This is a toast message.<% end %>
22
+ <% end %>
23
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <h2>Placement</h2>
2
+ <%= bs5_example(snippet: 'toasts/placement/snippet1') %>
3
+ <%= bs5_example(snippet: 'toasts/placement/snippet2') %>
@@ -0,0 +1,44 @@
1
+ <div
2
+ aria-live="polite"
3
+ aria-atomic="true"
4
+ class="position-relative"
5
+ style="min-height: 240px"
6
+ >
7
+ <%= bs5_toast_container(class: 'position-absolute top-0 end-0') do %>
8
+ <%= bs5_toast do |t| %>
9
+ <%= t.header do %>
10
+ <svg
11
+ class="bd-placeholder-img rounded me-2"
12
+ width="20"
13
+ height="20"
14
+ xmlns="http://www.w3.org/2000/svg"
15
+ aria-hidden="true"
16
+ focusable="false"
17
+ >
18
+ <rect width="100%" height="100%" fill="#007aff"></rect>
19
+ </svg>
20
+ <strong class="me-auto">Bootstrap</strong>
21
+ <small>just now</small>
22
+ <% end %>
23
+ <%= t.body do %>See? Just like this.<% end %>
24
+ <% end %>
25
+
26
+ <%= bs5_toast do |t| %>
27
+ <%= t.header do %>
28
+ <svg
29
+ class="bd-placeholder-img rounded me-2"
30
+ width="20"
31
+ height="20"
32
+ xmlns="http://www.w3.org/2000/svg"
33
+ aria-hidden="true"
34
+ focusable="false"
35
+ >
36
+ <rect width="100%" height="100%" fill="#007aff"></rect>
37
+ </svg>
38
+ <strong class="me-auto">Bootstrap</strong>
39
+ <small>2 seconds ago</small>
40
+ <% end %>
41
+ <%= t.body do %>Heads up, toasts will stack automatically<% end %>
42
+ <% end %>
43
+ <% end %>
44
+ </div>
@@ -0,0 +1,24 @@
1
+ <div
2
+ aria-live="polite"
3
+ aria-atomic="true"
4
+ class="d-flex justify-content-center align-items-center w-100"
5
+ style="min-height: 240px"
6
+ >
7
+ <%= bs5_toast do |t| %>
8
+ <%= t.header do %>
9
+ <svg
10
+ class="bd-placeholder-img rounded me-2"
11
+ width="20"
12
+ height="20"
13
+ xmlns="http://www.w3.org/2000/svg"
14
+ aria-hidden="true"
15
+ focusable="false"
16
+ >
17
+ <rect width="100%" height="100%" fill="#007aff"></rect>
18
+ </svg>
19
+ <strong class="me-auto">Bootstrap</strong>
20
+ <small>11 mins ago</small>
21
+ <% end %>
22
+ <%= t.body do %>Hello, world! This is a toast message.<% end %>
23
+ <% end %>
24
+ </div>
@@ -0,0 +1,2 @@
1
+ <h2>Stacking</h2>
2
+ <%= bs5_example(snippet: 'toasts/stacking/snippet') %>
@@ -0,0 +1,37 @@
1
+ <%= bs5_toast_container do %>
2
+ <%= bs5_toast do |t| %>
3
+ <%= t.header do %>
4
+ <svg
5
+ class="bd-placeholder-img rounded me-2"
6
+ width="20"
7
+ height="20"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ aria-hidden="true"
10
+ focusable="false"
11
+ >
12
+ <rect width="100%" height="100%" fill="#007aff"></rect>
13
+ </svg>
14
+ <strong class="me-auto">Bootstrap</strong>
15
+ <small>just now</small>
16
+ <% end %>
17
+ <%= t.body do %>See? Just like this.<% end %>
18
+ <% end %>
19
+
20
+ <%= bs5_toast do |t| %>
21
+ <%= t.header do %>
22
+ <svg
23
+ class="bd-placeholder-img rounded me-2"
24
+ width="20"
25
+ height="20"
26
+ xmlns="http://www.w3.org/2000/svg"
27
+ aria-hidden="true"
28
+ focusable="false"
29
+ >
30
+ <rect width="100%" height="100%" fill="#007aff"></rect>
31
+ </svg>
32
+ <strong class="me-auto">Bootstrap</strong>
33
+ <small>2 seconds ago</small>
34
+ <% end %>
35
+ <%= t.body do %>Heads up, toasts will stack automatically<% end %>
36
+ <% end %>
37
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <h1>Toasts</h1>
2
+ <%= render 'bs5/examples/toasts/default/example' %>
3
+ <%= render 'bs5/examples/toasts/stacking/example' %>
4
+ <%= render 'bs5/examples/toasts/custom_content/example' %>
5
+ <%= render 'bs5/examples/toasts/color_schemes/example' %>
6
+ <%= render 'bs5/examples/toasts/placement/example' %>
7
+ <%= render 'bs5/examples/toasts/js_options/example' %>
@@ -4,6 +4,7 @@
4
4
  <title>Bs5</title>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
6
  <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
7
+ <%= javascript_include_tag 'bs5/application', 'data-turbolinks-track': 'reload' %>
7
8
  <%= stylesheet_pack_tag 'styles', media: 'all', 'data-turbolinks-track': 'reload' %>
8
9
  <style><%= Rouge::Themes::Github.render(scope: '.highlight') %></style>
9
10
  </head>
@@ -24,6 +25,7 @@
24
25
  <% lg.item(active: current_page?(pages_path('list_group'))) do %><%= link_to 'List group', pages_path('list_group') %><% end %>
25
26
  <% lg.item(active: current_page?(pages_path('popovers'))) do %><%= link_to 'Popovers', pages_path('popovers') %><% end %>
26
27
  <% lg.item(active: current_page?(pages_path('spinners'))) do %><%= link_to 'Spinners', pages_path('spinners') %><% end %>
28
+ <% lg.item(active: current_page?(pages_path('toasts'))) do %><%= link_to 'Toasts', pages_path('toasts') %><% end %>
27
29
  <% lg.item(active: current_page?(pages_path('tooltips'))) do %><%= link_to 'Tooltips', pages_path('tooltips') %><% end %>
28
30
  <%- end %>
29
31
  </div>
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'view_component/engine'
4
+ require 'sprockets/railtie'
4
5
  module Bs5
5
6
  class Engine < ::Rails::Engine
6
7
  isolate_namespace Bs5
@@ -9,5 +10,10 @@ module Bs5
9
10
  config.before_configuration do |app|
10
11
  app.config.view_component.preview_paths << "#{Bs5::Engine.root}/spec/components/previews"
11
12
  end
13
+
14
+ initializer 'bs5.assets.precompile' do |app|
15
+ app.config.assets.paths << Rails.root.join('app/assets/javascripts')
16
+ app.config.assets.precompile << 'bs5/application.js'
17
+ end
12
18
  end
13
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bs5
4
- VERSION = '0.0.20'
4
+ VERSION = '0.0.25'
5
5
  end
@@ -1,24 +1,35 @@
1
1
  import * as bootstrap from "bootstrap";
2
2
 
3
- function tooltipify() {
4
- const tooltipTriggerList = [].slice.call(
5
- document.querySelectorAll('[data-bs-toggle="tooltip"]')
6
- );
7
- tooltipTriggerList.map(function (tooltipTriggerEl) {
8
- return new bootstrap.Tooltip(tooltipTriggerEl);
9
- });
3
+ function popoverify() {
4
+ document
5
+ .querySelectorAll('[data-bs-toggle="popover"]')
6
+ .forEach(function (popoverTriggerEl) {
7
+ new bootstrap.Popover(popoverTriggerEl);
8
+ });
10
9
  }
11
10
 
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);
11
+ function toastify() {
12
+ document.querySelectorAll(".toast").forEach(function (toastNode) {
13
+ let autohide = new RegExp("true", "i").test(
14
+ toastNode.dataset["bsAutohide"] || "false"
15
+ );
16
+ let toast = new bootstrap.Toast(toastNode, {
17
+ autohide,
18
+ });
19
+ toast.show();
18
20
  });
19
21
  }
20
22
 
23
+ function tooltipify() {
24
+ document
25
+ .querySelectorAll('[data-bs-toggle="tooltip"]')
26
+ .forEach(function (tooltipTriggerEl) {
27
+ new bootstrap.Tooltip(tooltipTriggerEl);
28
+ });
29
+ }
30
+
21
31
  export function start() {
22
32
  popoverify();
33
+ toastify();
23
34
  tooltipify();
24
35
  }
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ return unless defined?(RuboCop)
4
+
3
5
  require 'rubocop/rake_task'
4
6
 
5
7
  RuboCop::RakeTask.new(:rubocop)
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.20
4
+ version: 0.0.25
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-12-12 00:00:00.000000000 Z
11
+ date: 2020-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -100,20 +100,6 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: 4.0.1
103
- - !ruby/object:Gem::Dependency
104
- name: rubocop-rails
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '2.8'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - "~>"
115
- - !ruby/object:Gem::Version
116
- version: '2.8'
117
103
  - !ruby/object:Gem::Dependency
118
104
  name: sqlite3
119
105
  requirement: !ruby/object:Gem::Requirement
@@ -139,6 +125,7 @@ files:
139
125
  - README.md
140
126
  - Rakefile
141
127
  - app/assets/config/bs5_manifest.js
128
+ - app/assets/javascripts/bs5/application.js
142
129
  - app/assets/stylesheets/bs5/application.css
143
130
  - app/components/bs5/accordion_component.html.erb
144
131
  - app/components/bs5/accordion_component.rb
@@ -162,6 +149,14 @@ files:
162
149
  - app/components/bs5/list_group_component.rb
163
150
  - app/components/bs5/spinner_component.html.erb
164
151
  - app/components/bs5/spinner_component.rb
152
+ - app/components/bs5/toast/body_component.html.erb
153
+ - app/components/bs5/toast/body_component.rb
154
+ - app/components/bs5/toast/header_component.html.erb
155
+ - app/components/bs5/toast/header_component.rb
156
+ - app/components/bs5/toast_component.html.erb
157
+ - app/components/bs5/toast_component.rb
158
+ - app/components/bs5/toast_container_component.html.erb
159
+ - app/components/bs5/toast_container_component.rb
165
160
  - app/controllers/bs5/application_controller.rb
166
161
  - app/controllers/bs5/pages_controller.rb
167
162
  - app/helpers/bs5/application_helper.rb
@@ -278,6 +273,20 @@ files:
278
273
  - app/views/bs5/examples/spinners/size/_example.html.erb
279
274
  - app/views/bs5/examples/spinners/size/size1.html.erb
280
275
  - app/views/bs5/examples/spinners/size/size2.html.erb
276
+ - app/views/bs5/examples/toasts/color_schemes/_example.html.erb
277
+ - app/views/bs5/examples/toasts/color_schemes/snippet.html.erb
278
+ - app/views/bs5/examples/toasts/custom_content/_example.html.erb
279
+ - app/views/bs5/examples/toasts/custom_content/snippet1.html.erb
280
+ - app/views/bs5/examples/toasts/custom_content/snippet2.html.erb
281
+ - app/views/bs5/examples/toasts/default/_example.html.erb
282
+ - app/views/bs5/examples/toasts/default/snippet.html.erb
283
+ - app/views/bs5/examples/toasts/js_options/_example.html.erb
284
+ - app/views/bs5/examples/toasts/js_options/snippet.html.erb
285
+ - app/views/bs5/examples/toasts/placement/_example.html.erb
286
+ - app/views/bs5/examples/toasts/placement/snippet1.html.erb
287
+ - app/views/bs5/examples/toasts/placement/snippet2.html.erb
288
+ - app/views/bs5/examples/toasts/stacking/_example.html.erb
289
+ - app/views/bs5/examples/toasts/stacking/snippet.html.erb
281
290
  - app/views/bs5/examples/tooltips/default/_example.html.erb
282
291
  - app/views/bs5/examples/tooltips/default/buttons.html.erb
283
292
  - app/views/bs5/examples/tooltips/default/disabled_elements.html.erb
@@ -293,6 +302,7 @@ files:
293
302
  - app/views/bs5/pages/list_group.html.erb
294
303
  - app/views/bs5/pages/popovers.html.erb
295
304
  - app/views/bs5/pages/spinners.html.erb
305
+ - app/views/bs5/pages/toasts.html.erb
296
306
  - app/views/bs5/pages/tooltips.html.erb
297
307
  - app/views/layouts/bs5/application.html.erb
298
308
  - app/views/layouts/bs5/pages.html.erb