module Maglove module Widgets class Listitem < Base def identifier "listitem" end def defaults { background_color: "#18B545", size: "md", badge: nil, title: "Title", subtitle: nil, image_source: nil } end def styles style_string @options, :border_color, :background_color end module Helpers def listitem_widget(options = {}) widget_block(Widgets::Listitem.new(options)) do |widget| haml_tag :a, { class: "list-item list-item-#{widget.options[:size]}", href: (widget.options[:href] or "#"), style: widget.styles } do if widget.options[:icon] haml_tag :i, { class: "list-item-icon fa fa-#{widget.options[:icon]}" } end if widget.options[:image_source] image_style = style_string(widget.options) do |sb| sb.add(:background_image, widget.options[:image_source], "url(<%= value %>)") end haml_tag :div, { class: "list-item-image", style: image_style } end haml_tag :div, { class: "list-item-main" } do haml_tag :div, { class: "list-item-title" } do haml_concat(widget.options[:title]) end if widget.options[:subtitle] haml_tag :div, { class: "list-item-subtitle" } do haml_concat(widget.options[:subtitle]) end end end if widget.options[:badge] haml_tag :div, { class: "list-item-badge" } do haml_tag :span do haml_concat(widget.options[:badge]) end end end if widget.options[:href] haml_tag :i, { class: "list-item-arrow fa fa-angle-right" } end end end end end end end end