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,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Responsive Embed Component
7
+ # https://getbootstrap.com/docs/4.1/utilities/embed/
8
+ class Embed < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ def aspect_ratio
10
+ options.fetch(:aspect_ratio, default_aspect_ratio) || default_aspect_ratio
11
+ end
12
+
13
+ def iframe
14
+ return unless iframe?
15
+ view_context.content_tag :iframe, nil, src: src, class: 'embed-responsive-item', allowfullscreen: true
16
+ end
17
+
18
+ def iframe?
19
+ options[:iframe].present?
20
+ end
21
+
22
+ def autoplay
23
+ options.fetch(:autoplay, default_autoplay)
24
+ end
25
+
26
+ def render
27
+ super do
28
+ if iframe?
29
+ iframe
30
+ else
31
+ (block_given? ? yield : body)
32
+ end
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def component_css_class
39
+ 'embed-responsive'
40
+ end
41
+
42
+ def src
43
+ return unless iframe?
44
+ options[:iframe] + (autoplay ? '?autoplay=1' : '')
45
+ end
46
+
47
+ def css_classes
48
+ return super unless allowed_aspect_ratios.include?(aspect_ratio)
49
+ super + " embed-responsive-#{aspect_ratio.gsub("\:", 'by')}"
50
+ end
51
+
52
+ def allowed_aspect_ratios
53
+ %w[21:9 16:9 4:3 1:1]
54
+ end
55
+
56
+ def default_aspect_ratio
57
+ '16:9'
58
+ end
59
+
60
+ # def default_iframe
61
+ # ''
62
+ # end
63
+
64
+ def non_html_attribute_options
65
+ super.push(:iframe, :aspect_ratio, :autoplay)
66
+ end
67
+
68
+ # def defaults
69
+ # super.merge!(iframe: default_iframe,
70
+ # aspect_ratio: default_aspect_ratio,
71
+ # autoplay: default_autoplay)
72
+ # end
73
+
74
+ def default_autoplay
75
+ false
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Forms Component
7
+ # https://getbootstrap.com/docs/4.1/components/forms/
8
+ class Form < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Input Group Component
7
+ # https://getbootstrap.com/docs/4.1/components/input-group/
8
+ class InputGroup < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Jumbotron Component
7
+ # https://getbootstrap.com/docs/4.1/components/jumbotron/
8
+ class Jumbotron < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap List Group Component
7
+ # https://getbootstrap.com/docs/4.1/components/list-group/
8
+ class ListGroup < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ include Bootstrap::Utilities::Wrappable
10
+
11
+ def component_family
12
+ :list_group
13
+ end
14
+
15
+ def flush
16
+ options.fetch(:flush, false)
17
+ end
18
+
19
+ private
20
+
21
+ def base_element
22
+ as
23
+ end
24
+
25
+ def css_classes
26
+ flush ? super + " #{component_css_class}-flush" : super
27
+ end
28
+
29
+ def default_html_wrapper_element
30
+ :ul
31
+ end
32
+
33
+ def non_html_attribute_options
34
+ super.push(:flush)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap List Group Item Component
7
+ # https://getbootstrap.com/docs/4.1/components/list-group/
8
+ class ListGroupItem < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ include Bootstrap::Utilities::Wrappable
10
+ include Bootstrap::Utilities::Activatable
11
+ include Bootstrap::Utilities::Disableable
12
+ include Bootstrap::Utilities::Themeable
13
+
14
+ def component_family
15
+ :list_group
16
+ end
17
+
18
+ def action
19
+ options.fetch(:action, false)
20
+ end
21
+
22
+ def badge
23
+ options.fetch(:badge, nil)
24
+ end
25
+
26
+ def render
27
+ super do
28
+ capture do
29
+ concat(block_given? ? yield : body)
30
+ if badge
31
+ concat(Bootstrap4RailsComponents::Bootstrap::Components::Badge.new({ pill: true, theme: (theme || Bootstrap4RailsComponents::DEFAULT_BOOTSTRAP_THEME), body: badge }, view_context).render)
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def base_element
40
+ as
41
+ end
42
+
43
+ def default_theme
44
+ nil
45
+ end
46
+
47
+ def default_html_wrapper_element
48
+ :li
49
+ end
50
+
51
+ def css_classes
52
+ [
53
+ super,
54
+ ("#{component_css_class}-action" if action),
55
+ ('d-flex justify-content-between align-items-center' if badge)
56
+ ].join(' ').squish
57
+ end
58
+
59
+ def non_html_attribute_options
60
+ super.push(:action, :badge)
61
+ end
62
+
63
+ def outlineable?
64
+ false
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Media Object Layout Component
7
+ # https://getbootstrap.com/docs/4.1/layout/media-object/
8
+ class Media < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ def component_family
10
+ :media
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Media Object Layout Component
7
+ # https://getbootstrap.com/docs/4.1/layout/media-object/
8
+ class MediaBody < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ def component_family
10
+ :media
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Media Object Layout Component
7
+ # https://getbootstrap.com/docs/4.1/layout/media-object/
8
+ class MediaObject < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ def component_css_class
10
+ ''
11
+ end
12
+
13
+ def component_family
14
+ :media
15
+ end
16
+
17
+ def render
18
+ (block_given? ? yield : body)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Modal Component
7
+ # https://getbootstrap.com/docs/4.1/components/modal/
8
+ class Modal < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+
10
+ # NOTE: ARIALABELLEDBY has not been introduced on speed modals.
11
+ # ex: aria-labelledby="exampleModalLabel"
12
+ # which is then the ID of the modal title element
13
+
14
+ def component_family
15
+ :modal
16
+ end
17
+
18
+ def title
19
+ options.fetch(:title, nil)
20
+ end
21
+
22
+ def footer
23
+ options.fetch(:footer, nil)
24
+ end
25
+
26
+ def render
27
+ super do
28
+ content_tag(:div, class: 'modal-dialog', role: 'document') do
29
+ content_tag(:div, class: 'modal-content') do
30
+ capture do
31
+ concat(Bootstrap4RailsComponents::Bootstrap::Components::ModalHeader.new({ title: title }, view_context).render)
32
+ if render_in_body
33
+ concat(Bootstrap4RailsComponents::Bootstrap::Components::ModalBody.new({ body: (block_given? ? yield : body) }, view_context).render)
34
+ else
35
+ concat(block_given? ? yield : body)
36
+ end
37
+ if footer
38
+ concat(Bootstrap4RailsComponents::Bootstrap::Components::ModalFooter.new({ body: footer }, view_context).render)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ def render_in_body
47
+ options.fetch(:render_in_body, true)
48
+ end
49
+
50
+ private
51
+
52
+ def css_classes
53
+ super + ' fade'
54
+ end
55
+
56
+ def non_html_attribute_options
57
+ super.push((:footer if footer.present?), (:title if title.present?))
58
+ end
59
+
60
+ def assistive_html_attributes
61
+ super.merge(role: 'dialog', tabindex: '-1', aria: { hidden: 'true' })
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Modal Component
7
+ # https://getbootstrap.com/docs/4.1/components/modal/
8
+ class ModalBody < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+
10
+ def component_family
11
+ :modal
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Modal Component
7
+ # https://getbootstrap.com/docs/4.1/components/modal/
8
+ class ModalFooter < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+
10
+ def component_family
11
+ :modal
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Modal Component
7
+ # https://getbootstrap.com/docs/4.1/components/modal/
8
+ class ModalHeader < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+
10
+ def component_family
11
+ :modal
12
+ end
13
+
14
+ def title
15
+ options.fetch(:title, nil)
16
+ end
17
+
18
+ def render
19
+ super do
20
+ capture do
21
+ concat(content_tag(:h5, title, class: 'modal-title')) if title
22
+ concat(Bootstrap4RailsComponents::Bootstrap::Components::Button.new({ as: :button, class: 'close', theme: nil, data: { dismiss: 'modal' }, aria: { label: 'Close' } }, view_context).render {
23
+ content_tag(:span, "&times;".html_safe, { aria: { hidden: 'true' } })
24
+ })
25
+ end
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def non_html_attribute_options
32
+ super.push(:title)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bootstrap4RailsComponents
4
+ module Bootstrap
5
+ module Components
6
+ # Bootstrap Nav Component
7
+ # https://getbootstrap.com/docs/4.1/components/navs/
8
+ class Nav < Bootstrap4RailsComponents::Bootstrap::Components::Base
9
+ include Bootstrap::Utilities::Alignable
10
+ include Bootstrap::Utilities::Wrappable
11
+
12
+ def component_family
13
+ :nav
14
+ end
15
+
16
+ def fill
17
+ options.fetch(:fill, false)
18
+ end
19
+
20
+ def justified
21
+ options.fetch(:justified, false)
22
+ end
23
+
24
+ def pill
25
+ options.fetch(:pill, false)
26
+ end
27
+
28
+ def tabs
29
+ options.fetch(:tabs, false)
30
+ end
31
+
32
+ def vertical
33
+ options.fetch(:vertical, false)
34
+ end
35
+
36
+ private
37
+
38
+ def base_element
39
+ as
40
+ end
41
+
42
+ def component_css_class
43
+ 'nav'
44
+ end
45
+
46
+ def css_classes
47
+ [
48
+ super,
49
+ ('nav-fill' if fill),
50
+ ('nav-justified' if justified),
51
+ ('nav-pills' if pill),
52
+ ('nav-tabs' if tabs),
53
+ ('flex-column' if vertical)
54
+ ].join(' ').squish
55
+ end
56
+
57
+ def default_html_wrapper_element
58
+ :ul
59
+ end
60
+
61
+ def non_html_attribute_options
62
+ super.push(:fill,
63
+ :justified,
64
+ :tabs,
65
+ :pill,
66
+ :vertical)
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end