Class: Maglove::Widget::LegacyListitem
- Defined in:
- lib/maglove/widget/listitem.rb
Instance Attribute Summary
Attributes inherited from Base
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
#defaults ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/maglove/widget/listitem.rb', line 31 def defaults { background_color: "#18B545", text_color: "#FFFFFF", 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 |
#identifier ⇒ Object
27 28 29 |
# File 'lib/maglove/widget/listitem.rb', line 27 def identifier "listitem" end |
#render(&block) ⇒ Object
48 49 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 |
# File 'lib/maglove/widget/listitem.rb', line 48 def render(&block) super do haml_tag :a, { class: "list-item list-item-#{[:size]}", href: ([:href] or "#"), style: style_string(, :border_color, :background_color) } do if [:icon] haml_tag :i, { class: "list-item-icon fa fa-#{[:icon]}" } end if [:image_source] image_style = style_string() do |sb| sb.add(:background_image, [: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: #{[:text_color]}" } do haml_concat([:title]) end if [:subtitle] haml_tag :div, { class: "list-item-subtitle", style: "color: #{[:text_color]}; font-style: #{[:subtitle_style]}" } do haml_concat([:subtitle]) end end end if [:badge] haml_tag :div, { class: "list-item-badge" } do haml_tag :span, { style: "color: #{[:badge_color]}; background-color: #{[:badge_background]}; width: #{[:badge_width]};" } do haml_concat([:badge]) end end end if [:href] haml_tag :i, { class: "list-item-arrow fa fa-angle-right", style: "color: #{[:arrow_color]}" } end end end end |