Class: Maglove::Widgets::Paragraph

Inherits:
Base
  • Object
show all
Defined in:
lib/maglove/widgets/paragraph.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #scope

Instance Method Summary collapse

Methods inherited from Base

#initialize, #widget_options

Constructor Details

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

Instance Method Details

#defaultsObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/maglove/widgets/paragraph.rb', line 8

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

#identifierObject



4
5
6
# File 'lib/maglove/widgets/paragraph.rb', line 4

def identifier
  "paragraph"
end

#template(&block) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/maglove/widgets/paragraph.rb', line 19

def template(&block)
  scope.haml_tag :div, class: "paragraph #{options[:style]} align-#{options[:align]} size-#{options[:size]}" do
    unless options[:drop_cap].empty?
      haml_tag :span, class: "__dropcap", style: "color: #{options[:drop_cap_color]};" do
        haml_concat(options[:drop_cap])
      end
    end
    haml_tag :span, contenteditable: true, class: "paragraph-content", style: style_string(options, :line_height) do
      yield if block
    end
  end
end