Class: DesignSystem::Generic::ParagraphComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- DesignSystem::Generic::ParagraphComponent
- 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.
Direct Known Subclasses
DesignSystem::Govuk::ParagraphComponent, Nhsuk::ParagraphComponent
Constant Summary collapse
- FONT_SIZES =
%i[s].freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(text: nil, size: nil, **options) ⇒ ParagraphComponent
constructor
A new instance of ParagraphComponent.
-
#render? ⇒ Boolean
Renders nothing when neither block content nor text is supplied, matching the previous builder behaviour.
Methods included from Helpers::CssHelper
Methods included from BrandDerivable
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, **) super() @text = text @size = size @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'app/components/design_system/generic/paragraph_component.rb', line 16 def @options end |
#size ⇒ Object (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 |
#text ⇒ Object (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
#call ⇒ Object
24 25 26 |
# File 'app/components/design_system/generic/paragraph_component.rb', line 24 def call content_tag(:p, body, **) end |
#render? ⇒ Boolean
Renders nothing when neither block content nor text is supplied, matching the previous builder behaviour.
20 21 22 |
# File 'app/components/design_system/generic/paragraph_component.rb', line 20 def render? body.present? end |