Class: DesignSystem::Generic::ParagraphComponent

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

Overview

Body paragraph with typography styling, rendered by ds_paragraph. Content can be passed as the text argument or as a block. An optional size selects a smaller body style.

Constant Summary collapse

FONT_SIZES =
%i[s].freeze

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, size: nil, **options) ⇒ ParagraphComponent

Returns a new instance of ParagraphComponent.



9
10
11
12
13
14
# File 'app/components/design_system/generic/paragraph_component.rb', line 9

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

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



16
17
18
# File 'app/components/design_system/generic/paragraph_component.rb', line 16

def options
  @options
end

#sizeObject (readonly)

Returns the value of attribute size.



16
17
18
# File 'app/components/design_system/generic/paragraph_component.rb', line 16

def size
  @size
end

#textObject (readonly)

Returns the value of attribute text.



16
17
18
# File 'app/components/design_system/generic/paragraph_component.rb', line 16

def text
  @text
end

Instance Method Details

#callObject



24
25
26
# File 'app/components/design_system/generic/paragraph_component.rb', line 24

def call
  (:p, body, **paragraph_options)
end

#render?Boolean

Renders nothing when neither block content nor text is supplied, matching the previous builder behaviour.

Returns:

  • (Boolean)


20
21
22
# File 'app/components/design_system/generic/paragraph_component.rb', line 20

def render?
  body.present?
end