Skip to content

Commit 6d406f9

Browse files
authored
Merge pull request #70 from basemate/introduce_video_component
Add documented, untested video component
2 parents 58dd08f + f8c519b commit 6d406f9

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
= video_tag(ActionController::Base.helpers.asset_path(options[:path]), height: options[:height], width: options[:width], preload: options[:preload], autoplay: options[:autoplay], muted: options[:muted], playsinline: options[:playsinline], loop: options[:loop], class: options[:class], id: options[:id], controls: options[:controls])
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Matestack::Ui::Core::Video
2+
class Video < Matestack::Ui::Core::Component::Static
3+
4+
REQUIRED_KEYS = [:path]
5+
6+
end
7+
end

docs/components/video.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
11
# matestack core component: Video
22

33
Show [specs](../../spec/usage/components/video_spec.rb)
4+
5+
The HTML video tag implemented in ruby.
6+
7+
## Parameters
8+
The video tag takes a mandatory path argument and can take a number of optional configuration params.
9+
10+
#### # 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.
12+
13+
#### # id, class
14+
Like most of the core components, you can give a video an id and a class.
15+
16+
#### # height (optional)
17+
Expects an integer with the height of the image in px.
18+
19+
#### # width (optional)
20+
Expects an integer with the width of the image in px.
21+
22+
#### # alt (optional)
23+
Expects a string with the alt text the image should have.
24+
25+
#### # preload
26+
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.
27+
28+
#### # autoplay
29+
Expects a boolean and specifies whether the video should start playing as soon as it is ready.
30+
31+
#### # muted
32+
Expects a boolean and specifies whether the audio output of the video should be muted.
33+
34+
#### # playsinline
35+
Expects a boolean and specifies whether the video should be played inline on iOS Safari.
36+
37+
#### # loop
38+
Expects a boolean and specifies whether the video will start over again every time it is finished.
39+
40+
#### # controls
41+
Expects a boolean and specifies whether the video controls (play/pause button etc) should be displayed.

spec/usage/components/video_spec.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require_relative '../../support/utils'
2+
include Utils
3+
4+
describe 'Video Component', type: :feature, js: true do
5+
6+
it 'Renders a video tag on the page' do
7+
#
8+
# class ExamplePage < Matestack::Ui::Page
9+
# def response
10+
# components {
11+
# # simple video
12+
# # test below fails, either add something to `spec/dummy/app/assets/videos/*` or stub it
13+
# # video path: 'yourvid.mp4', width: 500, height: 300
14+
# }
15+
# end
16+
# end
17+
#
18+
# visit '/example'
19+
#
20+
# static_output = page.html
21+
#
22+
# expected_static_output = <<~HTML
23+
# <video src="yourvid.mp4" width="500" height="300"></video>
24+
# HTML
25+
#
26+
# expect(stripped(static_output)).to include(stripped(expected_static_output))
27+
end
28+
end

0 commit comments

Comments
 (0)