Class: Flowbite::Badge::Dot

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/flowbite/badge/dot.rb

Overview

Renders a colored dot indicator for use inside a badge.

Constant Summary collapse

CLASSES =
{
  alternative: ["bg-heading", "me-1", "rounded-full"],
  brand: ["bg-fg-brand-strong", "me-1", "rounded-full"],
  danger: ["bg-fg-danger-strong", "me-1", "rounded-full"],
  gray: ["bg-heading", "me-1", "rounded-full"],
  success: ["bg-fg-success-strong", "me-1", "rounded-full"],
  warning: ["bg-fg-warning", "me-1", "rounded-full"]
}.freeze
SIZES =
{
  default: ["h-1.5", "w-1.5"]
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size: :default, style: :brand) ⇒ Dot

Returns a new instance of Dot.



35
36
37
38
# File 'app/components/flowbite/badge/dot.rb', line 35

def initialize(size: :default, style: :brand)
  @size = size
  @style = style
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



33
34
35
# File 'app/components/flowbite/badge/dot.rb', line 33

def size
  @size
end

#styleObject (readonly)

Returns the value of attribute style.



33
34
35
# File 'app/components/flowbite/badge/dot.rb', line 33

def style
  @style
end

Class Method Details

.classes(size: :default, style: :brand) ⇒ Object



24
25
26
# File 'app/components/flowbite/badge/dot.rb', line 24

def classes(size: :default, style: :brand)
  CLASSES.fetch(style) + sizes.fetch(size)
end

.sizesObject



28
29
30
# File 'app/components/flowbite/badge/dot.rb', line 28

def sizes
  SIZES
end

Instance Method Details

#callObject



40
41
42
# File 'app/components/flowbite/badge/dot.rb', line 40

def call
  (:span, nil, class: self.class.classes(size: size, style: style))
end