bootstrap4_rails_components 0.1.0

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.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +362 -0
  4. data/Rakefile +23 -0
  5. data/app/assets/config/bootstrap4_rails_components_manifest.js +3 -0
  6. data/app/assets/javascripts/bootstrap4_rails_components/application.js +8 -0
  7. data/app/assets/javascripts/bootstrap4_rails_components/vendor/tooltips.js +42 -0
  8. data/app/assets/stylesheets/bootstrap4_rails_components/bootstrap/application.scss +2 -0
  9. data/app/controllers/bootstrap4_rails_components/application_controller.rb +5 -0
  10. data/app/helpers/bootstrap4_rails_components/application_helper.rb +38 -0
  11. data/app/models/bootstrap4_rails_components/application_record.rb +5 -0
  12. data/config/initializers/web_app_manifest.rb +3 -0
  13. data/config/locales/en.yml +63 -0
  14. data/config/routes.rb +2 -0
  15. data/config/spring.rb +1 -0
  16. data/lib/bootstrap4_rails_components.rb +75 -0
  17. data/lib/bootstrap4_rails_components/bootstrap/components/alert.rb +52 -0
  18. data/lib/bootstrap4_rails_components/bootstrap/components/badge.rb +39 -0
  19. data/lib/bootstrap4_rails_components/bootstrap/components/base.rb +151 -0
  20. data/lib/bootstrap4_rails_components/bootstrap/components/breadcrumb.rb +23 -0
  21. data/lib/bootstrap4_rails_components/bootstrap/components/breadcrumb_item.rb +28 -0
  22. data/lib/bootstrap4_rails_components/bootstrap/components/button.rb +74 -0
  23. data/lib/bootstrap4_rails_components/bootstrap/components/button_group.rb +36 -0
  24. data/lib/bootstrap4_rails_components/bootstrap/components/button_toolbar.rb +21 -0
  25. data/lib/bootstrap4_rails_components/bootstrap/components/card.rb +81 -0
  26. data/lib/bootstrap4_rails_components/bootstrap/components/card_body.rb +15 -0
  27. data/lib/bootstrap4_rails_components/bootstrap/components/card_footer.rb +15 -0
  28. data/lib/bootstrap4_rails_components/bootstrap/components/card_header.rb +35 -0
  29. data/lib/bootstrap4_rails_components/bootstrap/components/card_image.rb +33 -0
  30. data/lib/bootstrap4_rails_components/bootstrap/components/card_image_overlay.rb +46 -0
  31. data/lib/bootstrap4_rails_components/bootstrap/components/carousel.rb +57 -0
  32. data/lib/bootstrap4_rails_components/bootstrap/components/carousel_caption.rb +34 -0
  33. data/lib/bootstrap4_rails_components/bootstrap/components/carousel_control.rb +73 -0
  34. data/lib/bootstrap4_rails_components/bootstrap/components/carousel_indicators.rb +54 -0
  35. data/lib/bootstrap4_rails_components/bootstrap/components/carousel_item.rb +49 -0
  36. data/lib/bootstrap4_rails_components/bootstrap/components/collapse.rb +32 -0
  37. data/lib/bootstrap4_rails_components/bootstrap/components/dropdown.rb +51 -0
  38. data/lib/bootstrap4_rails_components/bootstrap/components/dropdown_divider.rb +19 -0
  39. data/lib/bootstrap4_rails_components/bootstrap/components/dropdown_header.rb +23 -0
  40. data/lib/bootstrap4_rails_components/bootstrap/components/dropdown_item.rb +41 -0
  41. data/lib/bootstrap4_rails_components/bootstrap/components/dropdown_menu.rb +32 -0
  42. data/lib/bootstrap4_rails_components/bootstrap/components/dropdown_toggle.rb +82 -0
  43. data/lib/bootstrap4_rails_components/bootstrap/components/embed.rb +80 -0
  44. data/lib/bootstrap4_rails_components/bootstrap/components/form.rb +13 -0
  45. data/lib/bootstrap4_rails_components/bootstrap/components/input_group.rb +13 -0
  46. data/lib/bootstrap4_rails_components/bootstrap/components/jumbotron.rb +13 -0
  47. data/lib/bootstrap4_rails_components/bootstrap/components/list_group.rb +39 -0
  48. data/lib/bootstrap4_rails_components/bootstrap/components/list_group_item.rb +69 -0
  49. data/lib/bootstrap4_rails_components/bootstrap/components/media.rb +15 -0
  50. data/lib/bootstrap4_rails_components/bootstrap/components/media_body.rb +15 -0
  51. data/lib/bootstrap4_rails_components/bootstrap/components/media_object.rb +23 -0
  52. data/lib/bootstrap4_rails_components/bootstrap/components/modal.rb +66 -0
  53. data/lib/bootstrap4_rails_components/bootstrap/components/modal_body.rb +16 -0
  54. data/lib/bootstrap4_rails_components/bootstrap/components/modal_footer.rb +16 -0
  55. data/lib/bootstrap4_rails_components/bootstrap/components/modal_header.rb +37 -0
  56. data/lib/bootstrap4_rails_components/bootstrap/components/nav.rb +71 -0
  57. data/lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb +103 -0
  58. data/lib/bootstrap4_rails_components/bootstrap/components/nav_link.rb +62 -0
  59. data/lib/bootstrap4_rails_components/bootstrap/components/navbar.rb +97 -0
  60. data/lib/bootstrap4_rails_components/bootstrap/components/navbar_brand.rb +25 -0
  61. data/lib/bootstrap4_rails_components/bootstrap/components/navbar_nav.rb +48 -0
  62. data/lib/bootstrap4_rails_components/bootstrap/components/navbar_text.rb +21 -0
  63. data/lib/bootstrap4_rails_components/bootstrap/components/navbar_toggler.rb +38 -0
  64. data/lib/bootstrap4_rails_components/bootstrap/components/page_item.rb +66 -0
  65. data/lib/bootstrap4_rails_components/bootstrap/components/pagination.rb +30 -0
  66. data/lib/bootstrap4_rails_components/bootstrap/components/popover.rb +12 -0
  67. data/lib/bootstrap4_rails_components/bootstrap/components/progress.rb +44 -0
  68. data/lib/bootstrap4_rails_components/bootstrap/components/progress_bar.rb +51 -0
  69. data/lib/bootstrap4_rails_components/bootstrap/components/tab_content.rb +15 -0
  70. data/lib/bootstrap4_rails_components/bootstrap/components/tab_pane.rb +49 -0
  71. data/lib/bootstrap4_rails_components/bootstrap/components/table.rb +17 -0
  72. data/lib/bootstrap4_rails_components/bootstrap/readme.md +1 -0
  73. data/lib/bootstrap4_rails_components/bootstrap/utilities/activatable.rb +32 -0
  74. data/lib/bootstrap4_rails_components/bootstrap/utilities/alignable.rb +33 -0
  75. data/lib/bootstrap4_rails_components/bootstrap/utilities/collapse_toggleable.rb +35 -0
  76. data/lib/bootstrap4_rails_components/bootstrap/utilities/collapsible.rb +42 -0
  77. data/lib/bootstrap4_rails_components/bootstrap/utilities/disableable.rb +49 -0
  78. data/lib/bootstrap4_rails_components/bootstrap/utilities/dismissible.rb +24 -0
  79. data/lib/bootstrap4_rails_components/bootstrap/utilities/dropdown_directionable.rb +40 -0
  80. data/lib/bootstrap4_rails_components/bootstrap/utilities/headable.rb +20 -0
  81. data/lib/bootstrap4_rails_components/bootstrap/utilities/modalable.rb +104 -0
  82. data/lib/bootstrap4_rails_components/bootstrap/utilities/progressable.rb +42 -0
  83. data/lib/bootstrap4_rails_components/bootstrap/utilities/remotable.rb +24 -0
  84. data/lib/bootstrap4_rails_components/bootstrap/utilities/sizable.rb +40 -0
  85. data/lib/bootstrap4_rails_components/bootstrap/utilities/themeable.rb +51 -0
  86. data/lib/bootstrap4_rails_components/bootstrap/utilities/titleable.rb +20 -0
  87. data/lib/bootstrap4_rails_components/bootstrap/utilities/tooltipable.rb +95 -0
  88. data/lib/bootstrap4_rails_components/bootstrap/utilities/wrappable.rb +48 -0
  89. data/lib/bootstrap4_rails_components/engine.rb +38 -0
  90. data/lib/bootstrap4_rails_components/ui/base.rb +42 -0
  91. data/lib/bootstrap4_rails_components/ui/bootstrap.rb +44 -0
  92. data/lib/bootstrap4_rails_components/ui/utilities.rb +10 -0
  93. data/lib/bootstrap4_rails_components/ui/utilities/initializer.rb +88 -0
  94. data/lib/bootstrap4_rails_components/version.rb +5 -0
  95. metadata +372 -0
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Carousel Caption Component
7
+ # https://getbootstrap.com/docs/4.1/components/carousel/#with-captions
8
+ class CarouselCaption < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ def component_family
10
+ :carousel
11
+ end
12
+
13
+ def label
14
+ options.fetch(:label, nil)
15
+ end
16
+
17
+ def render
18
+ super do
19
+ capture do
20
+ concat(content_tag(:h5, label)) if label
21
+ concat(block_given? ? yield : body)
22
+ end
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def non_html_attribute_options
29
+ super.push(:label)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Carousel Control Component
7
+ # https://getbootstrap.com/docs/4.1/components/carousel/#with-controls
8
+ class CarouselControl < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ # CarouselControl does not get adjustable body content
10
+ def body
11
+ nil
12
+ end
13
+
14
+ def component_family
15
+ :carousel
16
+ end
17
+
18
+ def carousel
19
+ options.fetch(:carousel, nil)
20
+ end
21
+
22
+ # Options for control are :prev and :next
23
+ # control's value sets up the rest of the carousel control attributes in HTML
24
+ def control
25
+ options.fetch(:control, nil)
26
+ end
27
+
28
+ def data
29
+ control ? super.merge!(slide: control) : super
30
+ end
31
+
32
+ def href
33
+ carousel ? carousel : '#'
34
+ end
35
+
36
+ def icon_html_options
37
+ return {} unless control
38
+ { class: "carousel-control-#{control}-icon", aria: { hidden: true } }
39
+ end
40
+
41
+ def render
42
+ super do
43
+ capture do
44
+ if control
45
+ concat(content_tag(:span, nil, icon_html_options))
46
+ concat(content_tag(:span, control.to_s, class: 'sr-only'))
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ private
53
+
54
+ def base_element
55
+ :a
56
+ end
57
+
58
+ def assistive_html_attributes
59
+ super.merge!(role: 'button')
60
+ end
61
+
62
+ # next is a reserved word, for here, we'll refer to options[:next]
63
+ def component_css_class
64
+ control ? "#{super}-#{control}" : super
65
+ end
66
+
67
+ def non_html_attribute_options
68
+ super.push(:control, :carousel)
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Carousel Indicators Component
7
+ # https://getbootstrap.com/docs/4.1/components/carousel/#with-indicators
8
+ class CarouselIndicators < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ def active
10
+ options.fetch(:active, 1) # allow nil so that no indicator is active if desired
11
+ end
12
+
13
+ # Carousel Indicators do not accept a body
14
+ def body
15
+ nil
16
+ end
17
+
18
+ def component_family
19
+ :carousel
20
+ end
21
+
22
+ def count
23
+ options[:count] || 0 # return 0 when nil
24
+ end
25
+
26
+ def carousel
27
+ options.fetch(:carousel, nil)
28
+ end
29
+
30
+ def render
31
+ super do
32
+ capture do
33
+ count.times do |i|
34
+ concat(content_tag(:li, nil, class: ('active' if active == i + 1), data: { target: carousel, slide_to: i }))
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ def base_element
43
+ :ol
44
+ end
45
+
46
+ def non_html_attribute_options
47
+ super.push(:active,
48
+ :count,
49
+ :carousel)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Carousel Slide / Carousel Item Component
7
+ # https://getbootstrap.com/docs/4.1/components/carousel/#slides-only
8
+ class CarouselItem < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ include Bootstrap::Utilities::Activatable
10
+
11
+ def caption
12
+ options.fetch(:caption, nil)
13
+ end
14
+
15
+ def component_family
16
+ :carousel
17
+ end
18
+
19
+ def image
20
+ options.fetch(:image, nil)
21
+ end
22
+
23
+ def label
24
+ options.fetch(:label, nil)
25
+ end
26
+
27
+ def render
28
+ super do
29
+ capture do
30
+ concat(image_tag(image, class: 'd-block w-100')) if image
31
+ if caption || label
32
+ concat(Bootstrap4RailsComponents::Bootstrap::Components::CarouselCaption.new({ body: caption, label: label }, view_context).render)
33
+ end
34
+ concat(block_given? ? yield : body)
35
+ end
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def non_html_attribute_options
42
+ super.push(:image,
43
+ :caption,
44
+ :label)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,32 @@
1
+ module Bootstrap4RailsComponents
2
+ module Bootstrap
3
+ module Components
4
+ # Bootstrap Collapse Component
5
+ # https://getbootstrap.com/docs/4.1/components/collapse/
6
+ class Collapse < Bootstrap4RailsComponents::Bootstrap::Components::Base
7
+ include Bootstrap::Utilities::Collapsible
8
+ # def collapsed
9
+ # options.fetch(:collapsed, false)
10
+ # end
11
+
12
+ def navbar
13
+ options.fetch(:navbar, false)
14
+ end
15
+
16
+ private
17
+
18
+ def css_classes
19
+ [
20
+ super,
21
+ ('show' unless collapsed || navbar),
22
+ ('navbar-collapse' if navbar)
23
+ ].join(' ').squish
24
+ end
25
+
26
+ def non_html_attribute_options
27
+ super.push(:collapsed, :navbar)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Dropdown Component
7
+ # https://getbootstrap.com/docs/4.1/components/dropdowns/
8
+ class Dropdown < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ include Bootstrap::Utilities::DropdownDirectionable
10
+
11
+ def button
12
+ options.fetch(:button, '')
13
+ end
14
+
15
+ def component_family
16
+ :dropdown
17
+ end
18
+
19
+ def offset
20
+ options.fetch(:offset, '')
21
+ end
22
+
23
+ def theme
24
+ options.fetch(:theme, Bootstrap4RailsComponents::DEFAULT_BOOTSTRAP_THEME)
25
+ end
26
+
27
+ def render
28
+ super do
29
+ capture do
30
+ if button.present?
31
+ concat(Bootstrap4RailsComponents::Bootstrap::Components::DropdownToggle.new({ body: button, theme: theme, as: :button, offset: offset }, view_context).render)
32
+ end
33
+ concat(block_given? ? yield : body)
34
+ end
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def non_html_attribute_options
41
+ super.push(:theme,
42
+ :button,
43
+ :offset,
44
+ :dropleft,
45
+ :dropright,
46
+ :dropup)
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Dropdown Component
7
+ # https://getbootstrap.com/docs/4.1/components/dropdowns/
8
+ class DropdownDivider < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ def component_family
10
+ :dropdown
11
+ end
12
+
13
+ def render
14
+ content_tag(:div, nil, html_options)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Dropdown Header Component
7
+ # https://getbootstrap.com/docs/4.1/components/dropdowns/#headers
8
+ class DropdownHeader < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ def heading
10
+ options.fetch(:heading, '')
11
+ end
12
+
13
+ def component_family
14
+ :dropdown
15
+ end
16
+
17
+ def render
18
+ content_tag(:h6, heading, html_options)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Dropdown Items Component
7
+ # https://getbootstrap.com/docs/4.1/components/dropdowns/#menu-items
8
+ class DropdownItem < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ include Bootstrap::Utilities::Wrappable
10
+ include Bootstrap::Utilities::Activatable
11
+ include Bootstrap::Utilities::Disableable
12
+ include Bootstrap::Utilities::Tooltipable
13
+ include Bootstrap::Utilities::Remotable
14
+
15
+ def component_family
16
+ :dropdown
17
+ end
18
+
19
+ def render
20
+ if tooltip && disabled
21
+ content_tag(:span, disabled_component_tooltip_wrapper_html_options) do
22
+ content_tag(as, html_options.except(:href)) do
23
+ (block_given? ? yield : body)
24
+ end
25
+ end
26
+ else
27
+ content_tag(as, html_options) do
28
+ (block_given? ? yield : body)
29
+ end
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def default_html_wrapper_element
36
+ :a
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Dropdown Component
7
+ # https://getbootstrap.com/docs/4.1/components/dropdowns/
8
+ class DropdownMenu < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ def component_family
10
+ :dropdown
11
+ end
12
+
13
+ def right
14
+ options.fetch(:right, false)
15
+ end
16
+
17
+ private
18
+
19
+ def css_classes
20
+ [
21
+ super,
22
+ ('dropdown-menu-right' if right)
23
+ ].join(' ').squish
24
+ end
25
+
26
+ def non_html_attribute_options
27
+ super.push(:right)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Dropdown Component
7
+ # https://getbootstrap.com/docs/4.1/components/dropdowns/
8
+ class DropdownToggle < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ include Bootstrap::Utilities::Wrappable
10
+ include Bootstrap::Utilities::Sizable
11
+
12
+ def component_family
13
+ :dropdown
14
+ end
15
+
16
+ def data
17
+ data_toggle = (options[:data] || {}).merge!(toggle: 'dropdown')
18
+ offset.present? ? { **data_toggle, offset: offset } : data_toggle
19
+ end
20
+
21
+ def href
22
+ as == :a ? '#' : super
23
+ end
24
+
25
+ def nav_link
26
+ options.fetch(:nav_link, false)
27
+ end
28
+
29
+ def offset
30
+ options.fetch(:offset, '')
31
+ end
32
+
33
+ def split
34
+ options.fetch(:split, false)
35
+ end
36
+
37
+ # Bypass & Skip Bootstrap::Utilities::Themeable module
38
+ # this method just passes the options[:theme] to the button component
39
+ # Otherwise, if utilizing :button AND Themeable,
40
+ # we end up with duplicate theme css classes being sent to the button...
41
+ # ex: <button class='btn-danger btn-danger'...>
42
+ def theme
43
+ options.fetch(:theme, Bootstrap4RailsComponents::DEFAULT_BOOTSTRAP_THEME)
44
+ end
45
+
46
+ def render
47
+ Bootstrap4RailsComponents::Bootstrap::Components::Button.new({ as: as, theme: theme, **html_options, remove_component_css_classes: nav_link }, view_context).render do
48
+ (block_given? ? yield : body)
49
+ end
50
+ end
51
+
52
+ private
53
+
54
+ def css_classes
55
+ [
56
+ super,
57
+ ("#{component_css_class}-split" if split)
58
+ ].join(' ').squish
59
+ end
60
+
61
+ def assistive_html_attributes
62
+ { aria: { haspopup: 'true', expanded: 'false' } }
63
+ end
64
+
65
+ def default_html_wrapper_element
66
+ :button
67
+ end
68
+
69
+ def non_html_attribute_options
70
+ super.push(:offset, :nav_link)
71
+ end
72
+
73
+ # Toggle, in html, is a customized button, so sizing a toggle requires using the
74
+ # button prefix -- otherwise it'll end up as
75
+ # 'dropdown-toggle-lg' or 'dropdown-toggle-sm', etc
76
+ def size_css_class_prefix
77
+ 'btn'
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end