Class: KozenetUi::BadgeComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/kozenet_ui/badge_component.rb

Overview

Badge component for labels, statuses, and counts Supports multiple variants and sizes

Examples:

Status badge

<%= kz_badge(variant: :success) { "Active" } %>

Count badge

<%= kz_badge(variant: :primary, size: :sm) { "99+" } %>

With icon

<%= kz_badge(variant: :warning) do |badge| %>
  <% badge.with_icon do %>
    <svg>...</svg>
  <% end %>
  Pending
<% end %>

Constant Summary

Constants inherited from BaseComponent

KozenetUi::BaseComponent::UNSET

Instance Attribute Summary

Attributes inherited from BaseComponent

#html_options, #size, #variant

Instance Method Summary collapse

Constructor Details

#initialize(variant: :primary, size: :md, pill: true, **html_options) ⇒ BadgeComponent

Returns a new instance of BadgeComponent.



23
24
25
26
27
28
29
30
31
# File 'app/components/kozenet_ui/badge_component.rb', line 23

def initialize(
  variant: :primary,
  size: :md,
  pill: true,
  **html_options
)
  super(variant: variant, size: size, **html_options)
  @pill = pill
end

Instance Method Details

#callObject



33
34
35
36
37
# File 'app/components/kozenet_ui/badge_component.rb', line 33

def call
  tag.span(**html_attrs) do
    badge_content
  end
end