Class: Matestack::Ui::Bootstrap::Components::Avatar

Inherits:
BaseComponent
  • Object
show all
Defined in:
lib/matestack/ui/bootstrap/components/avatar.rb

Instance Method Summary collapse

Instance Method Details

#heightObject



19
20
21
# File 'lib/matestack/ui/bootstrap/components/avatar.rb', line 19

def height
  context.size || 40
end

#responseObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/matestack/ui/bootstrap/components/avatar.rb', line 5

def response
  if context.text.present? && context.img_path.nil?
    div class: "rounded-circle bg-#{context.bg_variant || 'primary'} text-#{context.text_variant || 'white'} text-center p-2 #{context.bs_class}",
      style: "height: #{height}px; width: #{width}px; display: inline-block;" do
      plain context.text
    end
  else
    div class: "rounded-circle text-#{context.text_variant || 'white'} text-center p-2 #{context.bs_class}",
      style: "height: #{height}px; width: #{width}px; display: inline-block; background-image: url(#{context.img_path}); background-size: contain;" do
      plain context.text
    end
  end
end

#widthObject



23
24
25
# File 'lib/matestack/ui/bootstrap/components/avatar.rb', line 23

def width
  context.size || 40
end