File tree Expand file tree Collapse file tree 6 files changed +105
-5
lines changed
app/concepts/matestack/ui/core Expand file tree Collapse file tree 6 files changed +105
-5
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
+ pg 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
+ plan " 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 3
3
4
4
describe 'Details Element with summary' , type : :feature , js : true do
5
5
it 'Example 1' do
6
- class ExamplePage < Page :: Cell ::Page
6
+ class ExamplePage < Matestack :: Ui ::Page
7
7
def response
8
8
components {
9
9
# basic
@@ -12,6 +12,11 @@ def response
12
12
pg text : 'World!'
13
13
end
14
14
15
+ # without summary
16
+
17
+ details id : 'foo' do
18
+ plain "Hello World!"
19
+ end
15
20
# enhanced
16
21
details id : 'detail_id' , class : 'detail_class' do
17
22
summary id : 'summary_id' , class : 'summary_class' , text : 'Hello'
@@ -25,10 +30,20 @@ def response
25
30
static_output = page . html
26
31
27
32
expected_static_output = <<~HTML
28
- < details class ="detail_class " id ="detail_id ">
29
- < summary id ="summary_id " class ="summary_class "> Hello</ summary >
30
- < p > World!</ p >
31
- </ details >
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 >
32
47
HTML
33
48
34
49
expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
You can’t perform that action at this time.
0 commit comments