vime_view_components 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +35 -0
  4. data/Rakefile +12 -0
  5. data/lib/vime/component.rb +39 -0
  6. data/lib/vime/core/embed.rb +27 -0
  7. data/lib/vime/core/player.rb +53 -0
  8. data/lib/vime/core/playground.rb +29 -0
  9. data/lib/vime/providers/audio.rb +25 -0
  10. data/lib/vime/providers/dailymotion.rb +37 -0
  11. data/lib/vime/providers/dash.rb +39 -0
  12. data/lib/vime/providers/file.rb +37 -0
  13. data/lib/vime/providers/hls.rb +33 -0
  14. data/lib/vime/providers/video.rb +29 -0
  15. data/lib/vime/providers/vimeo.rb +31 -0
  16. data/lib/vime/providers/youtube.rb +27 -0
  17. data/lib/vime/ui/captions.rb +23 -0
  18. data/lib/vime/ui/click_to_play.rb +21 -0
  19. data/lib/vime/ui/controls/caption_control.rb +33 -0
  20. data/lib/vime/ui/controls/control.rb +35 -0
  21. data/lib/vime/ui/controls/control_group.rb +23 -0
  22. data/lib/vime/ui/controls/control_spacer.rb +15 -0
  23. data/lib/vime/ui/controls/controls.rb +43 -0
  24. data/lib/vime/ui/controls/default_controls.rb +29 -0
  25. data/lib/vime/ui/controls/fullscreen_control.rb +33 -0
  26. data/lib/vime/ui/controls/mute_control.rb +35 -0
  27. data/lib/vime/ui/controls/pip_control.rb +33 -0
  28. data/lib/vime/ui/controls/playback_control.rb +33 -0
  29. data/lib/vime/ui/controls/scrubber_control.rb +27 -0
  30. data/lib/vime/ui/controls/settings_control.rb +31 -0
  31. data/lib/vime/ui/controls/volume_control.rb +37 -0
  32. data/lib/vime/ui/dbl_click_fullscreen.rb +21 -0
  33. data/lib/vime/ui/default_ui.rb +37 -0
  34. data/lib/vime/ui/icon.rb +21 -0
  35. data/lib/vime/ui/icons.rb +21 -0
  36. data/lib/vime/ui/live_indicator.rb +13 -0
  37. data/lib/vime/ui/poster.rb +21 -0
  38. data/lib/vime/ui/scrim.rb +21 -0
  39. data/lib/vime/ui/settings/default_settings.rb +23 -0
  40. data/lib/vime/ui/settings/menu.rb +27 -0
  41. data/lib/vime/ui/settings/menu_item.rb +39 -0
  42. data/lib/vime/ui/settings/menu_radio.rb +31 -0
  43. data/lib/vime/ui/settings/menu_radio_group.rb +23 -0
  44. data/lib/vime/ui/settings/settings.rb +27 -0
  45. data/lib/vime/ui/settings/submenu.rb +29 -0
  46. data/lib/vime/ui/skeleton.rb +21 -0
  47. data/lib/vime/ui/slider.rb +31 -0
  48. data/lib/vime/ui/spinner.rb +13 -0
  49. data/lib/vime/ui/time/current_time.rb +23 -0
  50. data/lib/vime/ui/time/end_time.rb +23 -0
  51. data/lib/vime/ui/time/time.rb +27 -0
  52. data/lib/vime/ui/time/time_progress.rb +25 -0
  53. data/lib/vime/ui/tooltip.rb +27 -0
  54. data/lib/vime/ui/ui.rb +13 -0
  55. data/lib/vime_view_components.rb +68 -0
  56. data/lib/vime_view_components/version.rb +5 -0
  57. metadata +204 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 36f096f677d914a9ea6b94f10e0c343225fb420a89896e6fb8926e5cc7259cd9
4
+ data.tar.gz: 1def0ea3af02fa441578e156daa8d47f1299c678cc212eea2f3d0691d566c0e2
5
+ SHA512:
6
+ metadata.gz: 694dc48794d951e1038ee3eedaae8d225a647165b8efed812e12c020ccbc506a0b2449057b38d915111c60b93dffc32cce7c5cabaf8534099717e83aa84150b7
7
+ data.tar.gz: 472aa8cd079430dc1a0a28668bf331b75aa498797cbee63ea39c1c0b732635b8dfaf28db5d3e8b819b499cfe0ad8fbdb975ac81c31fe8ecd7f1f159d824fe745
@@ -0,0 +1,20 @@
1
+ Copyright 2020 asgerb
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # vime_view_components
2
+
3
+ ![Ruby](https://github.com/asgerb/vime_view_components/workflows/Ruby/badge.svg)
4
+
5
+ ViewComponents for vime.js
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'vime_view_components'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install vime_view_components
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/asgerb/vime_view_components.
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry-initializer"
4
+
5
+ module Vime
6
+ class Component < ViewComponent::Base
7
+ extend Dry::Initializer
8
+
9
+ module Types
10
+ include Dry.Types()
11
+
12
+ CrossOrigin = String.enum("", "anonymous", "use-credentials")
13
+ Pin = String.enum("bottomLeft", "bottomRight", "topLeft", "topRight")
14
+ Preload = String.enum("", "auto", "metadata", "none")
15
+ TooltipDirection = String.enum("left", "right")
16
+ TooltipPosition = String.enum("bottom", "top")
17
+ end
18
+
19
+ option :class, type: Types::Array.of(Types::String).optional, optional: true, as: :classes
20
+ option :data, type: Types::Hash.optional, optional: true
21
+ option :style, type: Types::String.optional, optional: true
22
+
23
+ def dom_attrs
24
+ {
25
+ class: classes,
26
+ data: data,
27
+ style: style,
28
+ }
29
+ end
30
+
31
+ private
32
+ def process_attrs(attrs)
33
+ attrs
34
+ .deep_transform_keys(&:to_s)
35
+ .deep_transform_keys(&:dasherize)
36
+ .reject { |_, v| v.nil? }
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @see https://vimejs.com/components/core/embed
4
+
5
+ module Vime
6
+ module Core
7
+ class Embed < Component
8
+ option :embed_src, type: Types::String
9
+ option :media_title, type: Types::String, optional: true
10
+ option :origin, type: Types::String, optional: true
11
+ option :params, type: Types::String, optional: true
12
+
13
+ def call
14
+ content_tag "vime-embed", content, process_attrs(dom_attrs)
15
+ end
16
+
17
+ def dom_attrs
18
+ super.merge({
19
+ embed_src: embed_src,
20
+ media_title: media_title,
21
+ origin: origin,
22
+ params: params,
23
+ })
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @see https://vimejs.com/components/core/player
4
+
5
+ module Vime
6
+ module Core
7
+ class Player < Component
8
+ option :aspect_ratio, type: Types::String, default: -> { "16:9" }
9
+ option :autopause, type: Types::Bool, default: -> { true }
10
+ option :autoplay, type: Types::Bool, default: -> { false }
11
+ option :controls, type: Types::Bool, default: -> { false }
12
+ option :current_time, type: Types::Integer, default: -> { 0 }
13
+ option :debug, type: Types::Bool, default: -> { false }
14
+ option :duration, type: Types::Integer, default: -> { -1 }
15
+ option :language, type: Types::String, default: -> { "en" }
16
+ option :loop, type: Types::Bool, default: -> { false }
17
+ option :media_title, type: Types::String, optional: true
18
+ option :muted, type: Types::Bool, default: -> { false }
19
+ option :paused, type: Types::Bool, default: -> { true }
20
+ option :playback_quality, type: Types::String, optional: true
21
+ option :playback_rate, type: Types::Integer, default: -> { 1 }
22
+ option :playsinline, type: Types::Bool, default: -> { false }
23
+ option :theme, type: Types::String, optional: true
24
+ option :volume, type: Types::Integer, default: -> { 50 }
25
+
26
+ def call
27
+ content_tag "vime-player", content, process_attrs(dom_attrs)
28
+ end
29
+
30
+ def dom_attrs
31
+ super.merge({
32
+ aspect_ratio: aspect_ratio,
33
+ autopause: autopause,
34
+ autoplay: autoplay,
35
+ controls: controls,
36
+ current_time: current_time,
37
+ debug: debug,
38
+ duration: duration,
39
+ language: language,
40
+ loop: loop,
41
+ media_title: media_title,
42
+ muted: muted,
43
+ paused: paused,
44
+ playback_quality: playback_quality,
45
+ playback_rate: playback_rate,
46
+ playsinline: playsinline,
47
+ theme: theme,
48
+ volume: volume,
49
+ })
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @see https://vimejs.com/components/core/playground
4
+
5
+ module Vime
6
+ module Core
7
+ class Playground < Component
8
+ option :poster, type: Types::String, optional: true
9
+ option :provider, type: Types::String.enum("Provider.Audio", "Provider.Dailymotion", "Provider.Dash", "Provider.FakeTube", "Provider.Video", "Provider.Vimeo", "Provider.YouTube"), default: -> { "Provider.Audio" }
10
+ option :show_custom_ui, type: Types::Bool, optional: true
11
+ option :src, type: Types::String
12
+ option :theme, type: Types::String.enum("", "dark", "light"), default: -> { "" }
13
+
14
+ def call
15
+ content_tag "vime-playground", content, process_attrs(dom_attrs)
16
+ end
17
+
18
+ def dom_attrs
19
+ super.merge({
20
+ poster: poster,
21
+ provider: provider,
22
+ show_custom_ui: show_custom_ui,
23
+ src: src,
24
+ theme: theme,
25
+ })
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @see https://vimejs.com/components/providers/audio
4
+
5
+ module Vime
6
+ module Providers
7
+ class Audio < Component
8
+ option :cross_origin, type: Types::CrossOrigin, optional: true
9
+ option :media_title, type: Types::String, optional: true
10
+ option :preload, type: Types::Preload, default: -> { "metadata" }
11
+
12
+ def call
13
+ content_tag "vime-audio", content, process_attrs(dom_attrs)
14
+ end
15
+
16
+ def dom_attrs
17
+ super.merge({
18
+ cross_origin: cross_origin,
19
+ media_title: media_title,
20
+ preload: preload,
21
+ })
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @see https://vimejs.com/components/providers/dailymotion
4
+
5
+ module Vime
6
+ module Providers
7
+ class Dailymotion < Component
8
+ option :color, type: Types::String, optional: true
9
+ option :poster, type: Types::String, optional: true
10
+ option :should_autoplay_queue, type: Types::Bool, default: -> { false }
11
+ option :show_dailymotion_logo, type: Types::Bool, default: -> { false }
12
+ option :show_share_buttons, type: Types::Bool, default: -> { false }
13
+ option :show_up_next_queue, type: Types::Bool, default: -> { false }
14
+ option :show_video_info, type: Types::Bool, default: -> { true }
15
+ option :syndication, type: Types::String, optional: true
16
+ option :video_id, type: Types::String
17
+
18
+ def call
19
+ tag "vime-dailymotion", process_attrs(dom_attrs)
20
+ end
21
+
22
+ def dom_attrs
23
+ super.merge({
24
+ color: color,
25
+ poster: poster,
26
+ should_autoplay_queue: should_autoplay_queue,
27
+ show_dailymotion_logo: show_dailymotion_logo,
28
+ show_share_buttons: show_share_buttons,
29
+ show_up_next_queue: show_up_next_queue,
30
+ show_video_info: show_video_info,
31
+ syndication: syndication,
32
+ video_id: video_id,
33
+ })
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @see https://vimejs.com/components/providers/dash
4
+
5
+ module Vime
6
+ module Providers
7
+ class Dash < Component
8
+ option :auto_pip, type: Types::Bool, optional: true
9
+ option :controls_list, type: Types::String, optional: true
10
+ option :cross_origin, type: Types::CrossOrigin, optional: true
11
+ option :disable_pip, type: Types::Bool, optional: true
12
+ option :disable_remote_playback, type: Types::Bool, optional: true
13
+ option :media_title, type: Types::String, optional: true
14
+ option :poster, type: Types::String, optional: true
15
+ option :preload, type: Types::Preload, default: -> { "metadata" }
16
+ option :src, type: Types::String
17
+ option :version, type: Types::String, default: -> { "latest" }
18
+
19
+ def call
20
+ content_tag "vime-dash", content, process_attrs(dom_attrs)
21
+ end
22
+
23
+ def dom_attrs
24
+ super.merge({
25
+ auto_pip: auto_pip,
26
+ controls_list: controls_list,
27
+ cross_origin: cross_origin,
28
+ disable_pip: disable_pip,
29
+ disable_remote_playback: disable_remote_playback,
30
+ media_title: media_title,
31
+ poster: poster,
32
+ preload: preload,
33
+ src: src,
34
+ version: version,
35
+ })
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @see https://vimejs.com/components/providers/file
4
+
5
+ module Vime
6
+ module Providers
7
+ class File < Component
8
+ option :auto_pip, type: Types::Bool, optional: true
9
+ option :controls_list, type: Types::String, optional: true
10
+ option :cross_origin, type: Types::CrossOrigin, optional: true
11
+ option :disable_pip, type: Types::Bool, optional: true
12
+ option :disable_remote_playback, type: Types::Bool, optional: true
13
+ option :media_title, type: Types::String, optional: true
14
+ option :poster, type: Types::String, optional: true
15
+ option :preload, type: Types::Preload, default: -> { "metadata" }
16
+ option :view_type, type: Types::String, optional: true
17
+
18
+ def call
19
+ content_tag "vime-file", content, process_attrs(dom_attrs)
20
+ end
21
+
22
+ def dom_attrs
23
+ super.merge({
24
+ auto_pip: auto_pip,
25
+ controls_list: controls_list,
26
+ cross_origin: cross_origin,
27
+ disable_pip: disable_pip,
28
+ disable_remote_playback: disable_remote_playback,
29
+ media_title: media_title,
30
+ poster: poster,
31
+ preload: preload,
32
+ view_type: view_type,
33
+ })
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @see https://vimejs.com/components/providers/hls
4
+
5
+ module Vime
6
+ module Providers
7
+ class Hls < Component
8
+ option :config, type: Types::Any, optional: true
9
+ option :controls_list, type: Types::String, optional: true
10
+ option :cross_origin, type: Types::CrossOrigin, optional: true
11
+ option :media_title, type: Types::String, optional: true
12
+ option :poster, type: Types::String, optional: true
13
+ option :preload, type: Types::Preload, default: -> { "metadata" }
14
+ option :version, type: Types::String, default: -> { "latest" }
15
+
16
+ def call
17
+ content_tag "vime-hls", content, process_attrs(dom_attrs)
18
+ end
19
+
20
+ def dom_attrs
21
+ super.merge({
22
+ config: config,
23
+ controls_list: controls_list,
24
+ cross_origin: cross_origin,
25
+ media_title: media_title,
26
+ poster: poster,
27
+ preload: preload,
28
+ version: version,
29
+ })
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @see https://vimejs.com/components/providers/video
4
+
5
+ module Vime
6
+ module Providers
7
+ class Video < Component
8
+ option :controls_list, type: Types::String, optional: true
9
+ option :cross_origin, type: Types::CrossOrigin, optional: true
10
+ option :media_title, type: Types::String, optional: true
11
+ option :poster, type: Types::String, optional: true
12
+ option :preload, type: Types::Preload, default: -> { "metadata" }
13
+
14
+ def call
15
+ content_tag "vime-video", content, process_attrs(dom_attrs)
16
+ end
17
+
18
+ def dom_attrs
19
+ super.merge({
20
+ controls_list: controls_list,
21
+ cross_origin: cross_origin,
22
+ media_title: media_title,
23
+ poster: poster,
24
+ preload: preload,
25
+ })
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @see https://vimejs.com/components/providers/vimeo
4
+
5
+ module Vime
6
+ module Providers
7
+ class Vimeo < Component
8
+ option :byline, type: Types::Bool, default: -> { true }
9
+ option :color, type: Types::String, optional: true
10
+ option :no_auto_aspect_ratio, type: Types::Bool, default: -> { false }
11
+ option :portrait, type: Types::Bool, default: -> { true }
12
+ option :poster, type: Types::String, optional: true
13
+ option :video_id, type: Types::String
14
+
15
+ def call
16
+ tag "vime-vimeo", process_attrs(dom_attrs)
17
+ end
18
+
19
+ def dom_attrs
20
+ super.merge({
21
+ byline: byline,
22
+ color: color,
23
+ no_auto_aspect_ratio: no_auto_aspect_ratio,
24
+ portrait: portrait,
25
+ poster: poster,
26
+ video_id: video_id,
27
+ })
28
+ end
29
+ end
30
+ end
31
+ end