Skip to content

Commit 6f108bc

Browse files
committed
Added <s> tag to core components
1 parent f9e8504 commit 6f108bc

File tree

4 files changed

+123
-0
lines changed

4 files changed

+123
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
%s{@tag_attributes}
2+
- if options[:text].nil? && block_given?
3+
= yield
4+
- else
5+
= options[:text]

app/concepts/matestack/ui/core/s/s.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Matestack::Ui::Core::S
2+
class S < Matestack::Ui::Core::Component::Static
3+
4+
end
5+
end
6+

docs/components/s.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# matestack core component: s
2+
3+
Show [specs](/spec/usage/components/s_spec.rb)
4+
5+
The HTML `<s>` tag implemented in ruby.
6+
7+
## Parameters
8+
9+
This component can take 3 optional configuration params and optional content.
10+
11+
#### # id (optional)
12+
Expects a string with all ids the s tag should have.
13+
14+
#### # class (optional)
15+
Expects a string with all classes the s tag should have.
16+
17+
#### # text (optional)
18+
Expects a string with the text that s go into the `<s>` tag.
19+
20+
## Example 1
21+
Specifying the text directly
22+
23+
```ruby
24+
s id: "foo", class: "bar" text: "Hello World"
25+
```
26+
27+
returns
28+
29+
```html
30+
<s id="foo" class="bar">Hello World</s>
31+
```
32+
33+
## Example 2
34+
Rendering a content block between the `<s>` tags
35+
36+
```ruby
37+
s id: "foo", class: "bar" do
38+
plain "Hello World"
39+
end
40+
```
41+
42+
returns
43+
44+
```html
45+
<s id="foo" class="bar">Hello World</s>
46+
```

spec/usage/components/s_spec.rb

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
require_relative "../../support/utils"
2+
include Utils
3+
4+
describe 'S 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 s
13+
s do
14+
plain 'I am simple'
15+
end
16+
17+
# enhanced s
18+
s 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+
<s>I am simple</s>
32+
<s id="my-id" class="my-class">I am enhanced</s>
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 s
45+
s text: 'I am simple'
46+
47+
# enhanced s
48+
s 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+
<s>I am simple</s>
60+
<s id="my-id" class="my-class">I am enhanced</s>
61+
HTML
62+
63+
expect(stripped(static_output)).to include(stripped(expected_static_output))
64+
end
65+
66+
end

0 commit comments

Comments
 (0)