Class: DaisyUI::Badge
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- DaisyUI::Badge
- Defined in:
- app/components/daisy_ui/data_display/badge.rb
Overview
Badge component implementing DaisyUI’s badge styles
Constant Summary collapse
- COLORS =
Available badge colors from DaisyUI
{ primary: 'badge-primary', secondary: 'badge-secondary', accent: 'badge-accent', neutral: 'badge-neutral', ghost: 'badge-ghost', info: 'badge-info', success: 'badge-success', warning: 'badge-warning', error: 'badge-error' }.freeze
- SIZES =
Available badge sizes from DaisyUI
{ xl: 'badge-xl', lg: 'badge-lg', md: 'badge-md', sm: 'badge-sm', xs: 'badge-xs' }.freeze
- VARIANTS =
Available badge variants from DaisyUI
{ outline: 'badge-outline', soft: 'badge-soft', dash: 'badge-dash', ghost: 'badge-ghost' }.freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(text = nil, color: nil, size: nil, variant: nil, icon: nil, tag_type: :div, **system_arguments) ⇒ Badge
constructor
A new instance of Badge.
Constructor Details
#initialize(text = nil, color: nil, size: nil, variant: nil, icon: nil, tag_type: :div, **system_arguments) ⇒ Badge
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/components/daisy_ui/data_display/badge.rb', line 75 def initialize( text = nil, color: nil, size: nil, variant: nil, icon: nil, tag_type: :div, **system_arguments ) @text = text @color = build_argument(color, COLORS, 'color') @size = build_argument(size, SIZES, 'size') @variant = build_argument(variant, VARIANTS, 'variant') @icon = icon @tag_type = tag_type super(**system_arguments) end |
Instance Method Details
#call ⇒ Object
94 95 96 97 98 |
# File 'app/components/daisy_ui/data_display/badge.rb', line 94 def call tag.public_send(@tag_type, **html_attributes) do safe_join([render_icon, content || @text].compact) end end |