Skip to content

Commit 01fe699

Browse files
re-add pg core component to avoid braking legacy applications
1 parent ffc6977 commit 01fe699

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

app/concepts/pg/cell/pg.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Pg::Cell
2+
class Pg < Component::Cell::Static
3+
4+
end
5+
end

app/concepts/pg/view/pg.haml

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/pg.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# matestack core component: PG
2+
3+
Show [specs](../../spec/usage/components/pg_spec.rb)
4+
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/pg_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 '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+
pg text: 'I am simple'
14+
15+
# enhanced paragraph
16+
pg 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

0 commit comments

Comments
 (0)