Class: Primer::AvatarComponent
- Defined in:
- app/components/primer/avatar_component.rb
Overview
Avatars are images used to represent users and organizations on GitHub. Use the default round avatar for users, and the ‘square` argument for organizations or any other non-human avatars.
Constant Summary collapse
- SMALL_THRESHOLD =
24
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(src:, alt:, size: 20, square: false, **system_arguments) ⇒ AvatarComponent
constructor
A new instance of AvatarComponent.
Methods included from FetchOrFallbackHelper
Methods included from ClassNameHelper
Constructor Details
#initialize(src:, alt:, size: 20, square: false, **system_arguments) ⇒ AvatarComponent
Returns a new instance of AvatarComponent.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/components/primer/avatar_component.rb', line 18 def initialize(src:, alt:, size: 20, square: false, **system_arguments) @system_arguments = system_arguments @system_arguments[:tag] = :img @system_arguments[:src] = src @system_arguments[:alt] = alt @system_arguments[:size] = size @system_arguments[:height] = size @system_arguments[:width] = size @system_arguments[:classes] = class_names( "avatar", system_arguments[:classes], "avatar--small" => size < SMALL_THRESHOLD, "CircleBadge" => !square ) end |
Instance Method Details
#call ⇒ Object
35 36 37 |
# File 'app/components/primer/avatar_component.rb', line 35 def call render(Primer::BaseComponent.new(**@system_arguments)) { content } end |