Skip to content

Add figure tag #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/concepts/matestack/ui/core/figure/figure.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
%figure{@tag_attributes}
- if block_given?
= yield
5 changes: 5 additions & 0 deletions app/concepts/matestack/ui/core/figure/figure.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Matestack::Ui::Core::Figure
class Figure < Matestack::Ui::Core::Component::Static

end
end
1 change: 1 addition & 0 deletions docs/components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ You can build your [own components](/docs/extend/custom_components.md) as well,
- [b](/docs/components/b.md)
- [br](/docs/components/br.md)
- [div](/docs/components/div.md)
- [figure](/docs/components/figure.md)
- [footer](/docs/components/footer.md)
- [header](/docs/components/header.md)
- [heading](/docs/components/heading.md)
Expand Down
31 changes: 31 additions & 0 deletions docs/components/figure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# matestack core component: Figure

Show [specs](/spec/usage/components/figure_spec.rb)

The HTML `<figure>` tag implemented in ruby.

## Parameters

This component can take 2 optional configuration params and optional content.

#### # id (optional)
Expects a string with all ids the figure tag should have.

#### # class (optional)
Expects a string with all classes the figure tag should have.

## Example 1

```ruby
figure id: "foo", class: "bar" do
img path: 'matestack-logo.png', width: 500, height: 300, alt: "logo"
end
```

returns

```html
<figure id="foo" class="bar">
<img src="your-asset-path/matestack-logo.png" width="500" height="300" alt="logo"/>
</figure>
```
22 changes: 22 additions & 0 deletions spec/usage/components/figure_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require_relative '../../support/utils'
include Utils

describe 'Figure Component', type: :feature, js: true do

it 'Example 1' do

class ExamplePage < Matestack::Ui::Page
def response
components {
figure id: "my-id", class: "my-class" do
img path: 'matestack-logo.png', width: 500, height: 300, alt: "logo"
end
}
end
end

visit '/example'

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']")
end
end