File tree Expand file tree Collapse file tree 4 files changed +126
-0
lines changed
app/concepts/matestack/ui/core/dfn Expand file tree Collapse file tree 4 files changed +126
-0
lines changed Original file line number Diff line number Diff line change 1+ %dfn {@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 ::Dfn
2+ class Dfn < Matestack ::Ui ::Core ::Component ::Static
3+
4+ end
5+ end
6+
Original file line number Diff line number Diff line change 1+ # matestack core component: Hr
2+
3+ Show [ specs] ( /spec/usage/components/dfn_spec.rb )
4+
5+ The HTML ` <dfn> ` tag implemented in ruby.
6+
7+ ## Parameters
8+
9+ This component can take 2 optional configuration params.
10+
11+ #### # id (optional)
12+ Expects a string with all ids the dfn should have.
13+
14+ #### # class (optional)
15+ Expects a string with all classes the dfn should have.
16+
17+ ## Example 1
18+ Adding an optional id
19+
20+ ``` ruby
21+ div id: " foo" , class : " bar" do
22+ dfn id: " dfn-id"
23+ end
24+ ```
25+
26+ returns
27+
28+ ``` html
29+ <div id =" foo" class =" bar" >
30+ <dfn id =" dfn-id" >
31+ </div >
32+ ```
33+
34+ ## Example 2
35+ Adding an optional class
36+
37+ ``` ruby
38+ div id: " foo" , class : " bar" do
39+ dfn class : " dfn-class"
40+ end
41+ ```
42+
43+ returns
44+
45+ ``` html
46+ <div id =" foo" class =" bar" >
47+ <dfn class =" dfn-class" >
48+ </div >
49+ ```
Original file line number Diff line number Diff line change 1+ require_relative "../../support/utils"
2+ include Utils
3+
4+ describe 'dfn 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 dfn
13+ dfn do
14+ plain 'I am simple'
15+ end
16+
17+ # enhanced dfn
18+ dfn id : 'my-id' , class : 'my-class' do
19+ plain 'I am enhanced'
20+ end
21+ }
22+ end
23+
24+ end
25+
26+ visit '/example'
27+
28+ static_output = page . html
29+
30+ expected_static_output = <<~HTML
31+ < dfn > I am simple</ dfn >
32+ < dfn id ="my-id " class ="my-class "> I am enhanced</ dfn >
33+ HTML
34+
35+ expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
36+ end
37+
38+ it 'Example 2 - render options[:text]' do
39+
40+ class ExamplePage < Matestack ::Ui ::Page
41+
42+ def response
43+ components {
44+ # simple dfn
45+ dfn text : 'I am simple'
46+
47+ # enhanced dfn
48+ dfn id : 'my-id' , class : 'my-class' , text : 'I am enhanced'
49+ }
50+ end
51+
52+ end
53+
54+ visit '/example'
55+
56+ static_output = page . html
57+
58+ expected_static_output = <<~HTML
59+ < dfn > I am simple</ dfn >
60+ < dfn id ="my-id " class ="my-class "> I am enhanced</ dfn >
61+ HTML
62+
63+ expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
64+ end
65+
66+ end
You can’t perform that action at this time.
0 commit comments