File tree Expand file tree Collapse file tree 7 files changed +136
-0
lines changed
app/concepts/matestack/ui/core Expand file tree Collapse file tree 7 files changed +136
-0
lines changed Original file line number Diff line number Diff line change
1
+ %details {@tag_attributes}
2
+ - if block_given?
3
+ = yield
Original file line number Diff line number Diff line change
1
+ module Matestack ::Ui ::Core ::Details
2
+ class Details < Matestack ::Ui ::Core ::Component ::Static
3
+ end
4
+ end
Original file line number Diff line number Diff line change
1
+ %summary {@tag_attributes}
2
+ - if options[:text].blank?
3
+ - if block_given?
4
+ = yield
5
+ - else
6
+ = options[:text]
Original file line number Diff line number Diff line change
1
+ module Matestack ::Ui ::Core ::Summary
2
+ class Summary < Matestack ::Ui ::Core ::Component ::Static
3
+ end
4
+ end
Original file line number Diff line number Diff line change
1
+ # matestack core component: Details
2
+
3
+ Show [ specs] ( ../../spec/usage/components/details_summary_spec.rb )
4
+
5
+ Use details to implement ` <details> ` and ` <summary> ` tags.
6
+
7
+
8
+ ## Parameters
9
+
10
+ ` <details> ` and ` <summary> ` can take two optional configuration params and optional content.
11
+
12
+
13
+ ### Optional configuration
14
+
15
+ #### id (optional)
16
+
17
+ Expects a string with all ids the details tag should have.
18
+
19
+ #### class (optional)
20
+
21
+ Expects a string with all classes the details tag should have.
22
+
23
+
24
+ ## Example 1
25
+
26
+ ``` ruby
27
+ details id: ' foo' , class : ' bar' do
28
+ summary text: ' Greetings'
29
+ plain " Hello World!" # optional content
30
+ end
31
+ ```
32
+
33
+ ``` html
34
+ <details id =" foo" class =" bar" >
35
+ <summary >Greetings</summary >
36
+ Hello World!
37
+ </details >
38
+ ```
39
+
40
+ ## Example 2
41
+
42
+ ``` ruby
43
+ details id: ' foo' , class : ' bar' do
44
+ summary id: ' baz' , text: ' Greetings'
45
+ paragraph text: ' Hello World!'
46
+ end
47
+ ```
48
+
49
+ ``` html
50
+ <details id =" foo" class =" bar" >
51
+ <summary id =" baz" >Greetings</summary >
52
+ <p >Hello World!</p >
53
+ </details >
54
+ ```
55
+
56
+ ## Example 3 (Without Summary)
57
+
58
+ ``` ruby
59
+ details id: ' foo' do
60
+ plain " Hello World!"
61
+ end
62
+ ```
63
+
64
+ ``` html
65
+ <details id =" foo" >
66
+ Hello World!
67
+ </details >
68
+ ```
Original file line number Diff line number Diff line change
1
+ require_relative "../../support/utils"
2
+ include Utils
3
+
4
+ describe 'Details Element with summary' , type : :feature , js : true do
5
+ it 'Example 1' do
6
+ class ExamplePage < Matestack ::Ui ::Page
7
+ def response
8
+ components {
9
+ # basic
10
+ details do
11
+ summary text : 'Hello'
12
+ paragraph text : 'World!'
13
+ end
14
+
15
+ # without summary
16
+ details id : 'foo' do
17
+ plain "Hello World!"
18
+ end
19
+
20
+ # enhanced
21
+ details id : 'detail_id' , class : 'detail_class' do
22
+ summary id : 'summary_id' , class : 'summary_class' , text : 'Hello'
23
+ paragraph text : 'World!'
24
+ end
25
+ }
26
+ end
27
+ end
28
+ visit '/example'
29
+
30
+ static_output = page . html
31
+
32
+ expected_static_output = <<~HTML
33
+
34
+ < details >
35
+ < summary > Hello</ summary >
36
+ < p > World!</ p >
37
+ </ details >
38
+
39
+ < details id ="foo ">
40
+ Hello World!
41
+ </ details >
42
+
43
+ < details id ="detail_id " class ="detail_class ">
44
+ < summary id ="summary_id " class ="summary_class "> Hello</ summary >
45
+ < p > World!</ p >
46
+ </ details >
47
+ HTML
48
+
49
+ expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
50
+ end
51
+ end
You can’t perform that action at this time.
0 commit comments