Skip to content

Commit 5b9a351

Browse files
Merge pull request #258 from lumisce/figure_tag
Add figure tag
2 parents 2976948 + 6c01816 commit 5b9a351

File tree

5 files changed

+62
-0
lines changed

5 files changed

+62
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
%figure{@tag_attributes}
2+
- if block_given?
3+
= yield
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Matestack::Ui::Core::Figure
2+
class Figure < Matestack::Ui::Core::Component::Static
3+
4+
end
5+
end

docs/components/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ You can build your [own components](/docs/extend/custom_components.md) as well,
88
- [b](/docs/components/b.md)
99
- [br](/docs/components/br.md)
1010
- [div](/docs/components/div.md)
11+
- [figure](/docs/components/figure.md)
1112
- [footer](/docs/components/footer.md)
1213
- [header](/docs/components/header.md)
1314
- [heading](/docs/components/heading.md)

docs/components/figure.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# matestack core component: Figure
2+
3+
Show [specs](/spec/usage/components/figure_spec.rb)
4+
5+
The HTML `<figure>` tag implemented in ruby.
6+
7+
## Parameters
8+
9+
This component can take 2 optional configuration params and optional content.
10+
11+
#### # id (optional)
12+
Expects a string with all ids the figure tag should have.
13+
14+
#### # class (optional)
15+
Expects a string with all classes the figure tag should have.
16+
17+
## Example 1
18+
19+
```ruby
20+
figure id: "foo", class: "bar" do
21+
img path: 'matestack-logo.png', width: 500, height: 300, alt: "logo"
22+
end
23+
```
24+
25+
returns
26+
27+
```html
28+
<figure id="foo" class="bar">
29+
<img src="your-asset-path/matestack-logo.png" width="500" height="300" alt="logo"/>
30+
</figure>
31+
```

spec/usage/components/figure_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require_relative '../../support/utils'
2+
include Utils
3+
4+
describe 'Figure Component', type: :feature, js: true do
5+
6+
it 'Example 1' do
7+
8+
class ExamplePage < Matestack::Ui::Page
9+
def response
10+
components {
11+
figure id: "my-id", class: "my-class" do
12+
img path: 'matestack-logo.png', width: 500, height: 300, alt: "logo"
13+
end
14+
}
15+
end
16+
end
17+
18+
visit '/example'
19+
20+
expect(page).to have_xpath("//figure[@id='my-id' and @class='my-class']/img[contains(@src,'matestack-logo') and @alt='logo' and @width='500' and @height='300']")
21+
end
22+
end

0 commit comments

Comments
 (0)