Class: BetterUi::BadgeComponent

Inherits:
ApplicationComponent show all
Includes:
Concerns::InlineLabelStyles
Defined in:
app/components/better_ui/badge_component.rb

Constant Summary collapse

SIZES =
{
  xs: { padding: "px-1.5 py-0.5", text: "text-xs", icon: "w-3 h-3", gap: "gap-1" },
  sm: { padding: "px-2 py-0.5", text: "text-xs", icon: "w-3.5 h-3.5", gap: "gap-1" },
  md: { padding: "px-2.5 py-1", text: "text-sm", icon: "w-4 h-4", gap: "gap-1.5" },
  lg: { padding: "px-3 py-1.5", text: "text-base", icon: "w-5 h-5", gap: "gap-2" }
}.freeze
STYLES =
i[solid outline soft ghost].freeze

Constants inherited from ApplicationComponent

ApplicationComponent::SHADOWS, ApplicationComponent::VARIANTS, ApplicationComponent::VARIANT_BODY_DIVIDE, ApplicationComponent::VARIANT_DIVIDE, ApplicationComponent::VARIANT_HEADER_BG, ApplicationComponent::VARIANT_HEADER_TEXT, ApplicationComponent::VARIANT_HIGHLIGHTED, ApplicationComponent::VARIANT_HOVERABLE, ApplicationComponent::VARIANT_RING, ApplicationComponent::VARIANT_SORT_ICON, ApplicationComponent::VARIANT_STRIPED

Instance Method Summary collapse

Constructor Details

#initialize(variant: :primary, style: :solid, size: :md, pill: true, dot: false, counter: nil, container_classes: nil, **options) ⇒ BadgeComponent

Returns a new instance of BadgeComponent.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/components/better_ui/badge_component.rb', line 18

def initialize(
  variant: :primary,
  style: :solid,
  size: :md,
  pill: true,
  dot: false,
  counter: nil,
  container_classes: nil,
  **options
)
  @variant = validate_variant(variant)
  @style = validate_style(style)
  @size = validate_size(size)
  @pill = pill
  @dot = dot
  @counter = counter
  @container_classes = container_classes
  @options = options
end