Class: Warped::Emails::Text

Inherits:
Base
  • Object
show all
Defined in:
lib/warped/emails/components/text.rb

Direct Known Subclasses

Link

Instance Attribute Summary

Attributes inherited from Base

#view_context

Instance Method Summary collapse

Methods inherited from Base

#content, #helpers, #render_in

Methods included from Styleable

#base_styles, #default_variants, included, #style, #variants

Methods included from Slottable

included, #slots

Constructor Details

#initialize(text = nil, size: nil, color: nil, weight: nil, align: nil, display: nil) ⇒ Text

Returns a new instance of Text.



42
43
44
45
46
47
48
49
50
# File 'lib/warped/emails/components/text.rb', line 42

def initialize(text = nil, size: nil, color: nil, weight: nil, align: nil, display: nil)
  super()
  @text = text
  @size = size
  @color = color
  @weight = weight
  @align = align
  @display = display
end

Instance Method Details

#templateObject



56
57
58
59
60
# File 'lib/warped/emails/components/text.rb', line 56

def template(&)
  style = style(size:, color:, weight:, align:, display:)

  tag.p(text, style:)
end

#textObject



52
53
54
# File 'lib/warped/emails/components/text.rb', line 52

def text
  content.presence || @text
end