Sha256: e09788b029e76686fa6cf90fb9d9d47c06145d03110daf1b6185afc7e7bf8a08

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 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: ""
        }
      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) do
                haml_concat(contents) if contents
                yield if block
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
maglove-widgets-1.1.6 lib/maglove/widgets/heading.rb
maglove-widgets-1.1.5 lib/maglove/widgets/heading.rb
maglove-widgets-1.1.4 lib/maglove/widgets/heading.rb
maglove-widgets-1.1.3 lib/maglove/widgets/heading.rb
maglove-widgets-1.0.8 lib/maglove/widgets/heading.rb
maglove-widgets-1.0.7 lib/maglove/widgets/heading.rb
maglove-widgets-1.0.6 lib/maglove/widgets/heading.rb
maglove-widgets-1.0.5 lib/maglove/widgets/heading.rb