Skip to content

Commit 34ab700

Browse files
authored
Merge pull request #49 from basemate/hr-component
Add <hr> tag with documentation and spec
2 parents a5870aa + 46b967a commit 34ab700

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

app/concepts/hr/cell/hr.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Hr::Cell
2+
class Hr < Component::Cell::Static
3+
4+
end
5+
end

app/concepts/hr/view/hr.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
%hr{@tag_attributes}

docs/components/hr.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# matestack core component: Hr
2+
3+
Show [specs](../../spec/usage/components/hr_spec.rb)
4+
5+
The HTML `<hr>` 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 hr should have.
13+
14+
#### # class (optional)
15+
Expects a string with all classes the hr should have.
16+
17+
## Example 1
18+
Adding an optional id
19+
20+
```ruby
21+
div id: "foo", class: "bar" do
22+
hr id: "hr-id"
23+
end
24+
```
25+
26+
returns
27+
28+
```html
29+
<div id="foo" class="bar">
30+
<hr id="hr-id">
31+
</div>
32+
```
33+
34+
## Example 2
35+
Adding an optional class
36+
37+
```ruby
38+
div id: "foo", class: "bar" do
39+
hr class: "hr-class"
40+
end
41+
```
42+
43+
returns
44+
45+
```html
46+
<div id="foo" class="bar">
47+
<hr class="hr-class">
48+
</div>
49+
```

spec/usage/components/hr_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require_relative '../../support/utils'
2+
include Utils
3+
4+
describe 'Horizontal Rule Component', type: :feature, js: true do
5+
it 'Renders an hr tag on the page' do
6+
7+
class ExamplePage < Page::Cell::Page
8+
def response
9+
components {
10+
# simple horizontal rule
11+
hr id: 'my-id', class: 'my-class'
12+
}
13+
end
14+
end
15+
16+
visit '/example'
17+
18+
static_output = page.html
19+
20+
expected_static_output = <<~HTML
21+
<hr id="my-id" class="my-class">
22+
HTML
23+
24+
expect(stripped(static_output)).to include(stripped(expected_static_output))
25+
end
26+
end

0 commit comments

Comments
 (0)