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

Inherits:
Component
  • Object
show all
Defined in:
app/concepts/matestack/ui/bootstrap/components/avatar.rb

Instance Method Summary collapse

Instance Method Details

#heightObject



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

def height
  size || 40
end

#responseObject



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

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

#widthObject



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

def width
  size || 40
end