Skip to content

Commit d0757f3

Browse files
authored
Merge pull request #48 from basemate/change_paragraph_component
rename pg component to paragraph component
2 parents 34ab700 + 01fe699 commit d0757f3

File tree

8 files changed

+128
-74
lines changed

8 files changed

+128
-74
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Paragraph::Cell
2+
class Paragraph < Component::Cell::Static
3+
4+
end
5+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- if options[:text].nil?
2+
%p{@tag_attributes}
3+
- if block_given?
4+
= yield
5+
6+
- else
7+
%p{@tag_attributes}
8+
= options[:text]

docs/components/paragraph.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# matestack core component: Paragraph
2+
3+
Show [specs](../../spec/usage/components/paragraph_spec.rb)
4+
5+
The HTML `<p>` tag implemented in ruby. This is a workaround because the single `p` is the short version of `puts` in ruby.
6+
7+
## Parameters
8+
9+
This component can take 3 optional configuration params and optional content.
10+
11+
#### # id (optional)
12+
Expects a string with all ids the p should have.
13+
14+
#### # class (optional)
15+
Expects a string with all classes the p should have.
16+
17+
#### # text (optional)
18+
Expects a string with the text that should go into the `<p>` tag.
19+
20+
## Example 1
21+
Specifying the text directly
22+
23+
```ruby
24+
div id: "foo", class: "bar" do
25+
paragraph text: "Hello World"
26+
end
27+
```
28+
29+
returns
30+
31+
```html
32+
<div id="foo" class="bar">
33+
<p>Hello World</p>
34+
</div>
35+
```
36+
37+
## Example 2
38+
Rendering a content block between the `<p>` tags
39+
40+
```ruby
41+
div id: "foo", class: "bar" do
42+
paragraph do
43+
plain "Hello World"
44+
end
45+
end
46+
```
47+
48+
returns
49+
50+
```html
51+
<div id="foo" class="bar">
52+
<p>Hello World</p>
53+
</div>
54+
```
55+
56+
## Example 3
57+
Rendering a `<span>` tag into `<p>` tags
58+
59+
```ruby
60+
paragraph id: "foo", class: "bar" do
61+
span do
62+
plain "Hello World"
63+
end
64+
end
65+
```
66+
67+
returns
68+
69+
```html
70+
<p id="foo" class="bar">
71+
<span>Hello World</span>
72+
</p>
73+
```

docs/components/pg.md

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,5 @@
1-
# matestack core component: Pg
1+
# matestack core component: PG
22

33
Show [specs](../../spec/usage/components/pg_spec.rb)
44

5-
The HTML `<p>` tag implemented in ruby. This is a workaround because the single `p` is the short version of `puts` in ruby.
6-
7-
## Parameters
8-
9-
This component can take 3 optional configuration params and optional content.
10-
11-
#### # id (optional)
12-
Expects a string with all ids the p should have.
13-
14-
#### # class (optional)
15-
Expects a string with all classes the p should have.
16-
17-
#### # text (optional)
18-
Expects a string with the text that should go into the `<p>` tag.
19-
20-
## Example 1
21-
Specifying the text directly
22-
23-
```ruby
24-
div id: "foo", class: "bar" do
25-
pg text: "Hello World"
26-
end
27-
```
28-
29-
returns
30-
31-
```html
32-
<div id="foo" class="bar">
33-
<p>Hello World</p>
34-
</div>
35-
```
36-
37-
## Example 2
38-
Rendering a content block between the `<p>` tags
39-
40-
```ruby
41-
div id: "foo", class: "bar" do
42-
pg do
43-
plain "Hello World"
44-
end
45-
end
46-
```
47-
48-
returns
49-
50-
```html
51-
<div id="foo" class="bar">
52-
<p>Hello World</p>
53-
</div>
54-
```
55-
56-
## Example 3
57-
Rendering a `<span>` tag into `<p>` tags
58-
59-
```ruby
60-
pg id: "foo", class: "bar" do
61-
span do
62-
plain "Hello World"
63-
end
64-
end
65-
```
66-
67-
returns
68-
69-
```html
70-
<p id="foo" class="bar">
71-
<span>Hello World</span>
72-
</p>
73-
```
5+
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.

spec/usage/components/action_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ class Pages::ExampleApp::SecondExamplePage < Page::Cell::Page
534534
def response
535535
components {
536536
heading size: 2, text: "This is Page 2"
537-
pg text: 'You made it!'
537+
paragraph text: 'You made it!'
538538
}
539539
end
540540

spec/usage/components/footer_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def response
1616

1717
# advanced footer tag
1818
footer id: 'my-unique-footer', class: 'awesome-footer' do
19-
pg class: 'footer-text', text: 'hello world!'
19+
paragraph class: 'footer-text', text: 'hello world!'
2020
end
2121
}
2222
end
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 'Paragraph Component', type: :feature, js: true do
5+
6+
it 'Example 1' do
7+
8+
class ExamplePage < Page::Cell::Page
9+
10+
def response
11+
components {
12+
# simple paragraph
13+
paragraph text: 'I am simple'
14+
15+
# enhanced paragraph
16+
paragraph id: 'my-id', class: 'my-class' do
17+
plain 'I am enhanced'
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+
<p>I am simple</p>
30+
<p id="my-id" class="my-class">I am enhanced</p>
31+
HTML
32+
33+
expect(stripped(static_output)).to include(stripped(expected_static_output))
34+
end
35+
36+
end

spec/usage/components/time_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ class ExamplePage < Page::Cell::Page
1010
def response
1111
components {
1212
# simple time tag
13-
pg do
13+
paragraph do
1414
plain 'This should show '
1515
time class: 'my-simple-time' do
1616
plain '12:00'
1717
end
1818
end
1919

2020
# time tag with timestamp
21-
pg id: 'my-parent-paragraph' do
21+
paragraph id: 'my-parent-paragraph' do
2222
plain 'Today is '
2323
time id: 'example-timestamp', datetime: DateTime.new(2019,2,12,10,38,39,'+02:00') do
2424
plain 'July 7'

0 commit comments

Comments
 (0)