Class: DesignSystem::Generic::InsetTextComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/design_system/generic/inset_text_component.rb

Overview

Inset text used to differentiate a block of content from what surrounds it, rendered by ds_inset_text. Content comes from the text argument or a block (block wins if both are given). Renders nothing when blank.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::CssHelper

#css_class_options_merge

Methods included from BrandDerivable

#brand

Constructor Details

#initialize(text: nil, **options) ⇒ InsetTextComponent

Returns a new instance of InsetTextComponent.



7
8
9
10
11
# File 'app/components/design_system/generic/inset_text_component.rb', line 7

def initialize(text: nil, **options)
  super()
  @text = text
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



13
14
15
# File 'app/components/design_system/generic/inset_text_component.rb', line 13

def options
  @options
end

#textObject (readonly)

Returns the value of attribute text.



13
14
15
# File 'app/components/design_system/generic/inset_text_component.rb', line 13

def text
  @text
end

Instance Method Details

#inset_optionsObject



19
20
21
# File 'app/components/design_system/generic/inset_text_component.rb', line 19

def inset_options
  css_class_options_merge(options, ["#{brand}-inset-text"])
end

#render?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/components/design_system/generic/inset_text_component.rb', line 15

def render?
  text.present? || content.present?
end