Sha256: 29e92938c1227f1d3e64f0e80a288706f820b5bbdd26899e9e6ffc3eb36d5923

Contents?: true

Size: 830 Bytes

Versions: 4

Compression:

Stored size: 830 Bytes

Contents

# frozen_string_literal: true

module PandaCms
  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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
panda_cms-0.6.3 app/components/panda_cms/admin/tag_component.rb
panda_cms-0.6.2 app/components/panda_cms/admin/tag_component.rb
panda_cms-0.6.1 app/components/panda_cms/admin/tag_component.rb
panda_cms-0.6.0 app/components/panda_cms/admin/tag_component.rb