Skip to content

Commit ae33d01

Browse files
committed
Add HTML <em> tag to core components
Closes #188
1 parent f9e8504 commit ae33d01

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
%em{@tag_attributes}
2+
- if options[:text].nil? && block_given?
3+
= yield
4+
- else
5+
= options[:text]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Matestack::Ui::Core::Em
2+
class Em < Matestack::Ui::Core::Component::Static
3+
4+
end
5+
end

spec/usage/components/em_spec.rb

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../../support/utils'
4+
include Utils
5+
6+
describe 'Em Component', type: :feature, js: true do
7+
it 'Example 1 - yield, no options[:text]' do
8+
class ExamplePage < Matestack::Ui::Page
9+
def response
10+
components do
11+
# simple em tag
12+
em do
13+
plain 'Emphasized text'
14+
end
15+
16+
# enhanced em tag
17+
em id: 'my-id', class: 'my-class' do
18+
plain 'Enhanced emphasized text'
19+
end
20+
end
21+
end
22+
end
23+
24+
visit '/example'
25+
26+
static_output = page.html
27+
28+
expected_static_output = <<~HTML
29+
<em>Emphasized text</em>
30+
<em id="my-id" class="my-class">Enhanced emphasized text</em>
31+
HTML
32+
33+
expect(stripped(static_output)).to include(stripped(expected_static_output))
34+
end
35+
36+
it 'Example 2 - render options[:text]' do
37+
class ExamplePage < Matestack::Ui::Page
38+
def response
39+
components do
40+
# simple em
41+
em text: 'Emphasized text'
42+
43+
# enhanced em
44+
em id: 'my-id', class: 'my-class', text: 'Enhanced emphasized text'
45+
end
46+
end
47+
end
48+
49+
visit '/example'
50+
51+
static_output = page.html
52+
53+
expected_static_output = <<~HTML
54+
<em>Emphasized text</em>
55+
<em id="my-id" class="my-class">Enhanced emphasized text</em>
56+
HTML
57+
58+
expect(stripped(static_output)).to include(stripped(expected_static_output))
59+
end
60+
end

0 commit comments

Comments
 (0)