bs5 0.0.26 → 0.0.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/components/bs5/carousel/caption_component.html.erb +3 -0
- data/app/components/bs5/carousel/caption_component.rb +8 -0
- data/app/components/bs5/carousel/item_component.html.erb +4 -0
- data/app/components/bs5/carousel/item_component.rb +74 -0
- data/app/components/bs5/carousel_component.html.erb +30 -0
- data/app/components/bs5/carousel_component.rb +60 -0
- data/app/components/bs5/modal/body_component.html.erb +3 -0
- data/app/components/bs5/modal/body_component.rb +8 -0
- data/app/components/bs5/modal/controller_component.html.erb +1 -0
- data/app/components/bs5/modal/controller_component.rb +40 -0
- data/app/components/bs5/modal/footer_component.html.erb +4 -0
- data/app/components/bs5/modal/footer_component.rb +8 -0
- data/app/components/bs5/modal/header_component.html.erb +4 -0
- data/app/components/bs5/modal/header_component.rb +18 -0
- data/app/components/bs5/modal_component.html.erb +11 -0
- data/app/components/bs5/modal_component.rb +80 -0
- data/app/components/bs5/nav/item_component.html.erb +1 -0
- data/app/components/bs5/nav/item_component.rb +80 -0
- data/app/components/bs5/nav_component.html.erb +7 -0
- data/app/components/bs5/nav_component.rb +47 -0
- data/app/components/bs5/progress/bar_component.html.erb +1 -0
- data/app/components/bs5/progress/bar_component.rb +60 -0
- data/app/components/bs5/progress_component.html.erb +9 -0
- data/app/components/bs5/progress_component.rb +15 -0
- data/app/components/bs5/tabs/item_component.html.erb +3 -0
- data/app/components/bs5/tabs/item_component.rb +48 -0
- data/app/components/bs5/tabs/link_component.html.erb +1 -0
- data/app/components/bs5/tabs/link_component.rb +27 -0
- data/app/components/bs5/tabs_component.html.erb +16 -0
- data/app/components/bs5/tabs_component.rb +63 -0
- data/app/helpers/bs5/components_helper.rb +6 -3
- data/app/views/bs5/examples/carousel/_dark_variant.html.erb +2 -0
- data/app/views/bs5/examples/carousel/_examples.html.erb +13 -0
- data/app/views/bs5/examples/carousel/dark_variant/snippet1.html.erb +25 -0
- data/app/views/bs5/examples/carousel/examples/snippet1.html.erb +13 -0
- data/app/views/bs5/examples/carousel/examples/snippet2.html.erb +13 -0
- data/app/views/bs5/examples/carousel/examples/snippet3.html.erb +13 -0
- data/app/views/bs5/examples/carousel/examples/snippet4.html.erb +25 -0
- data/app/views/bs5/examples/carousel/examples/snippet5.html.erb +13 -0
- data/app/views/bs5/examples/carousel/examples/snippet6.html.erb +13 -0
- data/app/views/bs5/examples/modal/_examples.html.erb +9 -0
- data/app/views/bs5/examples/modal/_fullscreen.html.erb +2 -0
- data/app/views/bs5/examples/modal/_optional_sizes.html.erb +2 -0
- data/app/views/bs5/examples/modal/examples/snippet1.html.erb +12 -0
- data/app/views/bs5/examples/modal/examples/snippet2.html.erb +12 -0
- data/app/views/bs5/examples/modal/examples/snippet3.html.erb +14 -0
- data/app/views/bs5/examples/modal/examples/snippet4.html.erb +12 -0
- data/app/views/bs5/examples/modal/fullscreen/snippet1.html.erb +55 -0
- data/app/views/bs5/examples/modal/optional_sizes/snippet1.html.erb +23 -0
- data/app/views/bs5/examples/navs_and_tabs/_base_nav.html.erb +2 -0
- data/app/views/bs5/examples/navs_and_tabs/_dropdowns.html.erb +5 -0
- data/app/views/bs5/examples/navs_and_tabs/_flex_utils.html.erb +2 -0
- data/app/views/bs5/examples/navs_and_tabs/_styles.html.erb +15 -0
- data/app/views/bs5/examples/navs_and_tabs/_tabs.html.erb +4 -0
- data/app/views/bs5/examples/navs_and_tabs/base_nav/snippet1.html.erb +6 -0
- data/app/views/bs5/examples/navs_and_tabs/dropdowns/snippet1.html.erb +14 -0
- data/app/views/bs5/examples/navs_and_tabs/dropdowns/snippet2.html.erb +14 -0
- data/app/views/bs5/examples/navs_and_tabs/flex_utils/snippet1.html.erb +6 -0
- data/app/views/bs5/examples/navs_and_tabs/styles/snippet1.html.erb +6 -0
- data/app/views/bs5/examples/navs_and_tabs/styles/snippet2.html.erb +6 -0
- data/app/views/bs5/examples/navs_and_tabs/styles/snippet3.html.erb +6 -0
- data/app/views/bs5/examples/navs_and_tabs/styles/snippet4.html.erb +6 -0
- data/app/views/bs5/examples/navs_and_tabs/styles/snippet5.html.erb +6 -0
- data/app/views/bs5/examples/navs_and_tabs/styles/snippet6.html.erb +6 -0
- data/app/views/bs5/examples/navs_and_tabs/styles/snippet7.html.erb +6 -0
- data/app/views/bs5/examples/navs_and_tabs/styles/snippet8.html.erb +6 -0
- data/app/views/bs5/examples/navs_and_tabs/styles/snippet9.html.erb +6 -0
- data/app/views/bs5/examples/navs_and_tabs/tabs/snippet1.html.erb +11 -0
- data/app/views/bs5/examples/navs_and_tabs/tabs/snippet2.html.erb +11 -0
- data/app/views/bs5/examples/navs_and_tabs/tabs/snippet3.html.erb +11 -0
- data/app/views/bs5/examples/progress/_animated.html.erb +2 -0
- data/app/views/bs5/examples/progress/_backgrounds.html.erb +2 -0
- data/app/views/bs5/examples/progress/_examples.html.erb +2 -0
- data/app/views/bs5/examples/progress/_labels.html.erb +2 -0
- data/app/views/bs5/examples/progress/_multiple_bars.html.erb +2 -0
- data/app/views/bs5/examples/progress/_striped.html.erb +2 -0
- data/app/views/bs5/examples/progress/animated/snippet1.html.erb +13 -0
- data/app/views/bs5/examples/progress/backgrounds/snippet1.html.erb +13 -0
- data/app/views/bs5/examples/progress/examples/snippet1.html.erb +17 -0
- data/app/views/bs5/examples/progress/labels/snippet1.html.erb +5 -0
- data/app/views/bs5/examples/progress/multiple_bars/snippet1.html.erb +5 -0
- data/app/views/bs5/examples/progress/striped/snippet1.html.erb +13 -0
- data/app/views/bs5/pages/carousel.html.erb +3 -0
- data/app/views/bs5/pages/modal.html.erb +4 -0
- data/app/views/bs5/pages/navs_and_tabs.html.erb +6 -0
- data/app/views/bs5/pages/progress.html.erb +7 -0
- data/app/views/layouts/bs5/pages.html.erb +4 -0
- data/lib/bs5/version.rb +1 -1
- metadata +95 -16
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bs5
|
4
|
+
class NavComponent < ViewComponent::Base
|
5
|
+
include ViewComponent::SlotableV2
|
6
|
+
|
7
|
+
renders_many :items, Bs5::Nav::ItemComponent
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@options = options.symbolize_keys
|
11
|
+
extract_options
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def extract_options
|
17
|
+
@style = @options.delete(:style)
|
18
|
+
@space = @options.delete(:space)
|
19
|
+
end
|
20
|
+
|
21
|
+
def component_class
|
22
|
+
class_names = Array(@options[:class])
|
23
|
+
class_names << ['nav']
|
24
|
+
class_names << style_class
|
25
|
+
class_names << space_class
|
26
|
+
class_names.join(' ')
|
27
|
+
end
|
28
|
+
|
29
|
+
def style_class
|
30
|
+
return unless style?
|
31
|
+
|
32
|
+
["nav-#{@style}"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def space_class
|
36
|
+
return unless space?
|
37
|
+
|
38
|
+
["nav-#{@space}"]
|
39
|
+
end
|
40
|
+
|
41
|
+
%i[style space].each do |name|
|
42
|
+
define_method("#{name}?") do
|
43
|
+
!!instance_variable_get("@#{name}")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<div class="<%= bar_class %>" role="progressbar" style="width: <%= value %>%" aria-valuenow="<%= value %>" aria-valuemin="0" aria-valuemax="100"><%= label %></div>
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bs5
|
4
|
+
module Progress
|
5
|
+
class BarComponent < ViewComponent::Base
|
6
|
+
attr_reader :value, :color
|
7
|
+
|
8
|
+
def initialize(value, label: nil, color: nil, striped: false, animated: false)
|
9
|
+
@value = value
|
10
|
+
@label = label
|
11
|
+
@color = color
|
12
|
+
@striped = striped
|
13
|
+
@animated = animated
|
14
|
+
end
|
15
|
+
|
16
|
+
def label
|
17
|
+
return unless @label
|
18
|
+
|
19
|
+
case @label
|
20
|
+
when String
|
21
|
+
@label
|
22
|
+
else
|
23
|
+
"#{value}%"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def bar_class
|
28
|
+
class_names = %w[progress-bar]
|
29
|
+
class_names << contextual_class
|
30
|
+
class_names << striped_class
|
31
|
+
class_names << animated_class
|
32
|
+
class_names.flatten.uniq.join(' ')
|
33
|
+
end
|
34
|
+
|
35
|
+
def contextual_class
|
36
|
+
return unless color?
|
37
|
+
|
38
|
+
"bg-#{color}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def striped_class
|
42
|
+
return unless striped?
|
43
|
+
|
44
|
+
'progress-bar-striped'
|
45
|
+
end
|
46
|
+
|
47
|
+
def animated_class
|
48
|
+
return unless animated?
|
49
|
+
|
50
|
+
%w[progress-bar-striped progress-bar-animated]
|
51
|
+
end
|
52
|
+
|
53
|
+
%i[color striped animated].each do |name|
|
54
|
+
define_method("#{name}?") do
|
55
|
+
!!instance_variable_get("@#{name}")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bs5
|
4
|
+
class ProgressComponent < ViewComponent::Base
|
5
|
+
include ViewComponent::SlotableV2
|
6
|
+
renders_many :bars, Bs5::Progress::BarComponent
|
7
|
+
|
8
|
+
attr_reader :value, :options
|
9
|
+
|
10
|
+
def initialize(value = nil, options = {})
|
11
|
+
@options = options.symbolize_keys
|
12
|
+
@value = value
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bs5
|
4
|
+
module Tabs
|
5
|
+
class ItemComponent < ViewComponent::Base
|
6
|
+
attr_reader :title, :options
|
7
|
+
attr_accessor :style
|
8
|
+
|
9
|
+
def initialize(title, options = {})
|
10
|
+
@title = title
|
11
|
+
@options = options.symbolize_keys
|
12
|
+
extract_options
|
13
|
+
end
|
14
|
+
|
15
|
+
def tab_id
|
16
|
+
"nav-#{object_id}-tab"
|
17
|
+
end
|
18
|
+
|
19
|
+
def pane_id
|
20
|
+
"nav-#{object_id}"
|
21
|
+
end
|
22
|
+
|
23
|
+
%i[active].each do |name|
|
24
|
+
define_method("#{name}?") do
|
25
|
+
!!instance_variable_get("@#{name}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def extract_options
|
32
|
+
@active = @options.delete(:active)
|
33
|
+
end
|
34
|
+
|
35
|
+
def component_class
|
36
|
+
class_names = %w[tab-pane fade]
|
37
|
+
class_names << active_class
|
38
|
+
class_names.join(' ')
|
39
|
+
end
|
40
|
+
|
41
|
+
def active_class
|
42
|
+
return unless active?
|
43
|
+
|
44
|
+
%w[show active]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= link_to item.title, "##{item.pane_id}", class: component_class, id: item.tab_id, role: :tab, data: { bs_toggle: item.style }, aria: { controls: item.pane_id, selected: item.active? } %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bs5
|
4
|
+
module Tabs
|
5
|
+
class LinkComponent < ViewComponent::Base
|
6
|
+
attr_reader :item
|
7
|
+
|
8
|
+
def initialize(item)
|
9
|
+
@item = item
|
10
|
+
end
|
11
|
+
|
12
|
+
def component_class
|
13
|
+
class_names = ['nav-link']
|
14
|
+
|
15
|
+
class_names << active_class
|
16
|
+
|
17
|
+
class_names.compact.join(' ')
|
18
|
+
end
|
19
|
+
|
20
|
+
def active_class
|
21
|
+
return unless item.active?
|
22
|
+
|
23
|
+
%w[active]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% if items.any? %>
|
2
|
+
<%= vertical_container do %>
|
3
|
+
<nav>
|
4
|
+
<div class="<%= tablist_class %>" role="tablist">
|
5
|
+
<% items.each do |item| %>
|
6
|
+
<%= render Bs5::Tabs::LinkComponent.new(item) %>
|
7
|
+
<% end %>
|
8
|
+
</div>
|
9
|
+
</nav>
|
10
|
+
<div class="tab-content">
|
11
|
+
<% items.each do |item| %>
|
12
|
+
<%= item %>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bs5
|
4
|
+
class TabsComponent < ViewComponent::Base
|
5
|
+
include ViewComponent::SlotableV2
|
6
|
+
|
7
|
+
renders_many :items, Bs5::Tabs::ItemComponent
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@options = options.symbolize_keys
|
11
|
+
extract_options
|
12
|
+
end
|
13
|
+
|
14
|
+
def before_render
|
15
|
+
items.each { |item| item.style = item_style }
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def extract_options
|
21
|
+
@style = @options.delete(:style) || :pills
|
22
|
+
@vertical = @options.delete(:vertical)
|
23
|
+
end
|
24
|
+
|
25
|
+
def vertical_container(&block)
|
26
|
+
if vertical?
|
27
|
+
tag.div(class: 'd-flex align-items-start') do
|
28
|
+
capture(&block)
|
29
|
+
end
|
30
|
+
else
|
31
|
+
capture(&block)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def tablist_class
|
36
|
+
class_names = Array(@options[:class])
|
37
|
+
class_names << %w[nav]
|
38
|
+
class_names << style_class
|
39
|
+
class_names << vertical_class
|
40
|
+
class_names.join(' ')
|
41
|
+
end
|
42
|
+
|
43
|
+
def style_class
|
44
|
+
["nav-#{@style}"]
|
45
|
+
end
|
46
|
+
|
47
|
+
def vertical_class
|
48
|
+
return unless vertical?
|
49
|
+
|
50
|
+
['flex-column']
|
51
|
+
end
|
52
|
+
|
53
|
+
%i[vertical].each do |name|
|
54
|
+
define_method("#{name}?") do
|
55
|
+
!!instance_variable_get("@#{name}")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def item_style
|
60
|
+
@style.to_s.singularize
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -2,12 +2,15 @@
|
|
2
2
|
|
3
3
|
module Bs5
|
4
4
|
module ComponentsHelper
|
5
|
-
COMPONENTS = %w[accordion alert badge breadcrumb button_group button_tag button_to button_toolbar
|
6
|
-
|
5
|
+
COMPONENTS = %w[accordion alert badge breadcrumb button_group button_tag button_to button_toolbar
|
6
|
+
carousel close_button
|
7
|
+
dropdown list_group modal nav spinner
|
8
|
+
progress
|
9
|
+
tabs toast toast_container].freeze
|
7
10
|
|
8
11
|
COMPONENTS.each do |name|
|
9
12
|
define_method("bs5_#{name}") do |*args, &block|
|
10
|
-
clazz = "Bs5::#{name.
|
13
|
+
clazz = "Bs5::#{name.camelize}Component".constantize
|
11
14
|
render_component(clazz, *args, &block)
|
12
15
|
end
|
13
16
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<h2>Examples</h2>
|
2
|
+
<h3>Slides only</h3>
|
3
|
+
<%= bs5_example(snippet: 'carousel/examples/snippet1') %>
|
4
|
+
<h3>With controls</h3>
|
5
|
+
<%= bs5_example(snippet: 'carousel/examples/snippet2') %>
|
6
|
+
<h3>With indicators</h3>
|
7
|
+
<%= bs5_example(snippet: 'carousel/examples/snippet3') %>
|
8
|
+
<h3>With captions</h3>
|
9
|
+
<%= bs5_example(snippet: 'carousel/examples/snippet4') %>
|
10
|
+
<h3>Crossfade</h3>
|
11
|
+
<%= bs5_example(snippet: 'carousel/examples/snippet5') %>
|
12
|
+
<h3>Individual <code>.carousel-item</code> interval</h3>
|
13
|
+
<%= bs5_example(snippet: 'carousel/examples/snippet6') %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%= bs5_carousel(controls: true, indicators: true, dark: true) do |c| %>
|
2
|
+
<% c.item do |i| %>
|
3
|
+
<%= image_tag 'https://picsum.photos/id/131/800/400?grayscale' %>
|
4
|
+
<%= i.caption do %>
|
5
|
+
<h5>First slide label</h5>
|
6
|
+
<p>Nulla vitae elit libero, a pharetra augue mollis interdum.</p>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% c.item do |i| %>
|
11
|
+
<%= image_tag 'https://picsum.photos/id/383/800/400?grayscale' %>
|
12
|
+
<%= i.caption do %>
|
13
|
+
<h5>Second slide label</h5>
|
14
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<% c.item do |i| %>
|
19
|
+
<%= image_tag 'https://picsum.photos/id/130/800/400' %>
|
20
|
+
<%= i.caption do %>
|
21
|
+
<h5>Third slide label</h5>
|
22
|
+
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur.</p>
|
23
|
+
<% end %>
|
24
|
+
<% end %>
|
25
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%= bs5_carousel do |c| %>
|
2
|
+
<% c.item do %>
|
3
|
+
<%= image_tag 'https://picsum.photos/800/400?random=1' %>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<% c.item do %>
|
7
|
+
<%= image_tag 'https://picsum.photos/800/400?random=2' %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% c.item do %>
|
11
|
+
<%= image_tag 'https://picsum.photos/800/400?random=3' %>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%= bs5_carousel(controls: true) do |c| %>
|
2
|
+
<% c.item do %>
|
3
|
+
<%= image_tag 'https://picsum.photos/800/400?random=1' %>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<% c.item do %>
|
7
|
+
<%= image_tag 'https://picsum.photos/800/400?random=2' %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% c.item do %>
|
11
|
+
<%= image_tag 'https://picsum.photos/800/400?random=3' %>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%= bs5_carousel(controls: true, indicators: true) do |c| %>
|
2
|
+
<% c.item do %>
|
3
|
+
<%= image_tag 'https://picsum.photos/800/400?random=1' %>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<% c.item do %>
|
7
|
+
<%= image_tag 'https://picsum.photos/800/400?random=2' %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% c.item do %>
|
11
|
+
<%= image_tag 'https://picsum.photos/800/400?random=3' %>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%= bs5_carousel(controls: true, indicators: true) do |c| %>
|
2
|
+
<% c.item do |i| %>
|
3
|
+
<%= image_tag 'https://picsum.photos/id/1042/800/400?blur=2' %>
|
4
|
+
<%= i.caption do %>
|
5
|
+
<h5>First slide label</h5>
|
6
|
+
<p>Nulla vitae elit libero, a pharetra augue mollis interdum.</p>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% c.item do |i| %>
|
11
|
+
<%= image_tag 'https://picsum.photos/id/195/800/400?blur=2' %>
|
12
|
+
<%= i.caption do %>
|
13
|
+
<h5>Second slide label</h5>
|
14
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<% c.item do |i| %>
|
19
|
+
<%= image_tag 'https://picsum.photos/id/960/800/400?blur=2' %>
|
20
|
+
<%= i.caption do %>
|
21
|
+
<h5>Third slide label</h5>
|
22
|
+
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur.</p>
|
23
|
+
<% end %>
|
24
|
+
<% end %>
|
25
|
+
<% end %>
|