File tree Expand file tree Collapse file tree 4 files changed +120
-0
lines changed
app/concepts/matestack/ui/core/dd Expand file tree Collapse file tree 4 files changed +120
-0
lines changed Original file line number Diff line number Diff line change
1
+ %dd {@tag_attributes}
2
+ - if options[:text].nil? && block_given?
3
+ = yield
4
+ - else
5
+ = options[:text]
Original file line number Diff line number Diff line change
1
+ module Matestack ::Ui ::Core ::Dd
2
+ class Dd < Matestack ::Ui ::Core ::Component ::Static
3
+
4
+ end
5
+ end
Original file line number Diff line number Diff line change
1
+ # matestack core component: Dd
2
+
3
+ Show [ specs] ( /spec/usage/components/dd_spec.rb )
4
+
5
+ The HTML dd tag implemented in ruby.
6
+
7
+ ## Parameters
8
+
9
+ This component can take 3 optional configuration params and either yield content or display what gets passed to the ` text ` configuration param.
10
+
11
+ #### # id (optional)
12
+ Expects a string with all ids the ` dd ` should have.
13
+
14
+ #### # class (optional)
15
+ Expects a string with all classes the ` dd ` should have.
16
+
17
+ ## Example 1: Yield a given block
18
+
19
+ ``` ruby
20
+ dd id: " foo" , class : " bar" do
21
+ plain ' Hello World'
22
+ end
23
+ ```
24
+
25
+ returns
26
+
27
+ ``` html
28
+ <dd id =" foo" class =" bar" >
29
+ Hello World
30
+ </dd >
31
+ ```
32
+
33
+ ## Example 2: Render options[ : text ] param
34
+
35
+ ``` ruby
36
+ dd id: " foo" , class : " bar" , text: ' Hello World'
37
+ ```
38
+
39
+ returns
40
+
41
+ ``` html
42
+ <dd id =" foo" class =" bar" >
43
+ Hello World
44
+ </dd >
45
+ ```
46
+
Original file line number Diff line number Diff line change
1
+ require_relative "../../support/utils"
2
+ include Utils
3
+
4
+ describe 'Dd Component' , type : :feature , js : true do
5
+
6
+ it 'Example 1 - yield, no options[:text]' do
7
+
8
+ class ExamplePage < Matestack ::Ui ::Page
9
+
10
+ def response
11
+ components {
12
+ # simple dd tag
13
+ dd do
14
+ plain 'This is simple dd text'
15
+ end
16
+
17
+ # enhanced dd tag
18
+ dd id : 'my-id' , class : 'my-class' do
19
+ plain 'This is a enhanced dd with text'
20
+ end
21
+ }
22
+ end
23
+
24
+ end
25
+
26
+ visit '/example'
27
+ static_output = page . html
28
+
29
+ expected_static_output = <<~HTML
30
+ < dd > This is simple dd text</ dd >
31
+ < dd id ="my-id " class ="my-class "> This is a enhanced dd with text</ dd >
32
+ HTML
33
+ expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
34
+ end
35
+
36
+ it 'Example 2 - render options[:text]' do
37
+
38
+ class ExamplePage < Matestack ::Ui ::Page
39
+
40
+ def response
41
+ components {
42
+ # simple dd tag
43
+ dd text : 'This is simple dd text'
44
+
45
+ # enhanced dd tag
46
+ dd id : 'my-id' , class : 'my-class' , text : 'This is a enhanced dd with text'
47
+ }
48
+ end
49
+
50
+ end
51
+
52
+ visit '/example'
53
+
54
+ static_output = page . html
55
+
56
+ expected_static_output = <<~HTML
57
+ < dd > This is simple dd text</ dd >
58
+ < dd id ="my-id " class ="my-class "> This is a enhanced dd with text</ dd >
59
+ HTML
60
+
61
+ expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
62
+ end
63
+
64
+ end
You can’t perform that action at this time.
0 commit comments