Class: Railsboot::RatingGroupComponent
- Inherits:
-
Component
- Object
- Component
- Railsboot::RatingGroupComponent
- Defined in:
- app/components/railsboot/rating_group_component.rb
Overview
ViewComponent: renders the rating group block.
Defined Under Namespace
Classes: BackgroundIconComponent, FillIconComponent
Constant Summary collapse
- DEFAULT_AMOUNT =
Default amount.
5
Instance Method Summary collapse
-
#initialize(amount: DEFAULT_AMOUNT, value: 0, background_color: "black", fill_color: "primary", gap: 0, **html_attributes) ⇒ RatingGroupComponent
constructor
A new instance of RatingGroupComponent.
-
#render? ⇒ Boolean
Only renders when both the background and fill icon slots have content.
Constructor Details
#initialize(amount: DEFAULT_AMOUNT, value: 0, background_color: "black", fill_color: "primary", gap: 0, **html_attributes) ⇒ RatingGroupComponent
Returns a new instance of RatingGroupComponent.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/components/railsboot/rating_group_component.rb', line 17 def initialize(amount: DEFAULT_AMOUNT, value: 0, background_color: "black", fill_color: "primary", gap: 0, **html_attributes) @amount = amount @value = value @background_color = background_color @fill_color = fill_color @gap = gap @html_attributes = html_attributes @html_attributes[:class] = class_names( "position-relative d-inline-flex text-#{@background_color} gap-#{@gap}", html_attributes[:class] ) end |
Instance Method Details
#render? ⇒ Boolean
Only renders when both the background and fill icon slots have content.
33 34 35 |
# File 'app/components/railsboot/rating_group_component.rb', line 33 def render? [background_icon, fill_icon].all?(&:present?) end |