Sha256: 7f96c308916a4ada45906dd55e1bc694257e20b88e2f8263f6dcc31df64fbffe

Contents?: true

Size: 896 Bytes

Versions: 3

Compression:

Stored size: 896 Bytes

Contents

# frozen_string_literal: true

module Panda
  module CMS
    module Admin
      class TagComponent < ViewComponent::Base
        attr_accessor :status, :text

        def initialize(status: :active, text: nil)
          @status = status.to_sym
          @text = text || status.to_s.humanize
        end

        def call
          classes = "inline-flex items-center py-1 px-2 text-xs font-medium rounded-md ring-1 ring-inset "

          classes += case @status
          when :active
            "text-white ring-black/30 bg-active border-0 "
          when :draft
            "text-black ring-black/30 bg-warning "
          when :inactive, :hidden
            "text-black ring-black/30 bg-black/5 bg-white "
          else
            "text-black bg-white "
          end

          content_tag :span, class: classes do
            @text
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
panda-cms-0.7.3 app/components/panda/cms/admin/tag_component.rb
panda-cms-0.7.2 app/components/panda/cms/admin/tag_component.rb
panda-cms-0.7.0 app/components/panda/cms/admin/tag_component.rb