Class: Railsboot::CalloutComponent

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

Overview

ViewComponent: renders the callout block.

Constant Summary collapse

VARIANTS =

Variants.

["", "warning", "info", "danger"].freeze
DEFAULT_VARIANT =

Default variant.

"".freeze

Instance Method Summary collapse

Constructor Details

#initialize(variant: DEFAULT_VARIANT, **html_attributes) ⇒ CalloutComponent

Returns a new instance of CalloutComponent.



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

def initialize(variant: DEFAULT_VARIANT, **html_attributes)
  @variant = fetch_or_fallback(variant, VARIANTS, DEFAULT_VARIANT)
  @html_attributes = html_attributes

  @html_attributes[:class] = class_names(
    "callout",
    { "callout-#{@variant}" => @variant.present? },
    html_attributes.delete(:class)
  )
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/components/railsboot/callout_component.rb', line 20

def render?
  content.present?
end