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
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 |
#identifier ⇒ Object
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-#{[: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: #{[:title_color]}" } do haml_concat([:title]) end if [:subtitle] haml_tag :div, { class: "list-item-subtitle", style: "color: #{[:subtitle_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 |