Skip to content

Commit 74c0242

Browse files
Merge branch 'develop' into develop
2 parents 0cae1de + a476da4 commit 74c0242

File tree

5 files changed

+90
-0
lines changed

5 files changed

+90
-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
- [noscript](/docs/components/noscript.md)
4041

4142
## Dynamic Core Components

docs/components/legend.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# matestack core component: Legend
2+
3+
Show [specs](/spec/usage/components/legend_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 legend should have.
13+
14+
#### # class (optional)
15+
Expects a string with all classes the legend should have.
16+
17+
## Example 1: Yield a given block
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+
```
32+
33+
## Example 2: Render options[:text] param
34+
35+
```ruby
36+
legend id: "foo", class: "bar", text: 'Hello World'
37+
```
38+
39+
returns
40+
41+
```html
42+
<legend id="foo" class="bar">
43+
Hello World
44+
</legend>

spec/usage/components/legend_spec.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 text: 'I am simple'
13+
14+
# enhanced legend
15+
legend id: 'my-id', class: 'my-class' do
16+
plain 'I am enhanced'
17+
end
18+
}
19+
end
20+
21+
end
22+
23+
visit '/example'
24+
25+
static_output = page.html
26+
27+
expected_static_output = <<~HTML
28+
<legend>I am simple</legend>
29+
<legend id="my-id" class="my-class">I am enhanced</legend>
30+
HTML
31+
32+
expect(stripped(static_output)).to include(stripped(expected_static_output))
33+
end
34+
35+
end

0 commit comments

Comments
 (0)