Skip to content

Commit 4448e78

Browse files
Merge pull request #221 from GrantBarry/issue_163_fix
Issue 163 fix
2 parents 4ed2f62 + 4a27cf8 commit 4448e78

File tree

6 files changed

+125
-4
lines changed

6 files changed

+125
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
%b{@tag_attributes}
2+
- if options[:text].nil? && block_given?
3+
= yield
4+
- else
5+
= options[:text]

app/concepts/matestack/ui/core/b/b.rb

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

docs/components/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ You can build your [own components](/docs/extend/custom_components.md) as well,
1717
- [plain](/docs/components/plain.md)
1818
- [pg](/docs/components/pg.md)
1919
- [span](/docs/components/span.md)
20+
- [b](/docs/components/b.md)
2021
- [icon](/docs/components/icon.md)
2122
- [list](/docs/components/list.md)
2223
- ul

docs/components/b.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# matestack core component: B
2+
3+
Show [specs](/spec/usage/components/b_spec.rb)
4+
5+
The HTML b tag implemented in ruby.
6+
7+
## Parameters
8+
9+
This component can take 2 optional configuration params and either yield content or display what gets passed to the `text` configuration param.
10+
11+
#### # id (optional)
12+
Expects a string with all ids the b should have.
13+
14+
#### # class (optional)
15+
Expects a string with all classes the b should have.
16+
17+
## Example 1: Yield a given block
18+
19+
```ruby
20+
b id: "foo", class: "bar" do
21+
plain 'Hello World' # optional content
22+
end
23+
```
24+
25+
returns
26+
27+
```html
28+
<b id="foo" class="bar">
29+
Hello World
30+
</b>
31+
```
32+
33+
## Example 2: Render options[:text] param
34+
35+
```ruby
36+
b id: "foo", class: "bar", text: 'Hello World'
37+
```
38+
39+
returns
40+
41+
```html
42+
<b id="foo" class="bar">
43+
Hello World
44+
</b>

docs/components/video.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ The HTML video tag implemented in ruby.
88
The video tag takes a mandatory path argument and can take a number of optional configuration params.
99

1010
#### # path
11-
Expects a string with the source to the image. It looks for the image in the `assets/videos` folder and uses the standard Rails asset pipeline.
11+
Expects a string with the source to the video. It looks for the video in the `assets/videos` folder and uses the standard Rails asset pipeline.
1212

1313
#### # id, class
1414
Like most of the core components, you can give a video an id and a class.
1515

1616
#### # height (optional)
17-
Expects an integer with the height of the image in px.
17+
Expects an integer with the height of the video in px.
1818

1919
#### # width (optional)
20-
Expects an integer with the width of the image in px.
20+
Expects an integer with the width of the video in px.
2121

2222
#### # alt (optional)
23-
Expects a string with the alt text the image should have.
23+
Expects a string with the alt text the video should have.
2424

2525
#### # preload
2626
Expects a string (`auto`, `metadata` or `none`) and specifies whether the whole video/only metadata/nothing should be loaded on pageload. Default (if not specified) depends on the client's browser.

spec/usage/components/b_spec.rb

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
require_relative "../../support/utils"
2+
include Utils
3+
4+
describe 'B Component', type: :feature, js: true do
5+
6+
it 'Example 1 - yield, no options[:text]' do
7+
8+
class ExamplePage < Matestack::Ui::Page
9+
10+
def response
11+
components {
12+
# simple b
13+
b do
14+
plain 'I am simple'
15+
end
16+
17+
# enhanced b
18+
b id: 'my-id', class: 'my-class' do
19+
plain 'I am enhanced'
20+
end
21+
}
22+
end
23+
24+
end
25+
26+
visit '/example'
27+
28+
static_output = page.html
29+
30+
expected_static_output = <<~HTML
31+
<b>I am simple</b>
32+
<b id="my-id" class="my-class">I am enhanced</b>
33+
HTML
34+
35+
expect(stripped(static_output)).to include(stripped(expected_static_output))
36+
end
37+
38+
it 'Example 2 - render options[:text]' do
39+
40+
class ExamplePage < Matestack::Ui::Page
41+
42+
def response
43+
components {
44+
# simple b
45+
b text: 'I am simple'
46+
47+
# enhanced b
48+
b id: 'my-id', class: 'my-class',text: 'I am enhanced'
49+
}
50+
end
51+
52+
end
53+
54+
visit '/example'
55+
56+
static_output = page.html
57+
58+
expected_static_output = <<~HTML
59+
<b>I am simple</b>
60+
<b id="my-id" class="my-class">I am enhanced</b>
61+
HTML
62+
63+
expect(stripped(static_output)).to include(stripped(expected_static_output))
64+
end
65+
66+
end

0 commit comments

Comments
 (0)