Skip to content

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

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
8 changes: 5 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
**Please make sure to target feature and bugfix requests to develop branch**

## Issue https://github.com/basemate/matestack-ui-core/issues/XXX: Short description here
## Issue https://github.com/basemate/matestack-ui-core/issues/208: Add HTML <q> tag to core components

### Changes

- [x] Describe the changes in one or more bulletpoints
- Created q folder, q.haml and q.rb files to matestack ui core components
- Created q.md to docs > components
- Created q_spec.rb to usage > components

### Notes

- Let the reviewers know something special
- Nothing here
3 changes: 3 additions & 0 deletions app/concepts/matestack/ui/core/q/q.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
%q{@tag_attributes}
- if block_given?
Copy link
Contributor

Choose a reason for hiding this comment

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

I would love this component to have a options[:text, like e.g. the paragraph or span component. Could you implement (and test & document) this?

= yield
5 changes: 5 additions & 0 deletions app/concepts/matestack/ui/core/q/q.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Matestack::Ui::Core::Q
class Q < Matestack::Ui::Core::Component::Static

Copy link
Contributor

Choose a reason for hiding this comment

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

Here, you probably need to merge the cite option into @tag_attributes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, got you.

end
end
47 changes: 47 additions & 0 deletions docs/components/q.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# matestack core component: Q

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

The HTML q tag implemented in ruby.

## Parameters

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

Choose a reason for hiding this comment

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

Again, the cite configuration param is missing


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

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

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

## 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", text: 'Hello World'
Copy link
Contributor

Choose a reason for hiding this comment

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

This example is not tested and for now probably wouldn't work!

```

returns

```html
<q id="foo" class="bar">
Hello World
</q>
19 changes: 19 additions & 0 deletions spec/support/components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,25 @@ def self.specs
websocket_event: true
}
}
},
q: {
type: :static,
tag: "q",
options: {
optional: {
id: :string,
class: :string,
attributes: :hash,
},
required: {}
},
block: true,
optional_dynamics: {
rerender_on: {
client_side_event: true,
websocket_event: true
}
}
}
}
end
Expand Down
44 changes: 44 additions & 0 deletions spec/usage/components/q_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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

#simple q with attributes
q id: "my-id", class: "my-class"

#nested q
q do
q id: "my-nested-q"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please test the text: "This is an example text cite" and cite: "www.matestack.org/example" as well :)

end
}
end

end

visit "/example"

static_output = page.html

expected_static_output = <<~HTML
<q></q>

<q id="my-id" class="my-class"></q>

<q>
<q id="my-nested-q"></q>
</q>
HTML

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

end