Class: Railsboot::RibbonComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/ribbon_component.rb

Constant Summary collapse

POSITIONS =
["top-left", "top-right", "bottom-left", "bottom-right"].freeze
DEFAULT_POSITION =
"top-right"
DEFAULT_FIXED =
true

Instance Method Summary collapse

Constructor Details

#initialize(position: DEFAULT_POSITION, fixed: DEFAULT_FIXED, **html_attributes) ⇒ RibbonComponent

Returns a new instance of RibbonComponent.



7
8
9
10
11
12
13
14
15
16
17
# File 'app/components/railsboot/ribbon_component.rb', line 7

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

Returns:

  • (Boolean)


19
20
21
# File 'app/components/railsboot/ribbon_component.rb', line 19

def render?
  content.present?
end