Sha256: 168c9efe4a6bb67d0bdab0a3a685169dab4e52058149c79d2f60b4133601d7d6

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

module Maglove
  module Widgets
    class Heading < Base
      def identifier
        "heading"
      end

      def defaults
        {
          type: "h1",
          style: "default",
          align: "left",
          margin_bottom: "1em",
          line_height: "",
          letter_spacing: ""
        }
      end

      module Helpers
        def heading_widget(options = {}, contents = nil, &block)
          if options.class.name == "String"
            contents = options
            options = {}
          end
          widget_block(Widgets::Heading.new(options)) do |widget|
            haml_tag :header, class: "#{widget.options[:style]} align-#{widget.options[:align]}", style: style_string(widget.options, :margin, :padding) do
              haml_tag widget.options[:type], class: "_typeloft_editable _typeloft_widget_autoselect", style: style_string(widget.options, :line_height, :letter_spacing) do
                haml_concat(contents) if contents
                yield if block
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
maglove-widgets-1.1.9 lib/maglove/widgets/heading.rb
maglove-widgets-1.1.8 lib/maglove/widgets/heading.rb
maglove-widgets-1.1.7 lib/maglove/widgets/heading.rb