Class: Warped::Emails::Button

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

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, href, type: :primary, size: :md) ⇒ Button

Returns a new instance of Button.



35
36
37
38
39
40
41
# File 'lib/warped/emails/components/button.rb', line 35

def initialize(text = nil, href, type: :primary, size: :md)
  super()
  @text = text
  @href = href
  @type = type
  @size = size
end

Instance Method Details

#templateObject



47
48
49
50
51
# File 'lib/warped/emails/components/button.rb', line 47

def template
  style = style(type:, size:)

  tag.a(text, href:, style:)
end

#textObject



43
44
45
# File 'lib/warped/emails/components/button.rb', line 43

def text
  content.presence || @text
end