Skip to content

Commit c95ebeb

Browse files
committed
Adds blockquote tag to main component
1 parent b811cb3 commit c95ebeb

File tree

4 files changed

+125
-0
lines changed

4 files changed

+125
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
%blockquote{@tag_attributes}
2+
- if options[:text].nil? && block_given?
3+
= yield
4+
- else
5+
= options[:text]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module Matestack::Ui::Core::Blockquote
2+
class Blockquote < Matestack::Ui::Core::Component::Static
3+
def setup
4+
@tag_attributes.merge!({
5+
"cite": options[:cite]
6+
})
7+
end
8+
end
9+
end

docs/components/blockquote.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# matestack core component: Blockquote
2+
3+
Show [specs](../../spec/usage/components/blockquote_spec.rb)
4+
5+
The HTML blockquote tag implemented in ruby.
6+
7+
## Parameters
8+
9+
This component can take 3 optional configuration params and either yield content or display what gets passed to the `text` configuration param.
10+
11+
#### # id (optional)
12+
Expects a string with all ids the span should have.
13+
14+
#### # class (optional)
15+
Expects a string with all classes the span should have.
16+
17+
#### # site (optional)
18+
Expects a string referencing a cite for the blockquote.
19+
20+
## Example 1: Yield a given block
21+
22+
```ruby
23+
blockquote id: "foo", class: "bar", cite: "this is a cite" do
24+
plain 'Hello World' # optional content
25+
end
26+
```
27+
28+
returns
29+
30+
```html
31+
<blockquote cite="this is a cite" id="foo" class="bar">
32+
Hello World
33+
</blockquote>
34+
```
35+
36+
## Example 2: Render options[:text] param
37+
38+
```ruby
39+
span id: "foo", class: "bar", cite: "this is a cite", text: 'Hello World'
40+
```
41+
42+
returns
43+
44+
```html
45+
<span cite="this is a cite" id="foo" class="bar">
46+
Hello World
47+
</span>

spec/usage/components/blockquote.rb

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
require_relative "../../support/utils"
2+
include Utils
3+
4+
describe 'Blockquote Component', type: :feature, js: true do
5+
6+
it 'Example 1 - yield, no options[:text]' do
7+
8+
class ExamplePage < Matestack::Ui::Page
9+
10+
def response
11+
components {
12+
# simple blockquote
13+
blockquote do
14+
plain 'This is simple blockquote text'
15+
end
16+
17+
# enhanced blockquote
18+
blockquote id: 'my-id', class: 'my-class', cite: 'this is a cite' do
19+
plain 'This is a enhanced blockquote with text'
20+
end
21+
}
22+
end
23+
24+
end
25+
26+
visit '/example'
27+
static_output = page.html
28+
29+
expected_static_output = <<~HTML
30+
<blockquote>This is simple blockquote text</blockquote>
31+
<blockquote cite="this is a cite" id="my-id" class="my-class">This is a enhanced blockquote with text</blockquote>
32+
HTML
33+
expect(stripped(static_output)).to include(stripped(expected_static_output))
34+
end
35+
36+
it 'Example 2 - render options[:text]' do
37+
38+
class ExamplePage < Matestack::Ui::Page
39+
40+
def response
41+
components {
42+
# simple blockquote
43+
blockquote text: 'This is simple blockquote text'
44+
45+
# enhanced blockquote
46+
blockquote id: 'my-id', class: 'my-class', cite: 'this is a cite', text: 'This is a enhanced blockquote with text'
47+
}
48+
end
49+
50+
end
51+
52+
visit '/example'
53+
54+
static_output = page.html
55+
56+
expected_static_output = <<~HTML
57+
<blockquote>This is simple blockquote text</blockquote>
58+
<blockquote cite="this is a cite" id="my-id" class="my-class">This is a enhanced blockquote with text</blockquote>
59+
HTML
60+
61+
expect(stripped(static_output)).to include(stripped(expected_static_output))
62+
end
63+
64+
end

0 commit comments

Comments
 (0)