Class: Flowbite::Avatar::PlaceholderIcon

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

Overview

Renders the person icon shown in an avatar without an image or initials.

Constant Summary collapse

SIZES =

The icon is slightly larger than the avatar and offset to the left, so the person is centered and cropped by the container.

{
  xs: ["w-5.5", "h-5.5", "-left-0.5"],
  sm: ["w-7", "h-7", "-left-0.5"],
  base: ["w-10", "h-10", "-left-1"],
  default: ["w-12", "h-12", "-left-1"],
  lg: ["w-13", "h-13", "-left-1"],
  xl: ["w-17", "h-17", "-left-1.5"],
  "2xl": ["w-19", "h-19", "-left-1.5"]
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size: :default) ⇒ PlaceholderIcon

Returns a new instance of PlaceholderIcon.

Parameters:

  • size (Symbol) (defaults to: :default) —

    The size of the avatar the icon is placed in.



35
36
37
# File 'app/components/flowbite/avatar/placeholder_icon.rb', line 35

def initialize(size: :default)
  @size = size
end

Instance Attribute Details

#size ⇒ Object (readonly)

Returns the value of attribute size.



32
33
34
# File 'app/components/flowbite/avatar/placeholder_icon.rb', line 32

def size
  @size
end

Class Method Details

.classes(size: :default) ⇒ Object



23
24
25
# File 'app/components/flowbite/avatar/placeholder_icon.rb', line 23

def classes(size: :default)
  ["absolute"] + sizes.fetch(size) + ["text-body-subtle"]
end

.sizes ⇒ Object



27
28
29
# File 'app/components/flowbite/avatar/placeholder_icon.rb', line 27

def sizes
  SIZES
end

Instance Method Details

#classes ⇒ Object



39
40
41
# File 'app/components/flowbite/avatar/placeholder_icon.rb', line 39

def classes
  self.class.classes(size: size)
end