Skip to content

Commit 94c2a9c

Browse files
committed
iframe: Address review comments.
1 parent 0af512d commit 94c2a9c

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
module Matestack::Ui::Core::Iframe
22
class Iframe < Matestack::Ui::Core::Component::Static
33

4+
def setup
5+
@tag_attributes.merge!({
6+
src: options[:src],
7+
height: options[:height],
8+
width: options[:width],
9+
srcdoc: options[:srcdoc]
10+
})
11+
end
12+
413
end
514
end

docs/components/iframe.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@ Expects a string with all ids the `iframe` should have.
1414
#### # class (optional)
1515
Expects a string with all classes the `iframe` should have for styling purpose.
1616

17+
#### # height (optional)
18+
Specifies the height of an `iframe`.
19+
20+
#### # width (optional)
21+
Specifies the width of an `iframe`.
1722

1823
#### # src
1924
Specifies the address of the document to embed in the `iframe` tag.
2025

26+
#### # srcdoc
27+
Specifies the HTML content of the page to show in the inline frame.
28+
2129
## Example 1: Yield a given block
2230

2331
```ruby

spec/usage/components/iframe_spec.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def response
1515
end
1616

1717
# enhanced iframe tag
18-
iframe id: 'my-id', class: 'my-class', src="https://www.demopage.com" do
18+
iframe id: 'my-id', class: 'my-class', src="https://www.demopage.com", srcdoc="<p>Mate Stack UI!</p>" do
1919
plain 'The browser does not support iframe.'
2020
end
2121
}
@@ -28,7 +28,7 @@ def response
2828

2929
expected_static_output = <<~HTML
3030
<iframe src="https://www.demopage.com">The browser does not support iframe.</iframe>
31-
<iframe id="my-id" class="my-class" src="https://www.demopage.com">The browser does not support iframe.</iframe>
31+
<iframe id="my-id" class="my-class" src="https://www.demopage.com" srcdoc="<p>Mate Stack UI!</p>">The browser does not support iframe.</iframe>
3232
HTML
3333
expect(stripped(static_output)).to include(stripped(expected_static_output))
3434
end
@@ -43,7 +43,8 @@ def response
4343
iframe src="https://www.demopage.com", text: 'The browser does not support iframe.'
4444

4545
# enhanced iframe tag
46-
iframe id: 'my-id', class: 'my-class', src="https://www.demopage.com", text: 'The browser does not support iframe.'
46+
iframe id: 'my-id', class: 'my-class', src="https://www.demopage.com",
47+
srcdoc="<p>Mate Stack UI!</p>", text: 'The browser does not support iframe.'
4748
}
4849
end
4950

@@ -55,7 +56,7 @@ def response
5556

5657
expected_static_output = <<~HTML
5758
<iframe src="https://www.demopage.com">The browser does not support iframe.</iframe>
58-
<iframe id="my-id" class="my-class" src="https://www.demopage.com">The browser does not support iframe.</iframe>
59+
<iframe id="my-id" class="my-class" src="https://www.demopage.com" srcdoc="<p>Mate Stack UI!</p>">The browser does not support iframe.</iframe>
5960
HTML
6061

6162
expect(stripped(static_output)).to include(stripped(expected_static_output))

0 commit comments

Comments
 (0)