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, #icon, #options, #popover?, #random_id, #remove_class, #remove_class_from_props, #render_popover_or_tooltip, #target, #tooltip?
Methods included from IconHelpers
#chevron_double_left, #chevron_double_right, #chevron_down, #chevron_left, #chevron_right, #chevron_up, #close_icon, #ellipsis_horizontal, #eye_icon, #eye_slash_icon, #plus_icon
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 48 |
# File 'app/components/fluxbit/badge_component.rb', line 36 def initialize(**props) super @props = props @color = @props.delete(:color), collection: styles[:colors].keys, default: @@color @pill = @props.delete(:pill), default: @@pill @size = @props.delete(:size), default: @@size @perfect_rounded = @props.delete(:perfect_rounded), default: @@perfect_rounded @notification = @props.delete(:notification), default: @@notification @as = @props.delete(:as), default: @@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
50 51 52 |
# File 'app/components/fluxbit/badge_component.rb', line 50 def before_render add_popover_or_tooltip end |
#call ⇒ Object
54 55 56 |
# File 'app/components/fluxbit/badge_component.rb', line 54 def call concat(content_tag(@as, content, @props) + render_popover_or_tooltip.to_s) end |