Class: Railsboot::RibbonComponent
- Inherits:
-
Component
- Object
- Component
- Railsboot::RibbonComponent
- Defined in:
- app/components/railsboot/ribbon_component.rb
Overview
ViewComponent: renders the ribbon block.
Constant Summary collapse
- POSITIONS =
Positions.
%w[top-left top-right bottom-left bottom-right].freeze
- DEFAULT_POSITION =
Default position.
"top-right".freeze
- DEFAULT_FIXED =
Default fixed.
true
Instance Method Summary collapse
-
#initialize(position: DEFAULT_POSITION, fixed: DEFAULT_FIXED, **html_attributes) ⇒ RibbonComponent
constructor
A new instance of RibbonComponent.
- #render? ⇒ Boolean
Constructor Details
#initialize(position: DEFAULT_POSITION, fixed: DEFAULT_FIXED, **html_attributes) ⇒ RibbonComponent
Returns a new instance of RibbonComponent.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/components/railsboot/ribbon_component.rb', line 12 def initialize(position: DEFAULT_POSITION, fixed: DEFAULT_FIXED, **html_attributes) @position = fetch_or_raise(position, POSITIONS) @html_attributes = html_attributes @html_attributes[:class] = class_names( "ribbon", "ribbon--#{@position}", { "ribbon--absolute" => !fixed }, html_attributes[:class] ).presence end |
Instance Method Details
#render? ⇒ Boolean
24 25 26 |
# File 'app/components/railsboot/ribbon_component.rb', line 24 def render? content.present? end |