Skip to content

Commit 4ed2f62

Browse files
Merge pull request #216 from GrantBarry/develop
Fix issue #208: Add HTML <q> tag to core components
2 parents 225c6be + 458ead6 commit 4ed2f62

File tree

5 files changed

+104
-2
lines changed

5 files changed

+104
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
%q{@tag_attributes}
2+
- if block_given?
3+
= yield
4+
- else
5+
= options[:text]

app/concepts/matestack/ui/core/q/q.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module Matestack::Ui::Core::Q
2+
class Q < Matestack::Ui::Core::Component::Static
3+
4+
def setup
5+
@tag_attributes.merge!({
6+
"cite": options[:cite]
7+
})
8+
end
9+
10+
end
11+
end

docs/components/blockquote.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ The HTML blockquote tag implemented in ruby.
99
This component can take 3 optional configuration params and either yield content or display what gets passed to the `text` configuration param.
1010

1111
#### # id (optional)
12-
Expects a string with all ids the span should have.
12+
Expects a string with all ids the blockquote should have.
1313

1414
#### # class (optional)
15-
Expects a string with all classes the span should have.
15+
Expects a string with all classes the blockquote should have.
1616

1717
#### # cite (optional)
1818
Expects a string referencing a cite for the blockquote.

docs/components/q.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# matestack core component: Q
2+
3+
Show [specs](../../spec/usage/components/q_spec.rb)
4+
5+
The HTML q tag implemented in ruby.
6+
7+
## Parameters
8+
9+
This component can take 4 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 quote should have.
13+
14+
#### # class (optional)
15+
Expects a string with all classes the quote should have.
16+
17+
#### # text (optional)
18+
Expects a string with the text that should go into the `<q>` tag.
19+
20+
#### # cite (optional)
21+
Expects a string for referencing the source for the quote.
22+
23+
## Example 1: Yield a given block
24+
25+
```ruby
26+
q id: "foo", class: "bar" do
27+
plain 'Hello World' # optional content
28+
end
29+
```
30+
31+
returns
32+
33+
```html
34+
<q id="foo" class="bar">
35+
Hello World
36+
</q>
37+
```
38+
39+
## Example 2: Render options[:text] param
40+
41+
```ruby
42+
q id: "foo", class: "bar", cite: "helloworld.io" text: 'Hello World'
43+
```
44+
45+
returns
46+
47+
```html
48+
<q id="foo" class="bar" cite="helloworld.io">
49+
Hello World
50+
</q>

spec/usage/components/q_spec.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
require_relative "../../support/utils"
2+
include Utils
3+
4+
describe "Q 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+
#simple q
13+
q text: "A simple quote"
14+
15+
# enhanced q
16+
q id: 'my-id', class: 'my-class', cite: 'www.matestack.org/example' do
17+
plain 'This is a enhanced q with text'
18+
end
19+
}
20+
end
21+
22+
end
23+
24+
visit "/example"
25+
26+
static_output = page.html
27+
28+
expected_static_output = <<~HTML
29+
<q>A simple quote</q>
30+
<q cite="www.matestack.org/example" id="my-id" class="my-class">This is a enhanced q with text</q>
31+
HTML
32+
33+
expect(stripped(static_output)).to include(stripped(expected_static_output))
34+
end
35+
36+
end

0 commit comments

Comments
 (0)