Class: Maglove::Widget::LegacyListitem

Inherits:
V1
  • Object
show all
Defined in:
lib/maglove/widget/listitem.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #scope

Instance Method Summary collapse

Methods inherited from V1

#drop_container, #widget_options

Methods inherited from Base

#initialize, #style_string, #widget_options

Constructor Details

This class inherits a constructor from Maglove::Widget::Base

Instance Method Details

#defaultsObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/maglove/widget/listitem.rb', line 32

def defaults
  {
    background_color: "#18B545",
    title_color: "#111111",
    subtitle_color: "#111111",
    arrow_color: "#FFFFFF",
    size: "md",
    badge: nil,
    badge_color: "#FFFFFF",
    badge_background: "rgba(255, 255, 255, 0.25)",
    badge_width: "24px",
    title: "Title",
    subtitle: nil,
    subtitle_style: "normal",
    image_source: nil
  }
end

#identifierObject



28
29
30
# File 'lib/maglove/widget/listitem.rb', line 28

def identifier
  "listitem"
end

#render(&block) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/maglove/widget/listitem.rb', line 50

def render(&block)
  super do
    haml_tag :a, { class: "list-item list-item-#{options[:size]}", href: (options[:href] or "#"), style: style_string(options, :border_color, :background_color) } do
      if options[:icon]
        haml_tag :i, { class: "list-item-icon fa fa-#{options[:icon]}" }
      end
      if options[:image_source]
        image_style = style_string(options) do |sb|
          sb.add(:background_image, 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", style: "color: #{options[:title_color]}" } do
          haml_concat(options[:title])
        end
        if options[:subtitle]
          haml_tag :div, { class: "list-item-subtitle", style: "color: #{options[:subtitle_color]}; font-style: #{options[:subtitle_style]}" } do
            haml_concat(options[:subtitle])
          end
        end
      end
      if options[:badge]
        haml_tag :div, { class: "list-item-badge" } do
          haml_tag :span, { style: "color: #{options[:badge_color]}; background-color: #{options[:badge_background]}; width: #{options[:badge_width]};" } do
            haml_concat(options[:badge])
          end
        end
      end
      if options[:href]
        haml_tag :i, { class: "list-item-arrow fa fa-angle-right", style: "color: #{options[:arrow_color]}" }
      end
    end
  end
end