module Maglove module Widgets class Container < Base def identifier "container" end def defaults { animate: "none", image_source: false, image_position: "center_center", parallax_effect: "none", bg_color: "", opacity: "", border_radius: "", border_width: "", border_style: "", border_color: "transparent", style: "default", min_height: "", max_height: "", overflow_y: "" } end def container_options result = { class: container_classes, style: container_styles } result["data-parallax-style"] = @options[:parallax_effect] if !@options[:parallax_effect].empty? and @options[:parallax_effect] != "none" result end def image_options { class: "one-container-image", style: image_styles } end def container_classes classes = ["one-container"] classes.push("animate #{@options[:animate]}") if @options[:animate] != "none" classes.push("container-#{@options[:style]}") unless @options[:style].empty? classes.push("container-parallax") if !@options[:parallax_effect].empty? and @options[:parallax_effect] != "none" classes.join(" ") end def container_styles style_string @options, :opacity, :border, :opacity, :border_radius, :border_width, :border_style, :border_color, :min_height end def image_styles style_string @options, :max_height, :overflow_y end module Helpers def container_widget(options = {}, &block) widget_block(Widgets::Container.new(options)) do |widget| haml_tag :section, widget.container_options do haml_tag :div, widget.image_options do yield if block drop_container end end end end end end end end