bootstrap4_helper 1.0.2 → 1.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96ca003a3537479c6938e25c5e3c63a2a7cc07f6231da69990e99b4d27a096ec
4
- data.tar.gz: 1de1ebb2c2db736dd990e0a656beb6e959a7affa3696bad3e6776b65a0eed9c2
3
+ metadata.gz: dcd8899a1dfc67e56574cd1f0c78d65e45dc3cf6a5f1e9c87bb9c249c89f23e8
4
+ data.tar.gz: 1eabeb64cc4d1c29b7c47af427336b3c40b0a16b65917c5fb857ef293bb6f042
5
5
  SHA512:
6
- metadata.gz: 9efa4daa8b090928e043b3437353338bf24afa29c6535a552eb3087911a45537fdeff7f8d25188af0a921fae0a8e1e3f5e62edc10a780c6006e36c2714b1543e
7
- data.tar.gz: 22119b3d181c221effbb3c822a655bf2cbb1a5a574d8dc5f8fc5e31102dc38208970b1d87bb7a5d69214f71833ed0f1006a1e3ab3d253d55357d72dfc8ea4d0f
6
+ metadata.gz: 1d4d6840a43370f5743315e3cc8c7deae8f2679dc3482eae721850c70fa24f7b44f356a45fae10184ee7e24143b922b38d64e9a1e91c2187bcbace323330677b
7
+ data.tar.gz: bf48bdd5ce2000ca74854a4b5f1a68d50800d8f2ae1625145f4e47673c84673899b59e52466a778f6ef855de835fc6f51b8f41fcdb0d56a955d3ce74fdec92e6
@@ -448,6 +448,15 @@ module Bootstrap4Helper
448
448
  Nav.new(self, opts, &block)
449
449
  end
450
450
 
451
+ # Generates a page header, similiar to bootstrap 3
452
+ #
453
+ # @param [Hash] opts
454
+ # @return [String]
455
+ #
456
+ def page_header_helper(opts = {}, &block)
457
+ PageHeader.new(self, opts, &block)
458
+ end
459
+
451
460
  # Generates a Tab component.
452
461
  #
453
462
  # ```erb
@@ -7,29 +7,31 @@ module Bootstrap4Helper
7
7
  title
8
8
  text
9
9
  image_overlay
10
+ footer
10
11
  ].freeze
11
12
 
12
13
  # Class constructor
13
- # -
14
14
  #
15
15
  # @param [ActionView] template
16
16
  # @param [Hash] opts
17
- # @option opts [String] :id
18
- # @option opts [String] :class
19
- # @option opts [Hash] :data
20
- # @option opts [String] :parent
21
- # @option opts [String] :target
17
+ # @option opts [String] :id
18
+ # @option opts [String] :class
19
+ # @option opts [Hash] :data
20
+ # @option opts [String] :parent
21
+ # @option opts [String] :target
22
+ # @option opts [Boolean] :expanded
22
23
  #
23
24
  def initialize(template, opts = {}, &block)
24
25
  super(template)
25
26
 
26
- @id = opts.fetch(:id, uuid)
27
- @class = opts.fetch(:class, '')
28
- @data = opts.fetch(:data, {})
29
- @parent = opts.fetch(:parent, nil)
30
- @target = @data.fetch(:target, uuid)
31
- @content = block || proc { '' }
32
- @card = Card.new(@template)
27
+ @id = opts.fetch(:id, uuid)
28
+ @class = opts.fetch(:class, '')
29
+ @data = opts.fetch(:data, {})
30
+ @parent = opts.fetch(:parent, nil)
31
+ @expanded = opts.fetch(:expanded, false)
32
+ @target = @data.fetch(:target, uuid)
33
+ @content = block || proc { '' }
34
+ @card = Card.new(@template)
33
35
  end
34
36
 
35
37
  # Builds a header component for the accordion, which is actually the header
@@ -60,9 +62,11 @@ module Bootstrap4Helper
60
62
  # @return [String]
61
63
  #
62
64
  def body(opts = {}, &block)
63
- data = { parent: "##{@parent}" } if @parent.present?
65
+ data = { parent: "##{@parent}" } if @parent.present?
66
+ klass = 'collapse'
67
+ klass += ' show' if @expanded
64
68
 
65
- content_tag :div, id: @target, class: 'collapse', data: data do
69
+ content_tag :div, id: @target, class: klass, data: data do
66
70
  @card.body(opts, &block)
67
71
  end
68
72
  end
@@ -82,7 +86,7 @@ module Bootstrap4Helper
82
86
  end
83
87
  end
84
88
 
85
- # Checks if the Object reponds to missing.
89
+ # Checks if the Object reponds to missing.
86
90
  #
87
91
  #
88
92
  def respond_to_missing?(method, include_private = false)
@@ -95,7 +99,7 @@ module Bootstrap4Helper
95
99
  # @return [String]
96
100
  #
97
101
  def to_s
98
- content_tag :div, class: "card #{@class}", data: @data do
102
+ content_tag :div, id: @id, class: "card #{@class}", data: @data.except(:target) do
99
103
  @content.call(self)
100
104
  end
101
105
  end
@@ -9,7 +9,8 @@ module Bootstrap4Helper
9
9
  card_title: :h5,
10
10
  card_text: :p,
11
11
  accordion_header: :h5,
12
- badge: :span
12
+ badge: :span,
13
+ page_header: :h1
13
14
  }.freeze
14
15
 
15
16
  attr_accessor(*DEFAULT_SETTINGS.keys)
@@ -19,6 +19,7 @@ module Bootstrap4Helper
19
19
  dropdown/menu
20
20
  modal
21
21
  nav
22
+ page_header
22
23
  spinner
23
24
  tab
24
25
  tab/content
@@ -0,0 +1,38 @@
1
+ module Bootstrap4Helper
2
+ # Builds a simple CSS spinner component.
3
+ #
4
+ #
5
+ class PageHeader < Component
6
+ # Class constructor
7
+ #
8
+ # @param [ActionView] template
9
+ # @param [Hash] opts
10
+ # @option opts [String] :id
11
+ # @option opts [String] :class
12
+ # @option opts [Hash] :data
13
+ #
14
+ def initialize(template, opts = {}, &block)
15
+ super(template)
16
+
17
+ @id = opts.fetch(:id, uuid)
18
+ @class = opts.fetch(:class, '')
19
+ @data = opts.fetch(:data, {})
20
+ @content = block || proc { '' }
21
+ end
22
+
23
+ # String representation of the object.
24
+ #
25
+ # @return [String]
26
+ #
27
+ def to_s
28
+ content_tag(
29
+ config(:page_header, :h1),
30
+ id: @id,
31
+ class: "pb-2 mt-4 mb-2 border-bottom #{@class}",
32
+ data: @data
33
+ ) do
34
+ @content.call(self)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -24,18 +24,19 @@ module Bootstrap4Helper
24
24
  # Builds the pane for the tab.
25
25
  #
26
26
  # @param [Symbol] source
27
- # @param [Hash] opts
27
+ # @param [Hash] opts
28
28
  # @option opts [String] :class
29
29
  # @option opts [Hash] :data
30
30
  # @return [String]
31
31
  #
32
32
  def pane(source, opts = {}, &block)
33
+ id = opts.fetch(:id, source)
33
34
  klass = opts.fetch(:class, '')
34
35
  data = opts.fetch(:data, {})
35
36
 
36
37
  content_tag(
37
38
  :div,
38
- id: source,
39
+ id: id,
39
40
  class: "tab-pane #{klass}",
40
41
  role: 'tabpanel',
41
42
  data: data,
@@ -1,3 +1,3 @@
1
1
  module Bootstrap4Helper
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap4_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert David
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-07 00:00:00.000000000 Z
11
+ date: 2021-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "<"
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.0
19
+ version: '4.2'
20
+ - - "<="
21
+ - !ruby/object:Gem::Version
22
+ version: 7.0.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "<"
27
+ - - ">"
28
+ - !ruby/object:Gem::Version
29
+ version: '4.2'
30
+ - - "<="
25
31
  - !ruby/object:Gem::Version
26
- version: 6.0.0
32
+ version: 7.0.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bootstrap
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +156,7 @@ files:
150
156
  - lib/bootstrap4_helper/initialize.rb
151
157
  - lib/bootstrap4_helper/modal.rb
152
158
  - lib/bootstrap4_helper/nav.rb
159
+ - lib/bootstrap4_helper/page_header.rb
153
160
  - lib/bootstrap4_helper/railtie.rb
154
161
  - lib/bootstrap4_helper/spinner.rb
155
162
  - lib/bootstrap4_helper/tab.rb
@@ -175,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
182
  - !ruby/object:Gem::Version
176
183
  version: '0'
177
184
  requirements: []
178
- rubygems_version: 3.1.3
185
+ rubygems_version: 3.0.1
179
186
  signing_key:
180
187
  specification_version: 4
181
188
  summary: Library for rapidly building bootstrap 4 components