bootstrap4_helper 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +489 -4
- data/lib/bootstrap4_helper.rb +67 -69
- data/lib/bootstrap4_helper/accordion.rb +18 -21
- data/lib/bootstrap4_helper/accordion_group.rb +9 -13
- data/lib/bootstrap4_helper/alert.rb +6 -31
- data/lib/bootstrap4_helper/badge.rb +8 -13
- data/lib/bootstrap4_helper/card.rb +52 -39
- data/lib/bootstrap4_helper/card_column.rb +3 -6
- data/lib/bootstrap4_helper/card_deck.rb +3 -6
- data/lib/bootstrap4_helper/card_group.rb +3 -6
- data/lib/bootstrap4_helper/card_grouping.rb +6 -8
- data/lib/bootstrap4_helper/component.rb +28 -32
- data/lib/bootstrap4_helper/configuration.rb +9 -10
- data/lib/bootstrap4_helper/constants.rb +3 -5
- data/lib/bootstrap4_helper/dropdown.rb +23 -20
- data/lib/bootstrap4_helper/dropdown/menu.rb +42 -25
- data/lib/bootstrap4_helper/initialize.rb +2 -7
- data/lib/bootstrap4_helper/modal.rb +54 -37
- data/lib/bootstrap4_helper/nav.rb +32 -19
- data/lib/bootstrap4_helper/page_header.rb +38 -0
- data/lib/bootstrap4_helper/railtie.rb +1 -1
- data/lib/bootstrap4_helper/spinner.rb +12 -9
- data/lib/bootstrap4_helper/tab.rb +20 -16
- data/lib/bootstrap4_helper/tab/content.rb +25 -17
- data/lib/bootstrap4_helper/version.rb +1 -1
- metadata +58 -9
@@ -1,17 +1,16 @@
|
|
1
|
-
# @root
|
2
|
-
#
|
3
|
-
#
|
4
1
|
module Bootstrap4Helper
|
5
|
-
#
|
6
|
-
#
|
2
|
+
# Builds a Nav Component that can be used in other components.
|
3
|
+
#
|
7
4
|
#
|
8
5
|
class Nav < Component
|
9
|
-
#
|
10
|
-
# -
|
6
|
+
# Class constructor
|
11
7
|
#
|
12
|
-
# @param [ActionView]
|
13
|
-
# @param [
|
14
|
-
# @
|
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
|
-
#
|
29
|
-
|
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
|
-
#
|
58
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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,16 +1,18 @@
|
|
1
|
-
# @root
|
2
|
-
#
|
3
|
-
#
|
4
1
|
module Bootstrap4Helper
|
5
|
-
#
|
6
|
-
#
|
2
|
+
# Builds a simple CSS spinner component.
|
3
|
+
#
|
7
4
|
#
|
8
5
|
class Spinner < Component
|
9
|
-
#
|
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
|
-
#
|
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
|
-
#
|
2
|
+
# Builds a Tab component.
|
6
3
|
#
|
7
4
|
#
|
8
5
|
class Tab < Component
|
9
|
-
#
|
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
|
-
# @
|
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
|
-
#
|
27
|
-
# - Builds a custom Nav component for the tabs.
|
27
|
+
# Builds a custom Nav component for the tabs.
|
28
28
|
#
|
29
|
-
# @param
|
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
|
-
#
|
45
|
-
# - Builds the Content object for the Tab.
|
46
|
+
# Builds the Content object for the Tab.
|
46
47
|
#
|
47
|
-
# @param
|
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
|
-
#
|
55
|
-
#
|
56
|
-
#
|
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
|
-
#
|
14
|
-
# -
|
7
|
+
# Class constructor
|
15
8
|
#
|
16
9
|
# @param [ActionView] template
|
17
|
-
# @param [
|
18
|
-
# @
|
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
|
-
#
|
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,
|
33
|
+
id = opts.fetch(:id, source)
|
34
34
|
klass = opts.fetch(:class, '')
|
35
35
|
data = opts.fetch(:data, {})
|
36
36
|
|
37
|
-
content_tag
|
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
|
-
#
|
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
|
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.
|
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:
|
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:
|
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
|
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.
|
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.
|
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.
|
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
|