bootstrap4_helper 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,15 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- # @description
6
- # - Used to build groups of Accordions, that are all synced with each other.
2
+ # Used to build groups of Accordions, that are all synced with each other.
3
+ #
7
4
  #
8
5
  class AccordionGroup < Component
9
- # @description
10
- # -
6
+ # Class constructor
11
7
  #
12
8
  # @param [ActionView] template
13
- # @param [NilClass|String|Symbol|Hash] opts
14
- # @param [Hash]
9
+ # @param [Hash] opts
10
+ # @option opts [String] :id
11
+ # @option opts [String] :class
12
+ # @option opts [Hash] :data
15
13
  #
16
14
  def initialize(template, opts = {}, &block)
17
15
  super(template)
@@ -22,8 +20,7 @@ module Bootstrap4Helper
22
20
  @content = block || proc { '' }
23
21
  end
24
22
 
25
- # @description
26
- # - Used to build a `Accordion` for the `AccordionGroup`.
23
+ # Used to build a `Accordion` for the `AccordionGroup`.
27
24
  #
28
25
  # @param [Mixed] args
29
26
  # @return [Accordion]
@@ -40,8 +37,7 @@ module Bootstrap4Helper
40
37
  Accordion.new(self, *opts, &block)
41
38
  end
42
39
 
43
- # @description
44
- # - Used to get the HTML markup of the `AccordionGroup`
40
+ # Used to get the HTML markup of the `AccordionGroup`
45
41
  #
46
42
  # @return [String]
47
43
  #
@@ -1,35 +1,13 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- # @description
6
- # - The Alert helper is meant to help you rapidly build Bootstrap Alert
2
+ # The Alert helper is meant to help you rapidly build Bootstrap Alert
7
3
  # components quickly and easily. The dissmiss button is optional.
8
4
  #
9
- # <code>
10
- # <%= alert_helper :warning, dismissable: true do %>
11
- # <% if @model.errors.present? %>
12
- # <p>Some kind of error</p>
13
- # <% end %>
14
- # <% end %>
15
- #
16
- # <%= alert_helper(:success, dismissible: true) { "Successful save"}
17
- # </code>
18
- #
19
5
  class Alert < Component
20
- # @description
21
- # - Used to generate Bootstrap alert components quickly.
6
+ # Class constructor
22
7
  #
23
8
  # @param [Class] template - Template in which your are binding too.
24
- # @param [NilClass|String|Symbol|Hash] - Bootstrap class context, or options hash.
9
+ # @param [NilClass|String|Symbol|Hash] context_or_options
25
10
  # @param [Hash] opts
26
- # <code>
27
- # opts = {
28
- # id: [String] - ID of the alert box
29
- # class: [String] - Additional classes for the alert box
30
- # }
31
- # </code>
32
- # @param [Proc] &block
33
11
  # @return [Alert]
34
12
  #
35
13
  def initialize(template, context_or_options = nil, opts = {}, &block)
@@ -42,8 +20,7 @@ module Bootstrap4Helper
42
20
  @content = block || proc { '' }
43
21
  end
44
22
 
45
- # @description
46
- # - The dissmiss button, if the element has one.
23
+ # The dissmiss button, if the element has one.
47
24
  #
48
25
  # @return [String]
49
26
  #
@@ -53,8 +30,7 @@ module Bootstrap4Helper
53
30
  end
54
31
  end
55
32
 
56
- # @description
57
- # - Used to render out the Alert component.
33
+ # Used to render out the Alert component.
58
34
  #
59
35
  # @return [String]
60
36
  #
@@ -67,8 +43,7 @@ module Bootstrap4Helper
67
43
 
68
44
  private
69
45
 
70
- # @description
71
- # - Used to get the container classes.
46
+ # Used to get the container classes.
72
47
  #
73
48
  # @return [String]
74
49
  #
@@ -1,17 +1,13 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- # @description
6
- # - Creates Bootstrap badge components that can be used anywhere.
2
+ # Creates Bootstrap badge components that can be used anywhere.
3
+ #
7
4
  #
8
5
  class Badge < Component
9
- # @description
10
- # -
6
+ # Class constructor
11
7
  #
12
8
  # @param [ActionView] template
13
- # @param [NilClass|String|Symbol|Hash] context_or_options.
14
- # @param [Hash] opts
9
+ # @param [NilClass|String|Symbol|Hash] context_or_options
10
+ # @param [Hash] opts
15
11
  #
16
12
  def initialize(template, context_or_options = nil, opts = {}, &block)
17
13
  super(template)
@@ -22,8 +18,8 @@ module Bootstrap4Helper
22
18
  @content = block || proc { '' }
23
19
  end
24
20
 
25
- # @description
26
- # -
21
+ # String representation of the object.
22
+ #
27
23
  #
28
24
  def to_s
29
25
  content_tag(config(:badge, :span), id: @id, class: container_class) { @content.call(self) }
@@ -31,8 +27,7 @@ module Bootstrap4Helper
31
27
 
32
28
  private
33
29
 
34
- # @description
35
- # - Used to get the container classes.
30
+ # Used to get the container classes.
36
31
  #
37
32
  # @return [String]
38
33
  #
@@ -1,16 +1,15 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- # @description
6
- # - Used to build Bootstrap Card components. Cards are wildly used through Bootstrap 4.
2
+ # Used to build Bootstrap Card components. Cards are wildly used through Bootstrap 4.
3
+ #
7
4
  #
8
5
  class Card < Component
9
- # @description
10
- # - Used to initialize a new Card component.
6
+ # Used to initialize a new Card component.
11
7
  #
12
- # @param [ActionView] template
13
- # @param [Hash] opts
8
+ # @param [ActionView] template
9
+ # @param [Hash] opts
10
+ # @option opts [String] :id
11
+ # @option opts [String] :class
12
+ # @option opts [Hash] :data
14
13
  # @return [Card]
15
14
  #
16
15
  def initialize(template, opts = {}, &block)
@@ -22,68 +21,81 @@ module Bootstrap4Helper
22
21
  @content = block || proc { '' }
23
22
  end
24
23
 
25
- # @description
26
- # - Builds the Header component.
24
+ # Builds the Header component.
27
25
  #
28
- # @param [Hash] args
26
+ # @param [Hash] args
27
+ # @option args [String] :id
28
+ # @option args [String] :class
29
+ # @option args [Hash] :data
29
30
  # @return [String]
30
31
  #
31
32
  def header(args = {}, &block)
32
33
  build_base_component :header, args, &block
33
34
  end
34
35
 
35
- # @description
36
- # - Builds the Body component.
36
+ # Builds the Body component.
37
37
  #
38
- # @param [Hash] args
38
+ # @param [Hash] args
39
+ # @option args [String] :id
40
+ # @option args [String] :class
41
+ # @option args [Hash] :data
39
42
  # @return [String]
40
43
  #
41
44
  def body(args = {}, &block)
42
45
  build_base_component :body, args, &block
43
46
  end
44
47
 
45
- # @description
46
- # - Builds the Footer component.
48
+ # Builds the Footer component.
47
49
  #
48
- # @param [Hash] args
50
+ # @param [Hash] args
51
+ # @option args [String] :id
52
+ # @option args [String] :class
53
+ # @option args [Hash] :data
49
54
  # @return [String]
50
55
  #
51
56
  def footer(args = {}, &block)
52
57
  build_base_component :footer, args, &block
53
58
  end
54
59
 
55
- # @description
56
- # - Builds a Title component.
60
+ # Builds a Title component.
57
61
  #
58
- # @param [Hash] args
62
+ # @param [Hash] args
63
+ # @option args [String] :id
64
+ # @option args [String] :class
65
+ # @option args [Hash] :data
59
66
  # @return [String]
60
67
  #
61
68
  def title(args = {}, &block)
62
69
  build_sub_component config(:card_title, :h5), :title, args, &block
63
70
  end
64
71
 
65
- # @description
66
- # - Builds a Text component.
72
+ # Builds a Text component.
67
73
  #
68
- # @param [Hash] args
74
+ # @param [Hash] args
75
+ # @option args [String] :id
76
+ # @option args [String] :class
77
+ # @option args [Hash] :data
69
78
  # @return [String]
70
79
  #
71
80
  def text(args = {}, &block)
72
81
  build_sub_component config(:card_text, :p), :text, args, &block
73
82
  end
74
83
 
75
- # @description
76
- # - Builds a Img Overlay component.
84
+ # Builds a Img Overlay component.
77
85
  #
78
- # @param [Hash] args
86
+ # @param [Hash] args
87
+ # @option args [String] :id
88
+ # @option args [String] :class
89
+ # @option args [Hash] :data
79
90
  # @return [String]
80
91
  #
81
92
  def image_overlay(args = {}, &block)
82
93
  build_base_component 'img-overlay', args, &block
83
94
  end
84
95
 
85
- # @description
86
- # - Outputs the Object in its String representation.
96
+ # Outputs the Object in its String representation.
97
+ #
98
+ # @return [String]
87
99
  #
88
100
  def to_s
89
101
  content_tag :div, id: @id, class: "card #{@class}", data: @data do
@@ -93,23 +105,24 @@ module Bootstrap4Helper
93
105
 
94
106
  private
95
107
 
96
- # @description
97
- # - Used to build basic DIV components.
108
+ # Used to build basic DIV components.
98
109
  #
99
- # @param [String] type
100
- # @param [Mixed] args
110
+ # @param [String] type
111
+ # @param [Mixed] args
101
112
  # @return [String]
102
113
  #
103
114
  def build_base_component(type, args, &block)
104
115
  build_sub_component :div, type, args, &block
105
116
  end
106
117
 
107
- # @description
108
- # - Used to build various DOM components.
109
- #
110
- # @param [Symbol] tag
111
- # @param [String] type
112
- # @param [Mixed] args
118
+ # Used to build various DOM components.
119
+ #
120
+ # @param [Symbol] tag
121
+ # @param [String] type
122
+ # @param [Hash] args
123
+ # @option args [String] :id
124
+ # @option args [String] :class
125
+ # @option args [Hash] :data
113
126
  # @return [String]
114
127
  #
115
128
  def build_sub_component(tag, type, args, &block)
@@ -1,13 +1,10 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- # @description
2
+ # Creates a Card Column Component.
6
3
  #
7
4
  #
8
5
  class CardColumn < CardGrouping
9
- # @description
10
- # -
6
+ # String representation of the object.
7
+ #
11
8
  #
12
9
  def to_s
13
10
  content_tag :div, id: @id, class: "card-columns #{@class}", data: @data do
@@ -1,13 +1,10 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- # @description
2
+ # Creates a Card Deck component
6
3
  #
7
4
  #
8
5
  class CardDeck < CardGrouping
9
- # @description
10
- # -
6
+ # String representation of the object.
7
+ #
11
8
  #
12
9
  def to_s
13
10
  content_tag :div, id: @id, class: "card-deck #{@class}", data: @data do
@@ -1,13 +1,10 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- # @description
2
+ # Creates a Card Group component
6
3
  #
7
4
  #
8
5
  class CardGroup < CardGrouping
9
- # @description
10
- # -
6
+ # String representation of the object
7
+ #
11
8
  #
12
9
  def to_s
13
10
  content_tag :div, id: @id, class: "card-group #{@class}", data: @data do
@@ -1,16 +1,15 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- # @description
2
+ # Class for other Card group type components to inherit from.
6
3
  #
7
4
  #
8
5
  class CardGrouping < Component
9
- # @description
10
- # - Used to initialize a new Card Group.
6
+ # Used to initialize a new Card Grouping.
11
7
  #
12
8
  # @param [Class] template
13
9
  # @param [Hash] opts
10
+ # @option opts [String] :id
11
+ # @option opts [String] :class
12
+ # @option opts [Hash] :data
14
13
  # @return [Card]
15
14
  #
16
15
  def initialize(template, opts = {}, &block)
@@ -22,8 +21,7 @@ module Bootstrap4Helper
22
21
  @content = block || proc { '' }
23
22
  end
24
23
 
25
- # @description
26
- # - Builds a `Card` for the grouping class.
24
+ # Builds a `Card` for the grouping class.
27
25
  #
28
26
  # @param [Hash] opts
29
27
  # @return [Card]
@@ -1,37 +1,33 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- # @description
6
- # - This super class is meant to contain commonly used methods that
2
+ # This super class is meant to contain commonly used methods that
7
3
  # all sub classes can leverage.
8
4
  #
9
- # @note
10
- # - Every component that inherits from this class, needs to call the parent
11
- # initialization method! In order to properly render erb blocks within the
12
- # proper context, we need the template. The only way to get this, is to pass
13
- # in the template.
5
+ # @note Every component that inherits from this class, needs to call the parent
6
+ # initialization method! In order to properly render erb blocks within the
7
+ # proper context, we need the template. The only way to get this, is to pass
8
+ # in the template.
14
9
  #
15
- # @note
16
- # - the `context` mentioned above, refers to the context of `@template` and
17
- # not to be confused with `@context` that can be found in the sub classes.
18
- # `@context` refers to the Bootstrap class context of the component.
10
+ # @note the `context` mentioned above, refers to the context of `@template` and
11
+ # not to be confused with `@context` that can be found in the sub classes.
12
+ # `@context` refers to the Bootstrap class context of the component.
19
13
  #
20
14
  class Component
21
- # @description
22
- # - Used to ensure that the helpers always have the propert context for
15
+ # Used to ensure that the helpers always have the propert context for
23
16
  # rendering and bindings.
24
17
  #
25
- # @param [Class] template - the context of the bindings
18
+ # @param [Class] template
26
19
  #
27
20
  def initialize(template)
28
21
  @template = template
29
22
  end
30
23
 
31
- # @description
32
- # - Used to pass all context of content_tag to the template. This ensures
24
+ # Used to pass all context of content_tag to the template. This ensures
33
25
  # proper template binding of variables and methods!
34
26
  #
27
+ # @param [String] name
28
+ # @param [Hash|NilClass] content_or_options_with_block
29
+ # @param [Hash|NilClass] options
30
+ # @param [Boolean] escape
35
31
  # @return [String]
36
32
  #
37
33
  def content_tag(
@@ -50,31 +46,33 @@ module Bootstrap4Helper
50
46
  )
51
47
  end
52
48
 
53
- # @description
54
- # -
49
+ # Used to pass all context of the capture tag to then template. This ensures
50
+ # proper template binding of variables and methods!
51
+ #
52
+ # @param [Mixed] args
53
+ # @return [String]
55
54
  #
56
55
  def capture(*args)
57
56
  @template.capture(*args)
58
57
  end
59
58
 
60
- # @description
61
- # - Used to pass all concat references to the template. This ensures proper
59
+ # Used to pass all concat references to the template. This ensures proper
62
60
  # binding. Concat adds a String to the template Output buffer. Useful when
63
61
  # trying to add a String with no block.
64
62
  #
65
- # @params [String] text
63
+ # @param [String] text
64
+ # @return [String]
66
65
  #
67
66
  def concat(text)
68
67
  @template.concat(text)
69
68
  end
70
69
 
71
- # @description
72
- # - Used to parse method arguments. If the first argument is
70
+ # Used to parse method arguments. If the first argument is
73
71
  # a Hash, then it is assumed that the user left off the bootstrap
74
72
  # contectual class. So we will assign it to `secondary` and
75
73
  # return the Hash to be used as options.
76
74
  #
77
- # @params [Hash|NilClass|String|Symbol] *args
75
+ # @param [Hash|NilClass|String|Symbol] args
78
76
  # @return [Array]
79
77
  #
80
78
  def parse_arguments(*args)
@@ -87,8 +85,7 @@ module Bootstrap4Helper
87
85
  end
88
86
  end
89
87
 
90
- # @description
91
- # - Used to generate a (hopefully) unique ID for DOM elements. Used as a
88
+ # Used to generate a (hopefully) unique ID for DOM elements. Used as a
92
89
  # fallback if the user doesn't specify one.
93
90
  #
94
91
  # @return [String]
@@ -97,10 +94,9 @@ module Bootstrap4Helper
97
94
  (0...10).map { rand(65..90).chr }.join
98
95
  end
99
96
 
100
- # @description
101
- # - Used to get config settings inside of components quicker.
97
+ # Used to get config settings inside of components quicker.
102
98
  #
103
- # @param [Symbol] setting
99
+ # @param [Symbol] setting
104
100
  # @return [Mixed]
105
101
  #
106
102
  def config(setting, fallback)