Skip to content

Commit 3d27f92

Browse files
committed
Add the figure component
1 parent cfe888e commit 3d27f92

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-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/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)