Skip to content

Commit 196908b

Browse files
committed
Add legend tag
1 parent b97d093 commit 196908b

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
%legend{@tag_attributes}
2+
- if options[:text].nil? && block_given?
3+
= yield
4+
- else
5+
= options[:text]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Matestack::Ui::Core::Legend
2+
class Legend < 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
@@ -36,6 +36,7 @@ You can build your [own components](/docs/extend/custom_components.md) as well,
3636
- [ruby](/docs/components/ruby.md)
3737
- [rt](/docs/components/rb.md)
3838
- [rp](/docs/components/rt.md)
39+
- [legend](/docs/components/legend.md)
3940

4041
## Dynamic Core Components
4142

docs/components/legend.md

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

spec/usage/components/legend_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require_relative '../../support/utils'
2+
include Utils
3+
4+
describe 'Legend Component', type: :feature, js: true do
5+
6+
it 'Example 1' do
7+
8+
class ExamplePage < Matestack::Ui::Page
9+
10+
def response
11+
components {
12+
legend id: 'my-id', class: 'my-class' do
13+
plain 'Hello World' #optional content
14+
end
15+
}
16+
end
17+
18+
end
19+
20+
visit '/example'
21+
22+
static_output = page.html
23+
24+
expected_static_output = <<~HTML
25+
<legend id="my-id" class="my-class">
26+
Hello World
27+
</legend>
28+
HTML
29+
30+
expect(stripped(static_output)).to include(stripped(expected_static_output))
31+
end
32+
33+
end

0 commit comments

Comments
 (0)