Sha256: ed5998180d2c3c38c7e1df3d57cb464885b66ceba65ea1cdb645acaec86faf5c

Contents?: true

Size: 826 Bytes

Versions: 3

Compression:

Stored size: 826 Bytes

Contents

module Components::BadgeHelper
  def render_badge(label = "", data: "", text: "", variant: :default, **options)
    badge_classes = " inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2  "
    varianet_classes = case variant.to_sym
    when :default
      ComponentsHelper::PRIMARY_CLASSES
    when :secondary
      ComponentsHelper::SECONDARY_CLASSES
    when :error, :danger, :alert, :destructive
      ComponentsHelper::DESTRUCTIVE_CLASSES
    when :outline
      ComponentsHelper::OUTLINE_CLASSES
    when :ghost
      ComponentsHelper::GHOST_CLASSES
    end
    badge_classes << " #{varianet_classes}"
    text = label if label.present?

    content_tag :div, class: badge_classes do
      text
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shadcn-ui-0.0.12 app/helpers/components/badge_helper.rb
shadcn-ui-0.0.10 app/helpers/components/badge_helper.rb
shadcn-ui-0.0.8 app/helpers/components/badge_helper.rb