File tree Expand file tree Collapse file tree 3 files changed +40
-3
lines changed
app/concepts/matestack/ui/core/label Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Original file line number Diff line number Diff line change 1
1
module Matestack ::Ui ::Core ::Label
2
2
class Label < Matestack ::Ui ::Core ::Component ::Static
3
-
3
+ def setup
4
+ @tag_attributes . merge! ( {
5
+ for : options [ :for ]
6
+ } )
7
+ end
4
8
end
5
9
end
Original file line number Diff line number Diff line change 1
1
# matestack core component: Label
2
2
3
3
Show [ specs] ( /spec/usage/components/label_spec.rb )
4
+
5
+
6
+ The HTML label tag implemented in ruby.
7
+
8
+ ## Parameters
9
+
10
+ This component can take 3 optional configuration params and optional content.
11
+
12
+ #### # id (optional)
13
+ Expects a string with all ids the div should have.
14
+
15
+ #### # class (optional)
16
+ Expects a string with all classes the div should have.
17
+
18
+ #### # for (optional)
19
+ Expects a string that binds the label to a given form element
20
+
21
+ ## Example
22
+
23
+ ``` ruby
24
+ label id: " foo" , class : " bar" , for: ' input_id' do
25
+ plain ' Label For Element' # optional content
26
+ end
27
+ ```
28
+
29
+ returns
30
+
31
+ ``` html
32
+ <label for =" input_id" id =" foo" class =" bar" >
33
+ Label For Element
34
+ </label >
35
+ ```
36
+
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ def response
13
13
label text : 'I am simple'
14
14
15
15
# enhanced label
16
- label id : 'my-id' , class : 'my-class' do
16
+ label id : 'my-id' , for : 'label for something' , class : 'my-class' do
17
17
plain 'I am enhanced'
18
18
end
19
19
}
@@ -27,7 +27,7 @@ def response
27
27
28
28
expected_static_output = <<~HTML
29
29
< label > I am simple</ label >
30
- < label id ="my-id " class ="my-class "> I am enhanced</ label >
30
+ < label for =" label for something " id ="my-id " class ="my-class "> I am enhanced</ label >
31
31
HTML
32
32
33
33
expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
You can’t perform that action at this time.
0 commit comments