Skip to content

Commit e504388

Browse files
Merge pull request #299 from basemate/add_wbr_tag
add tested & documented wbr core component
2 parents 5b30413 + 2c8fd7f commit e504388

File tree

5 files changed

+74
-0
lines changed

5 files changed

+74
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
%wbr{@tag_attributes}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Matestack::Ui::Core::Wbr
2+
class Wbr < Matestack::Ui::Core::Component::Static
3+
end
4+
end

docs/components/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ You can build your [own components](/docs/extend/README.md) as well, both static
7474
- [var](/docs/components/var.md)
7575
- [video](/docs/components/video.md)
7676
- [youtube](/docs/components/youtube.md)
77+
- [wbr](/docs/components/wbr.md)
7778

7879
## Dynamic Core Components
7980

docs/components/wbr.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# matestack core component: Wbr
2+
3+
Show [specs](/spec/usage/components/wbr_spec.rb)
4+
5+
The HTML `<wbr>` 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 `<wbr>` should have.
13+
14+
#### # class (optional)
15+
Expects a string with all classes the `<wbr>` should have.
16+
17+
## Example 1: Usage
18+
19+
```ruby
20+
paragraph do
21+
plain 'First part of text'
22+
wbr id: 'foo', class: 'bar'
23+
plain 'Second part of text'
24+
end
25+
```
26+
27+
returns
28+
29+
```html
30+
<p>First part of text<wbr id="foo" class="bar">Second part of text</p>
31+
```

spec/usage/components/wbr_spec.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
require_relative '../../support/utils'
2+
include Utils
3+
4+
describe 'Wbr component', type: :feature, js: true do
5+
it 'Renders a simple and enhanced wbr tag on a page' do
6+
class ExamplePage < Matestack::Ui::Page
7+
def response
8+
components {
9+
# Simple wbr
10+
paragraph do
11+
plain 'First part of text'
12+
wbr
13+
plain 'Second part of text'
14+
end
15+
16+
# Enhanced wbr
17+
paragraph do
18+
plain 'First part of second text'
19+
wbr id: 'special', class: 'nice-wbr'
20+
plain 'Second part of second text'
21+
end
22+
}
23+
end
24+
end
25+
26+
visit '/example'
27+
28+
static_output = page.html
29+
30+
expected_static_output = <<~HTML
31+
<p>First part of text<wbr>Second part of text</p>
32+
<p>First part of second text<wbr id="special" class="nice-wbr">Second part of second text</p>
33+
HTML
34+
35+
expect(stripped(static_output)).to include(stripped(expected_static_output))
36+
end
37+
end

0 commit comments

Comments
 (0)