Class: Maglove::Widget::LegacyParagraph

Inherits:
V1
  • Object
show all
Defined in:
lib/maglove/widget/paragraph.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #scope

Instance Method Summary collapse

Methods inherited from V1

#drop_container, #widget_options

Methods inherited from Base

#initialize, #style_string, #widget_options

Constructor Details

This class inherits a constructor from Maglove::Widget::Base

Instance Method Details

#defaultsObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/maglove/widget/paragraph.rb', line 24

def defaults
  {
    style: "default",
    align: "left",
    size: "md",
    margin_bottom: "1em",
    drop_cap: nil,
    drop_cap_color: "#000000",
    line_height: nil
  }
end

#identifierObject



20
21
22
# File 'lib/maglove/widget/paragraph.rb', line 20

def identifier
  "paragraph"
end

#render(&block) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/maglove/widget/paragraph.rb', line 36

def render(&block)
  super do
    haml_tag :div, style: style_string(options, :margin, :padding), class: "paragraph #{options[:style]} align-#{options[:align]} size-#{options[:size]}" do
      unless options[:drop_cap].nil?
        color_attr = options[:style].include?('inverse-dropcap') ? "background-color" : "color"
        haml_tag :span, class: "__dropcap", style: "#{color_attr}: #{options[:drop_cap_color]};" do
          haml_concat(options[:drop_cap])
        end
      end
      haml_tag :span, style: style_string(options, :line_height), class: "paragraph-content _typeloft_editable _typeloft_widget_autoselect" do
        yield self if block_given?
      end
    end
  end
end