bootstrap4_helper 1.0.0 → 1.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.
@@ -1,17 +1,16 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- # @description
6
- # -
2
+ # Builds a Nav Component that can be used in other components.
3
+ #
7
4
  #
8
5
  class Nav < Component
9
- # @description
10
- # -
6
+ # Class constructor
11
7
  #
12
- # @param [ActionView] template
13
- # @param [NilClass|String|Symbol|Hash] context_or_options
14
- # @param [Hash]
8
+ # @param [ActionView] template
9
+ # @param [Hash] opts
10
+ # @option opts [String] :id
11
+ # @option opts [String] :class
12
+ # @option opts [Hash] :data
13
+ # @option opts [Hash] :child
15
14
  #
16
15
  def initialize(template, opts = {}, &block)
17
16
  super(template)
@@ -25,14 +24,19 @@ module Bootstrap4Helper
25
24
  @dropdown = Dropdown.new(@template)
26
25
  end
27
26
 
28
- # @description
29
- # - Adds an nav-item to the nav component. this method gets used when the nav-item
27
+ # rubocop:disable Metrics/MethodLength
28
+
29
+ # Adds an nav-item to the nav component. this method gets used when the nav-item
30
30
  # links to content in a tab or something.
31
31
  #
32
32
  # @param [Symbol|String] target
33
33
  # @param [Hash] opts
34
+ # @option opts [String] :id
35
+ # @option opts [String] :class
36
+ # @option opts [Hash] :data
37
+ # @option opts [Hash] :aria
38
+ # @return [String]
34
39
  #
35
- # rubocop:disable Metrics/MethodLength
36
40
  def item(target, opts = {})
37
41
  id = opts.fetch(:id, nil)
38
42
  klass = opts.fetch(:class, '')
@@ -54,8 +58,12 @@ module Bootstrap4Helper
54
58
  end
55
59
  # rubocop:enable Metrics/MethodLength
56
60
 
57
- # @description
58
- # - Use this when the nav item is nothing more than a hyperlink.
61
+ # Use this when the nav item is nothing more than a hyperlink.
62
+ #
63
+ # @param [String|NilClass] name
64
+ # @param [Hash|NilClass] options
65
+ # @param [Hash|NilClass] html_options
66
+ # @return [String]
59
67
  #
60
68
  def link(name = nil, options = nil, html_options = nil, &block)
61
69
  html_options = (html_options || {}).merge(class: 'nav-link')
@@ -63,11 +71,15 @@ module Bootstrap4Helper
63
71
  @template.link_to(name, options, html_options, &block)
64
72
  end
65
73
 
66
- # @description
67
- # - Creates a dropdown menu for the nav.
74
+ # Creates a dropdown menu for the nav.
68
75
  #
69
76
  # @param [NilClass|Symbol|String] name
70
77
  # @param [Hash] opts
78
+ # @option opts [String] :id
79
+ # @option opts [String] :class
80
+ # @option opts [Hash] :data
81
+ # @option opts [Hash] :aria
82
+ # @return [String]
71
83
  #
72
84
  def dropdown(name, opts = {}, &block)
73
85
  id = opts.fetch(:id, nil)
@@ -88,8 +100,9 @@ module Bootstrap4Helper
88
100
  end
89
101
  end
90
102
 
91
- # @description
92
- # -
103
+ # String representation of the object.
104
+ #
105
+ # @return [String]
93
106
  #
94
107
  def to_s
95
108
  content_tag :ul, id: @id, class: "nav #{@class}" do
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Bootstrap4Helper
2
- # @description
2
+ # Simple Railtie to hook out module into ActionView.
3
3
  #
4
4
  #
5
5
  class Railtie < ::Rails::Railtie
@@ -1,16 +1,18 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- # @description
6
- # - a simple CSS spinner component.
2
+ # Builds a simple CSS spinner component.
3
+ #
7
4
  #
8
5
  class Spinner < Component
9
- # @description
10
- # -
6
+ # Class constructor
7
+ #
8
+ # @note The different support types are: `:border` and `:grow`
11
9
  #
12
10
  # @param [ActionView] template
13
11
  # @param [Hash] opts
12
+ # @option opts [Symbol] :type
13
+ # @option opts [String] :id
14
+ # @option opts [String] :class
15
+ # @option opts [Hash] :data
14
16
  #
15
17
  def initialize(template, opts = {}, &block)
16
18
  super(template)
@@ -22,8 +24,9 @@ module Bootstrap4Helper
22
24
  @content = block || proc { '' }
23
25
  end
24
26
 
25
- # @description
26
- # -
27
+ # String representation of the object.
28
+ #
29
+ # @return [String]
27
30
  #
28
31
  def to_s
29
32
  content_tag(
@@ -1,17 +1,18 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- # @description
2
+ # Builds a Tab component.
6
3
  #
7
4
  #
8
5
  class Tab < Component
9
- # @description
10
- # -
6
+ # Class constructor
7
+ #
8
+ # @note The support types are: `:tabs` and `:pills`
11
9
  #
12
10
  # @param [ActionView] template
13
11
  # @param [Hash] opts
14
- # @param [Hash]
12
+ # @option opts [Symbol] :type
13
+ # @option opts [String] :id
14
+ # @option opts [String] :class
15
+ # @option opts [Hash] :data
15
16
  #
16
17
  def initialize(template, opts = {}, &block)
17
18
  super(template)
@@ -23,10 +24,11 @@ module Bootstrap4Helper
23
24
  @content = block || proc { '' }
24
25
  end
25
26
 
26
- # @description
27
- # - Builds a custom Nav component for the tabs.
27
+ # Builds a custom Nav component for the tabs.
28
28
  #
29
- # @param [Hash] opts
29
+ # @param [Hash] opts
30
+ # @option opts [String] :class
31
+ # @option opts [Hash] :data
30
32
  # @return [Nav]
31
33
  #
32
34
  def nav(opts = {}, &block)
@@ -41,19 +43,21 @@ module Bootstrap4Helper
41
43
  Nav.new(@template, opts, &block)
42
44
  end
43
45
 
44
- # @description
45
- # - Builds the Content object for the Tab.
46
+ # Builds the Content object for the Tab.
46
47
  #
47
- # @param [Hash] opts
48
+ # @param [Hash] opts
49
+ # @option opts [String] :id
50
+ # @option opts [String] :class
51
+ # @option opts [Hash] :data
48
52
  # @return [Tab::Content]
49
53
  #
50
54
  def content(opts = {}, &block)
51
55
  Content.new(@template, opts, &block)
52
56
  end
53
57
 
54
- # @description
55
- # - This has a weird interaction. Because this object doesn't actually return any wrapping
56
- # string or DOM element, we want to return nil, so that only the output buffer on the sub components are returned.
58
+ # This has a weird interaction. Because this object doesn't actually return any wrapping
59
+ # string or DOM element, we want to return nil, so that only the output buffer on the sub components are
60
+ # returned.
57
61
  # If we return the return value of the block, we will get the last element added to the input
58
62
  # buffer as an unescaped string.
59
63
  #
@@ -1,21 +1,16 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- #
6
- #
7
- #
8
2
  class Tab
9
- #
3
+ # Build a Content component to be used with Tabs
10
4
  #
11
5
  #
12
6
  class Content < Component
13
- # @description
14
- # -
7
+ # Class constructor
15
8
  #
16
9
  # @param [ActionView] template
17
- # @param [NilClass|String|Symbol|Hash] context_or_options
18
- # @param [Hash]
10
+ # @param [Hash] opts
11
+ # @option opts [String] :id
12
+ # @option opts [String] :class
13
+ # @option opts [Hash] :data
19
14
  #
20
15
  def initialize(template, opts = {}, &block)
21
16
  super(template)
@@ -26,19 +21,32 @@ module Bootstrap4Helper
26
21
  @content = block || proc { '' }
27
22
  end
28
23
 
29
- # @description
30
- # -
24
+ # Builds the pane for the tab.
25
+ #
26
+ # @param [Symbol] source
27
+ # @param [Hash] opts
28
+ # @option opts [String] :class
29
+ # @option opts [Hash] :data
30
+ # @return [String]
31
31
  #
32
32
  def pane(source, opts = {}, &block)
33
- id = opts.fetch(:id, nil)
33
+ id = opts.fetch(:id, source)
34
34
  klass = opts.fetch(:class, '')
35
35
  data = opts.fetch(:data, {})
36
36
 
37
- content_tag :div, id: source, class: "tab-pane #{klass}", role: 'tabpanel', &block
37
+ content_tag(
38
+ :div,
39
+ id: id,
40
+ class: "tab-pane #{klass}",
41
+ role: 'tabpanel',
42
+ data: data,
43
+ &block
44
+ )
38
45
  end
39
46
 
40
- # @description
41
- # -
47
+ # String representation of the object.
48
+ #
49
+ # @return [String]
42
50
  #
43
51
  def to_s
44
52
  content_tag :div, id: @id, class: "tab-content #{@class}" do
@@ -1,3 +1,3 @@
1
1
  module Bootstrap4Helper
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.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.0
4
+ version: 1.1.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: 2019-11-08 00:00:00.000000000 Z
11
+ date: 2020-06-12 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
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ - - "<="
18
21
  - !ruby/object:Gem::Version
19
- version: 4.2.11
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
+ - - ">"
25
28
  - !ruby/object:Gem::Version
26
- version: 4.2.11
29
+ version: '4.2'
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: 7.0.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bootstrap
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +64,56 @@ dependencies:
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: 5.2.3
67
+ version: 5.2.4
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: 5.2.3
74
+ version: 5.2.4
75
+ - !ruby/object:Gem::Dependency
76
+ name: redcarpet
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rubocop
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: solargraph
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
69
117
  - !ruby/object:Gem::Dependency
70
118
  name: sqlite3
71
119
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +156,7 @@ files:
108
156
  - lib/bootstrap4_helper/initialize.rb
109
157
  - lib/bootstrap4_helper/modal.rb
110
158
  - lib/bootstrap4_helper/nav.rb
159
+ - lib/bootstrap4_helper/page_header.rb
111
160
  - lib/bootstrap4_helper/railtie.rb
112
161
  - lib/bootstrap4_helper/spinner.rb
113
162
  - lib/bootstrap4_helper/tab.rb
@@ -133,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
182
  - !ruby/object:Gem::Version
134
183
  version: '0'
135
184
  requirements: []
136
- rubygems_version: 3.0.1
185
+ rubygems_version: 3.1.3
137
186
  signing_key:
138
187
  specification_version: 4
139
188
  summary: Library for rapidly building bootstrap 4 components