Class: EmbedComponent
- Defined in:
- app/components/embed_component.rb
Overview
Embed — embedded video/iframe content.
Usage:
Embed(source: :youtube, embed_id: "dQw4w9WgXcQ")
Embed(source: :vimeo, embed_id: "123456", placeholder: "thumb.jpg")
Embed(url: "https://example.com/widget")
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
Methods inherited from Component
default, #initialize, #render_in, slot
Constructor Details
This class inherits a constructor from Component
Instance Method Details
#to_s ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/components/embed_component.rb', line 18 def to_s data = { controller: "fui-embed" } data[:source] = source if source data[:id] = if data[:url] = url if url data[:placeholder] = placeholder if placeholder icon_el = tag.i(class: "#{icon} icon") placeholder_el = placeholder ? tag.img(class: "placeholder", src: placeholder) : nil tag.div(class: "ui embed", data: data) { safe_join([ icon_el, placeholder_el, @content ]) } end |