Sha256: f3a0eb2822d13ef08691534eb6a0ae9ef22803055900ab9ff3e9dd48a36933c3

Contents?: true

Size: 947 Bytes

Versions: 3

Compression:

Stored size: 947 Bytes

Contents

module Panda
  module CMS
    module EditorJs
      module Blocks
        class Alert < Base
          def render
            message = sanitize(data["message"])
            type = data["type"] || "primary"

            html_safe(
              "<div class=\"#{alert_classes(type)} p-4 mb-4 rounded-lg\">" \
                "#{message}" \
              "</div>"
            )
          end

          private

          def alert_classes(type)
            case type
            when "primary" then "bg-blue-100 text-blue-800"
            when "secondary" then "bg-gray-100 text-gray-800"
            when "success" then "bg-green-100 text-green-800"
            when "danger" then "bg-red-100 text-red-800"
            when "warning" then "bg-yellow-100 text-yellow-800"
            when "info" then "bg-indigo-100 text-indigo-800"
            else "bg-blue-100 text-blue-800"
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
panda-cms-0.7.3 lib/panda/cms/editor_js/blocks/alert.rb
panda-cms-0.7.2 lib/panda/cms/editor_js/blocks/alert.rb
panda-cms-0.7.0 lib/panda/cms/editor_js/blocks/alert.rb