-
-
Notifications
You must be signed in to change notification settings - Fork 43
rename pg component to paragraph component #48
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Paragraph::Cell | ||
class Paragraph < Component::Cell::Static | ||
|
||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
- if options[:text].nil? | ||
%p{@tag_attributes} | ||
- if block_given? | ||
= yield | ||
|
||
- else | ||
%p{@tag_attributes} | ||
= options[:text] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# matestack core component: Paragraph | ||
|
||
Show [specs](../../spec/usage/components/paragraph_spec.rb) | ||
|
||
The HTML `<p>` tag implemented in ruby. This is a workaround because the single `p` is the short version of `puts` in ruby. | ||
|
||
## Parameters | ||
|
||
This component can take 3 optional configuration params and optional content. | ||
|
||
#### # id (optional) | ||
Expects a string with all ids the p should have. | ||
|
||
#### # class (optional) | ||
Expects a string with all classes the p should have. | ||
|
||
#### # text (optional) | ||
Expects a string with the text that should go into the `<p>` tag. | ||
|
||
## Example 1 | ||
Specifying the text directly | ||
|
||
```ruby | ||
div id: "foo", class: "bar" do | ||
paragraph text: "Hello World" | ||
end | ||
``` | ||
|
||
returns | ||
|
||
```html | ||
<div id="foo" class="bar"> | ||
<p>Hello World</p> | ||
</div> | ||
``` | ||
|
||
## Example 2 | ||
Rendering a content block between the `<p>` tags | ||
|
||
```ruby | ||
div id: "foo", class: "bar" do | ||
paragraph do | ||
plain "Hello World" | ||
end | ||
end | ||
``` | ||
|
||
returns | ||
|
||
```html | ||
<div id="foo" class="bar"> | ||
<p>Hello World</p> | ||
</div> | ||
``` | ||
|
||
## Example 3 | ||
Rendering a `<span>` tag into `<p>` tags | ||
|
||
```ruby | ||
paragraph id: "foo", class: "bar" do | ||
span do | ||
plain "Hello World" | ||
end | ||
end | ||
``` | ||
|
||
returns | ||
|
||
```html | ||
<p id="foo" class="bar"> | ||
<span>Hello World</span> | ||
</p> | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,5 @@ | ||
# matestack core component: Pg | ||
# matestack core component: PG | ||
|
||
Show [specs](../../spec/usage/components/pg_spec.rb) | ||
|
||
The HTML `<p>` tag implemented in ruby. This is a workaround because the single `p` is the short version of `puts` in ruby. | ||
|
||
## Parameters | ||
|
||
This component can take 3 optional configuration params and optional content. | ||
|
||
#### # id (optional) | ||
Expects a string with all ids the p should have. | ||
|
||
#### # class (optional) | ||
Expects a string with all classes the p should have. | ||
|
||
#### # text (optional) | ||
Expects a string with the text that should go into the `<p>` tag. | ||
|
||
## Example 1 | ||
Specifying the text directly | ||
|
||
```ruby | ||
div id: "foo", class: "bar" do | ||
pg text: "Hello World" | ||
end | ||
``` | ||
|
||
returns | ||
|
||
```html | ||
<div id="foo" class="bar"> | ||
<p>Hello World</p> | ||
</div> | ||
``` | ||
|
||
## Example 2 | ||
Rendering a content block between the `<p>` tags | ||
|
||
```ruby | ||
div id: "foo", class: "bar" do | ||
pg do | ||
plain "Hello World" | ||
end | ||
end | ||
``` | ||
|
||
returns | ||
|
||
```html | ||
<div id="foo" class="bar"> | ||
<p>Hello World</p> | ||
</div> | ||
``` | ||
|
||
## Example 3 | ||
Rendering a `<span>` tag into `<p>` tags | ||
|
||
```ruby | ||
pg id: "foo", class: "bar" do | ||
span do | ||
plain "Hello World" | ||
end | ||
end | ||
``` | ||
|
||
returns | ||
|
||
```html | ||
<p id="foo" class="bar"> | ||
<span>Hello World</span> | ||
</p> | ||
``` | ||
The HTML `<p>` tag implemented in ruby. Please refer to the [paragraph core component](./paragraph.md) since the PG component is deprecated and will be removed sometime in the future. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require_relative '../../support/utils' | ||
include Utils | ||
|
||
describe 'Paragraph Component', type: :feature, js: true do | ||
|
||
it 'Example 1' do | ||
|
||
class ExamplePage < Page::Cell::Page | ||
|
||
def response | ||
components { | ||
# simple paragraph | ||
paragraph text: 'I am simple' | ||
|
||
# enhanced paragraph | ||
paragraph id: 'my-id', class: 'my-class' do | ||
plain 'I am enhanced' | ||
end | ||
} | ||
end | ||
|
||
end | ||
|
||
visit '/example' | ||
|
||
static_output = page.html | ||
|
||
expected_static_output = <<~HTML | ||
<p>I am simple</p> | ||
<p id="my-id" class="my-class">I am enhanced</p> | ||
HTML | ||
|
||
expect(stripped(static_output)).to include(stripped(expected_static_output)) | ||
end | ||
|
||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PasWen actually
p
is a bit different fromputs
, it's not the short version.p
calls.inspect
on the printed object,puts
not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey,
thanks for pointing it out, just fixed it in the documentation (and learned sth new on the way;)!