Method: Primer::Beta::AvatarStack#initialize

Defined in:
app/components/primer/beta/avatar_stack.rb

#initialize(tag: DEFAULT_TAG, align: ALIGN_DEFAULT, tooltipped: false, body_arguments: {}, **system_arguments) ⇒ AvatarStack

Returns a new instance of AvatarStack.

Parameters:

  • tag (Symbol) (defaults to: DEFAULT_TAG)

    <%= one_of(Primer::Beta::AvatarStack::TAG_OPTIONS) %>

  • align (Symbol) (defaults to: ALIGN_DEFAULT)

    <%= one_of(Primer::Beta::AvatarStack::ALIGN_OPTIONS) %>

  • tooltipped (Boolean) (defaults to: false)

    Whether to add a tooltip to the stack or not.

  • body_arguments (Hash) (defaults to: {})

    Parameters to add to the Body. If ‘tooltipped` is set, has the same arguments as <%= link_to_component(Primer::Tooltip) %>. The default tag is <%= pretty_value(Primer::Beta::AvatarStack::DEFAULT_BODY_TAG) %> but can be changed using `tag:` to <%= one_of(Primer::Beta::AvatarStack::BODY_TAG_OPTIONS, lower: true) %>

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>

[View source]

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/components/primer/beta/avatar_stack.rb', line 29

def initialize(tag: DEFAULT_TAG, align: ALIGN_DEFAULT, tooltipped: false, body_arguments: {}, **system_arguments)
  @align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
  @system_arguments = system_arguments
  @tooltipped = tooltipped
  @body_arguments = body_arguments

  body_tag = @body_arguments[:tag] || DEFAULT_BODY_TAG
  @body_arguments[:tag] = fetch_or_fallback(BODY_TAG_OPTIONS, body_tag, DEFAULT_BODY_TAG)
  @body_arguments[:classes] = class_names(
    "AvatarStack-body",
    @body_arguments[:classes]
  )

  @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
  @system_arguments[:classes] = class_names(
    "AvatarStack",
    system_arguments[:classes],
    "AvatarStack--right" => @align == :right
  )
end