Class: NitroKit::Avatar

Inherits:
Component
  • Object
show all
Includes:
Phlex::Rails::Helpers::ImageTag
Defined in:
app/components/nitro_kit/avatar.rb

Instance Attribute Summary collapse

Attributes inherited from Component

#attrs

Instance Method Summary collapse

Methods inherited from Component

#builder, from_template

Constructor Details

#initialize(src_arg = nil, src: nil, size: :md, **attrs) ⇒ Avatar

Returns a new instance of Avatar.



7
8
9
10
11
12
13
14
15
# File 'app/components/nitro_kit/avatar.rb', line 7

def initialize(src_arg = nil, src: nil, size: :md, **attrs)
  @src = src_arg || src
  @size = size

  super(
    attrs,
    class: [ container_class, size_classes ]
  )
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



17
18
19
# File 'app/components/nitro_kit/avatar.rb', line 17

def size
  @size
end

#srcObject (readonly)

Returns the value of attribute src.



17
18
19
# File 'app/components/nitro_kit/avatar.rb', line 17

def src
  @src
end

Instance Method Details

#imageObject



25
26
27
# File 'app/components/nitro_kit/avatar.rb', line 25

def image
  image_tag(src, class: image_class)
end

#view_template(&block) ⇒ Object



19
20
21
22
23
# File 'app/components/nitro_kit/avatar.rb', line 19

def view_template(&block)
  div(**attrs) do
    image
  end
end