Class: Fluxbit::BadgeComponent
- Includes:
- Config::BadgeComponent
- Defined in:
- app/components/fluxbit/badge_component.rb
Overview
The ‘Fluxbit::BadgeComponent` is a customizable badge component that extends `Fluxbit::Component`. It allows you to create badges with different colors, sizes, borders, and shapes (pill).
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
- #before_render ⇒ Object
- #call ⇒ Object
-
#initialize(**props) ⇒ Fluxbit::BadgeComponent
constructor
Initializes the badge component with the given properties.
Methods inherited from Component
#add, #add_popover_or_tooltip, #anyicon, #element_name, #fx_id, #options, #random_id, #remove_class, #render_popover_or_tooltip, #target
Constructor Details
#initialize(**props) ⇒ Fluxbit::BadgeComponent
Initializes the badge component with the given properties.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/components/fluxbit/badge_component.rb', line 36 def initialize(**props) super @props = props @color = @props.delete(:color) || @@color @pill = @props.delete(:pill) || @@pill @size = @props.delete(:size) || @@size @perfect_rounded = @props.delete(:perfect_rounded) || @@perfect_rounded @notification = @props.delete(:notification) || @@notification @as = @props.delete(:as) || @@as add(class: badge_classes, to: @props, first_element: true) @props[:class] = remove_class(@props.delete(:remove_class) || "", @props[:class]) end |
Instance Method Details
#before_render ⇒ Object
49 50 51 |
# File 'app/components/fluxbit/badge_component.rb', line 49 def before_render add_popover_or_tooltip end |
#call ⇒ Object
53 54 55 |
# File 'app/components/fluxbit/badge_component.rb', line 53 def call concat(content_tag(@as, content, @props) + render_popover_or_tooltip.to_s) end |