Sha256: bde4955ad973f1e8f265e179d0854d5fbaf01aa1313f198e96c824ef3362ebf0
Contents?: true
Size: 1.63 KB
Versions: 6
Compression:
Stored size: 1.63 KB
Contents
module Maglove module Widgets class Paragraph < Base def identifier "paragraph" end def defaults { style: "default", align: "left", size: "md", margin_bottom: "1em", drop_cap: "", drop_cap_color: "#000000", line_height: "" } end module Helpers def paragraph_widget(options = {}, contents = nil, &block) if options.class.name == "String" contents = options options = {} end widget_block(Widgets::Paragraph.new(options)) do |widget| haml_tag :div, style: style_string(widget.options, :margin, :padding), class: "paragraph #{widget.options[:style]} align-#{widget.options[:align]} size-#{widget.options[:size]}" do unless widget.options[:drop_cap].empty? if widget.options[:style].include?('inverse-dropcap') set_dropcap widget, "background-color" else set_dropcap widget, "color" end end haml_tag :span, class: "paragraph-content _typeloft_editable _typeloft_widget_autoselect", style: style_string(widget.options, :line_height) do haml_concat(contents) if contents yield if block end end end end def set_dropcap widget, color_attribute haml_tag :span, class: "__dropcap", style: "#{color_attribute}: #{widget.options[:drop_cap_color]};" do haml_concat(widget.options[:drop_cap]) end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems