Class: Maglove::Widgets::Container
- Defined in:
- lib/maglove/widgets/container.rb
Defined Under Namespace
Modules: Helpers
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #container_classes ⇒ Object
- #container_options ⇒ Object
- #container_styles ⇒ Object
- #defaults ⇒ Object
- #identifier ⇒ Object
- #image_options ⇒ Object
- #image_styles ⇒ Object
Methods inherited from Base
#initialize, #typeloft_widget_options
Constructor Details
This class inherits a constructor from Maglove::Widgets::Base
Instance Method Details
#container_classes ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/maglove/widgets/container.rb', line 48 def container_classes classes = ["one-container"] classes.push("animate #{@options[:animate]}") if [:animate] != "none" classes.push("container-#{@options[:style]}") unless [:style].empty? classes.push("container-image-#{@options[:image_size]}") unless [:image_size].empty? classes.push("container-parallax") if ![:parallax_effect].empty? and [:parallax_effect] != "none" classes.join(" ") end |
#container_options ⇒ Object
38 39 40 41 42 |
# File 'lib/maglove/widgets/container.rb', line 38 def result = { class: container_classes, style: container_styles } result["data-parallax-style"] = [:parallax_effect] if ![:parallax_effect].empty? and [:parallax_effect] != "none" result end |
#container_styles ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/maglove/widgets/container.rb', line 57 def container_styles style_string , :opacity, :border, :opacity, :border_radius, :border_width, :border_style, :margin do |sb| sb.add(:background_color, [:background_color] == "custom" ? [:bg_color] : nil) if [:background_color] == "overlay" sb.add(:background_image, [:image_source], "linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url(<%= value %>)") end sb.add(:background_position, [:image_position], "<%= value.split('_').join(' ') %>") end end |
#defaults ⇒ Object
8 9 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 |
# File 'lib/maglove/widgets/container.rb', line 8 def defaults { animate: "none", image_source: false, image_position: "center_center", image_size: "cover", parallax_effect: "none", background_color: "", bg_color: "", opacity: "", border_radius: "", border_width: "", border_style: "", style: "default", padding_top: "", padding_right: "", padding_bottom: "", padding_left: "", alignment: "center", min_height: "", max_height: "", max_width: "", margin_top: "", margin_right: "", margin_bottom: "", margin_left: "", overflow_y: "" } end |
#identifier ⇒ Object
4 5 6 |
# File 'lib/maglove/widgets/container.rb', line 4 def identifier "container" end |
#image_options ⇒ Object
44 45 46 |
# File 'lib/maglove/widgets/container.rb', line 44 def { class: "one-container-image", style: image_styles } end |
#image_styles ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/maglove/widgets/container.rb', line 67 def image_styles if [:alignment] == "left" [:margin_left] = "0" [:margin_right] = "auto" elsif [:alignment] == "right" [:margin_left] = "auto" [:margin_right] = "0" else [:margin_left] = "auto" [:margin_right] = "auto" end style_string , :min_height, :max_height, :max_width, :padding, :overflow_y, :margin_left, :margin_right do |sb| if [:background_color] != "overlay" sb.add(:background_image, [:image_source], "url(<%= value %>)") end end end |