Class: Railsboot::BadgeComponent
- Inherits:
-
Component
- Object
- Component
- Railsboot::BadgeComponent
- Defined in:
- app/components/railsboot/badge_component.rb
Overview
ViewComponent: renders the badge block.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(pill: false, color: DEFAULT_COLOR, **html_attributes) ⇒ BadgeComponent
constructor
A new instance of BadgeComponent.
Constructor Details
#initialize(pill: false, color: DEFAULT_COLOR, **html_attributes) ⇒ BadgeComponent
Returns a new instance of BadgeComponent.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/components/railsboot/badge_component.rb', line 4 def initialize(pill: false, color: DEFAULT_COLOR, **html_attributes) @pill = pill @color = fetch_or_raise(color, COLORS) @html_attributes = html_attributes @html_attributes[:tag] = :span @html_attributes[:class] = class_names( "badge", "bg-#{@color}", { "rounded-pill" => @pill }, html_attributes.delete(:class) ) end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 |
# File 'app/components/railsboot/badge_component.rb', line 18 def call render Railsboot::BaseComponent.new(**@html_attributes) do content end end |