Class: Embed::WistiaMediaComponent

Inherits:
SparkComponents::Component
  • Object
show all
Defined in:
app/components/spark/embed/wistia_media_component.rb

Instance Method Summary collapse

Instance Method Details

#renderObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/components/spark/embed/wistia_media_component.rb', line 10

def render
  wistia_embed_options = {
    class: "wistia_embed wistia_async_#{video_id} popover=true seo=false popoverContent=link popoverAnimation=none",
    style: 'height:100%;width:100%'
  }

  wistia_embed_background_options = {
    class: 'wistia-embed-background',
    style: "background-image: url('#{background_image_url}')"
  }

  unless height.blank?
    tag_attrs.merge!(style: "height: #{height}px;max-width: #{width}px")
  end

  tag.div(tag_attrs) {
    concat tag.script(src: 'https://fast.wistia.com/assets/external/E-v1.js')
    concat tag.div(wistia_embed_options) {
      concat tag.div(wistia_embed_background_options) {
        concat tag.div(class: 'wistia-thumbnail-cover')
        concat tag.div(class: 'wistia-thumbnail-container') {
          tag.div {
            concat tag.p(title, class: 'title') unless title.blank?
            concat tag.p(subtitle, class: 'subtitle') unless subtitle.blank?
          }
        }
        concat tag.div(class: 'wistia-thumbnail-play') {
          component('ui/icon', name: 'play', size: :large)
        }
      }
    }
  }
end