Method: Primer::Alpha::Dialog::Header#initialize

Defined in:
app/components/primer/alpha/dialog/header.rb

#initialize(id:, title:, subtitle: nil, show_divider: false, visually_hide_title: false, variant: DEFAULT_VARIANT, **system_arguments) ⇒ Header

Returns a new instance of Header.

Parameters:

  • id (String)

    The HTML element’s ID value.

  • title (String)

    Describes the content of the dialog.

  • subtitle (String) (defaults to: nil)

    Provides additional context for the dialog, also setting the ‘aria-describedby` attribute.

  • show_divider (Boolean) (defaults to: false)

    Show a divider between the header and body.

  • visually_hide_title (Boolean) (defaults to: false)

    Visually hide the ‘title` while maintaining a label for assistive technologies.

  • variant (Symbol) (defaults to: DEFAULT_VARIANT)

    <%= one_of(Primer::Alpha::Dialog::Header::VARIANT_OPTIONS) %>

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>

[View source]

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/components/primer/alpha/dialog/header.rb', line 52

def initialize(
  id:,
  title:,
  subtitle: nil,
  show_divider: false,
  visually_hide_title: false,
  variant: DEFAULT_VARIANT,
  **system_arguments
)
  @id = id
  @title = title
  @subtitle = subtitle
  @visually_hide_title = visually_hide_title
  @system_arguments = deny_tag_argument(**system_arguments)
  @system_arguments[:tag] = :div

  @system_arguments[:classes] = class_names(
    "Overlay-header",
    VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)],
    { "Overlay-header--divided": show_divider },
    system_arguments[:classes]
  )
end