Class: Workarea::Storefront::ContentBlocks::SuperHeroViewModel
- Inherits:
-
ContentBlockViewModel
- Object
- ContentBlockViewModel
- Workarea::Storefront::ContentBlocks::SuperHeroViewModel
- Defined in:
- app/view_models/workarea/storefront/content_blocks/super_hero_view_model.rb
Instance Method Summary collapse
- #alt_text ⇒ Object
- #breakpoints ⇒ Object
- #content_class ⇒ Object
- #content_styles ⇒ Object
- #image ⇒ Object
- #image_medium_url ⇒ Object
- #image_small_url ⇒ Object
- #media_class ⇒ Object
- #media_styles ⇒ Object
- #video_iframe_attrs ⇒ Object
Instance Method Details
#alt_text ⇒ Object
29 30 31 |
# File 'app/view_models/workarea/storefront/content_blocks/super_hero_view_model.rb', line 29 def alt_text model.data[:alt_text].presence end |
#breakpoints ⇒ Object
21 22 23 |
# File 'app/view_models/workarea/storefront/content_blocks/super_hero_view_model.rb', line 21 def breakpoints Workarea.config.storefront_break_points end |
#content_class ⇒ Object
60 61 62 63 64 65 66 |
# File 'app/view_models/workarea/storefront/content_blocks/super_hero_view_model.rb', line 60 def content_class content_class = 'content-position ' model.data[:content_position].split(',').each do |pos| content_class << "content-position--#{pos.optionize} " end return content_class end |
#content_styles ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'app/view_models/workarea/storefront/content_blocks/super_hero_view_model.rb', line 68 def content_styles background_color = ColorTools.new( hex: model.data[:background_color], alpha: model.data[:background_alpha] ) "color: #{model.data[:text_color]}; background-color: rgba(#{background_color.rgba});" end |
#image ⇒ Object
25 26 27 |
# File 'app/view_models/workarea/storefront/content_blocks/super_hero_view_model.rb', line 25 def image @image ||= find_asset(data[:asset]) end |
#image_medium_url ⇒ Object
5 6 7 8 9 10 11 |
# File 'app/view_models/workarea/storefront/content_blocks/super_hero_view_model.rb', line 5 def image_medium_url if data[:asset_medium].present? find_asset(data[:asset_medium]).url else image.url end end |
#image_small_url ⇒ Object
13 14 15 16 17 18 19 |
# File 'app/view_models/workarea/storefront/content_blocks/super_hero_view_model.rb', line 13 def image_small_url if data[:asset_small].present? find_asset(data[:asset_small]).url else image.url end end |
#media_class ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/view_models/workarea/storefront/content_blocks/super_hero_view_model.rb', line 33 def media_class if model.data[:media_mode] == 'crop' "crop super-hero-content-block__media--crop-#{model.data[:crop_side]}" else model.data[:media_mode] end end |
#media_styles ⇒ Object
41 42 43 44 45 46 47 |
# File 'app/view_models/workarea/storefront/content_blocks/super_hero_view_model.rb', line 41 def media_styles if model.data[:media_mode] == 'resize' "padding-bottom: #{image.file_inverse_aspect_ratio * 100}%" elsif model.data[:media_mode] == 'crop' "padding-bottom: #{image.height}px" end end |
#video_iframe_attrs ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'app/view_models/workarea/storefront/content_blocks/super_hero_view_model.rb', line 49 def video_iframe_attrs return unless model.data[:video].present? = VideoEmbedder.new( model.data[:video], autoplay: model.data[:autoplay], loop_playback: model.data[:loop], mute: model.data[:mute] ) .iframe_attrs end |