Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add address tag, specs and documentation
- Loading branch information
1 parent
cf82a65
commit cecae31
Showing
4 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
%address{@tag_attributes} | ||
- if options[:text].nil? && block_given? | ||
= yield | ||
- else | ||
= options[:text] |
This file contains 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 Matestack::Ui::Core::Address | ||
class Address < Matestack::Ui::Core::Component::Static | ||
|
||
end | ||
end |
This file contains 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,51 @@ | ||
# matestack core component: Address | ||
|
||
Show [specs](../../spec/usage/components/address_spec.rb) | ||
|
||
The HTML `<address>` 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. | ||
|
||
#### # id (optional) | ||
Expects a string with all ids the address should have. | ||
|
||
#### # class (optional) | ||
Expects a string with all classes the address should have. | ||
|
||
## Example 1 - yield a given block | ||
|
||
```ruby | ||
address do | ||
plain 'Codey McCodeface' | ||
br | ||
plain '1 Developer Avenue' | ||
br | ||
plain 'Techville' | ||
end | ||
``` | ||
|
||
returns | ||
|
||
```html | ||
<address> | ||
Codey McCodeface<br> | ||
1 Developer Avenue<br> | ||
Techville | ||
</address> | ||
``` | ||
|
||
## Example 2 - render options[:text] param | ||
|
||
```ruby | ||
address text: 'PO Box 12345' | ||
``` | ||
|
||
returns | ||
|
||
```html | ||
<address> | ||
PO Box 12345 | ||
</address> | ||
``` |
This file contains 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,58 @@ | ||
require_relative '../../support/utils' | ||
include Utils | ||
|
||
describe 'Address Component', type: :feature, js: true do | ||
|
||
it 'Example 1 - yield a given block' do | ||
|
||
class ExamplePage < Matestack::Ui::Page | ||
|
||
def response | ||
components { | ||
address do | ||
plain 'Codey McCodeface' | ||
br | ||
plain '1 Developer Avenue' | ||
br | ||
plain 'Techville' | ||
end | ||
} | ||
end | ||
|
||
end | ||
|
||
visit '/example' | ||
|
||
static_output = page.html | ||
|
||
expected_static_output = <<~HTML | ||
<address>Codey McCodeface<br>1 Developer Avenue<br>Techville</address> | ||
HTML | ||
|
||
expect(stripped(static_output)).to include(stripped(expected_static_output)) | ||
end | ||
|
||
it 'Example 2 - render options[:text] param' do | ||
|
||
class ExamplePage < Matestack::Ui::Page | ||
|
||
def response | ||
components { | ||
address text: 'PO Box 12345' | ||
} | ||
end | ||
|
||
end | ||
|
||
visit '/example' | ||
|
||
static_output = page.html | ||
|
||
expected_static_output = <<~HTML | ||
<address>PO Box 12345</address> | ||
HTML | ||
|
||
expect(stripped(static_output)).to include(stripped(expected_static_output)) | ||
end | ||
|
||
end |