Sha256: 536dbe00a03db9cb2d1342de9e2b13160b6045528dee8827213134b04700bc4e

Contents?: true

Size: 1.37 KB

Versions: 10

Compression:

Stored size: 1.37 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?
                haml_tag :span, class: "__dropcap", style: "color: #{widget.options[:drop_cap_color]};" do
                  haml_concat(widget.options[:drop_cap])
                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
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
maglove-widgets-1.1.3 lib/maglove/widgets/paragraph.rb
maglove-widgets-1.0.8 lib/maglove/widgets/paragraph.rb
maglove-widgets-1.0.7 lib/maglove/widgets/paragraph.rb
maglove-widgets-1.0.6 lib/maglove/widgets/paragraph.rb
maglove-widgets-1.0.5 lib/maglove/widgets/paragraph.rb
maglove-widgets-1.0.4 lib/maglove/widgets/paragraph.rb
maglove-widgets-1.0.3 lib/maglove/widgets/paragraph.rb
maglove-widgets-1.0.2 lib/maglove/widgets/paragraph.rb
maglove-widgets-1.0.1 lib/maglove/widgets/paragraph.rb
maglove-widgets-1.0.0 lib/maglove/widgets/paragraph.rb