Skip to content

Fix issue #208: Add HTML <q> tag to core components #216

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 3 commits into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions app/concepts/matestack/ui/core/q/q.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%q{@tag_attributes}
- if block_given?
= yield
- else
= options[:text]
11 changes: 11 additions & 0 deletions app/concepts/matestack/ui/core/q/q.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Matestack::Ui::Core::Q
class Q < Matestack::Ui::Core::Component::Static

def setup
@tag_attributes.merge!({
"cite": options[:cite]
})
end

end
end
4 changes: 2 additions & 2 deletions docs/components/blockquote.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ The HTML blockquote tag implemented in ruby.
This component can take 3 optional configuration params and either yield content or display what gets passed to the `text` configuration param.

#### # id (optional)
Expects a string with all ids the span should have.
Expects a string with all ids the blockquote should have.

#### # class (optional)
Expects a string with all classes the span should have.
Expects a string with all classes the blockquote should have.

#### # cite (optional)
Expects a string referencing a cite for the blockquote.
Expand Down
50 changes: 50 additions & 0 deletions docs/components/q.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# matestack core component: Q

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

The HTML q tag implemented in ruby.

## Parameters

This component can take 4 optional configuration params and either yield content or display what gets passed to the `text` configuration param.

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

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

#### # text (optional)
Expects a string with the text that should go into the `<q>` tag.

#### # cite (optional)
Expects a string for referencing the source for the quote.

## Example 1: Yield a given block

```ruby
q id: "foo", class: "bar" do
plain 'Hello World' # optional content
end
```

returns

```html
<q id="foo" class="bar">
Hello World
</q>
```

## Example 2: Render options[:text] param

```ruby
q id: "foo", class: "bar", cite: "helloworld.io" text: 'Hello World'
```

returns

```html
<q id="foo" class="bar" cite="helloworld.io">
Hello World
</q>
39 changes: 39 additions & 0 deletions spec/usage/components/q_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require_relative "../../support/utils"
include Utils

describe "Q Component", type: :feature, js: true do

it "Example 1" do

class ExamplePage < Matestack::Ui::Page

def response
components {
#simple q
q text: "A simple quote"

# enhanced q
q id: 'my-id', class: 'my-class', cite: 'www.matestack.org/example' do
plain 'This is a enhanced q with text'
end
}
end

end

visit "/example"

static_output = page.html

expected_static_output = <<~HTML
<q>A simple quote</q>

<q id="my-id" class="my-class"></q>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where the empy <q> tag comes from. Please include it on the page above (between #simple and #enhanced) or remove it.


<q cite="www.matestack.org/example" id="my-id" class="my-class">This is a enhanced q with text</q>
HTML

expect(stripped(static_output)).to include(stripped(expected_static_output))
end

end