Method: Primer::Alpha::ActionList#build_avatar_item
- Defined in:
- app/components/primer/alpha/action_list.rb
permalink #build_avatar_item(src:, username:, full_name: nil, full_name_scheme: Primer::Alpha::ActionList::Item::DEFAULT_DESCRIPTION_SCHEME, component_klass: ActionList::Item, avatar_arguments: {}, **system_arguments) ⇒ Object
Builds a new avatar item but does not add it to the list. Avatar items are a convenient way to accessibly add an item with a leading avatar image. Use this method instead of the ‘#with_avatar_item` slot if you need to render an avatar item outside the context of a list, eg. if rendering additional items to append to an existing list, perhaps via a separate HTTP request.
217 218 219 220 221 222 223 224 225 226 |
# File 'app/components/primer/alpha/action_list.rb', line 217 def build_avatar_item(src:, username:, full_name: nil, full_name_scheme: Primer::Alpha::ActionList::Item::DEFAULT_DESCRIPTION_SCHEME, component_klass: ActionList::Item, avatar_arguments: {}, **system_arguments) build_item(label: username, description_scheme: full_name_scheme, component_klass: component_klass, **system_arguments).tap do |item| item.with_leading_visual_raw_content do # no alt text necessary for presentational item item.render(Primer::Beta::Avatar.new(src: src, **avatar_arguments, role: :presentation, size: 16)) end item.with_description_content(full_name) if full_name end end |