Class: LcpRuby::Display::TextBadge

Inherits:
BaseRenderer show all
Defined in:
lib/lcp_ruby/display/text_badge.rb

Instance Method Summary collapse

Methods inherited from BaseRenderer

#link_producing?

Instance Method Details

#render(value, options = {}, record: nil, view_context: nil) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/lcp_ruby/display/text_badge.rb', line 4

def render(value, options = {}, record: nil, view_context: nil)
  text = value.is_a?(Hash) ? value["text"] : value.to_s
  color = value.is_a?(Hash) ? value["color"] : options["color"]
  return nil if text.blank?

  opts = { class: "lcp-menu-badge lcp-menu-badge-text" }
  opts[:style] = "background:#{color}" if color
  view_context.(:span, text, opts)
end