Class: PhlexKit::Badge
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::Badge
- Defined in:
- app/components/phlex_kit/badge/badge.rb
Overview
Pill/label badge, ported from ruby_ui's RubyUI::Badge to variant/size parity.
Same kit shape as PhlexKit::Button — a variant:/size: selector plus attrs/block
passed through to the . ruby_ui's semantic variants are ported; its long
raw-colour palette (red/blue/teal/…) is omitted as unused. Tailwind → vanilla
.pk-badge CSS (badge.css). VARIANTS.fetch fails loud.
Constant Summary collapse
- VARIANTS =
{ primary: "primary", secondary: "secondary", outline: "outline", destructive: "destructive", success: "success", warning: "warning" }.freeze
- SIZES =
{ sm: "sm", md: nil, lg: "lg" }.freeze
Instance Method Summary collapse
-
#initialize(variant: :primary, size: :md, **attrs) ⇒ Badge
constructor
A new instance of Badge.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(variant: :primary, size: :md, **attrs) ⇒ Badge
Returns a new instance of Badge.
23 24 25 26 27 |
# File 'app/components/phlex_kit/badge/badge.rb', line 23 def initialize(variant: :primary, size: :md, **attrs) @variant = variant.to_sym @size = size.to_sym @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
29 30 31 |
# File 'app/components/phlex_kit/badge/badge.rb', line 29 def view_template(&block) span(**mix({ class: classes }, @attrs), &block) end |