Class: Primer::Beta::NavList::Group

Inherits:
Alpha::ActionList show all
Defined in:
app/components/primer/beta/nav_list/group.rb

Overview

A logical grouping of navigation links with an optional heading.

See <%= link_to_component(Primer::Beta::NavList) %> for usage examples.

Direct Known Subclasses

Alpha::NavList::Group

Constant Summary

Constants inherited from Alpha::ActionList

Alpha::ActionList::DEFAULT_MENU_ITEM_ROLE, Alpha::ActionList::DEFAULT_ROLE, Alpha::ActionList::DEFAULT_SCHEME, Alpha::ActionList::DEFAULT_SELECT_VARIANT, Alpha::ActionList::MENU_ROLE, Alpha::ActionList::SCHEME_MAPPINGS, Alpha::ActionList::SCHEME_OPTIONS, Alpha::ActionList::SELECT_VARIANT_OPTIONS, Alpha::ActionList::SELECT_VARIANT_ROLE_MAP

Constants inherited from Component

Component::INVALID_ARIA_LABEL_TAGS

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Constants included from AttributesHelper

AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES

Instance Attribute Summary

Attributes inherited from Alpha::ActionList

#id, #role, #select_variant

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Alpha::ActionList

#acts_as_form_input?, #acts_as_menu?, #allows_selection?, #custom_element_name, #multi_select?, #required_form_arguments_given?, #single_select?, #will_add_item, #with_avatar_item, #with_divider, #with_item

Methods inherited from Component

deprecated?, generate_id

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Methods included from AttributesHelper

#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Constructor Details

#initialize(selected_item_id: nil, **system_arguments) ⇒ Group

Returns a new instance of Group.

Parameters:

  • selected_item_id (Symbol) (defaults to: nil)

    The ID of the currently selected item. Used internally.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



57
58
59
60
61
62
# File 'app/components/primer/beta/nav_list/group.rb', line 57

def initialize(selected_item_id: nil, **system_arguments)
  @system_arguments = system_arguments
  @selected_item_id = selected_item_id

  super(**@system_arguments)
end

Class Method Details

.custom_element_nameObject



51
52
53
# File 'app/components/primer/beta/nav_list/group.rb', line 51

def self.custom_element_name
  Primer::Beta::NavList.custom_element_name
end

Instance Method Details

#before_renderObject

Raises:

  • (ArgumentError)


99
100
101
102
103
# File 'app/components/primer/beta/nav_list/group.rb', line 99

def before_render
  super

  raise ArgumentError, "NavList groups are required to have headings" unless heading?
end

#build_avatar_item(component_klass: NavList::Item, **system_arguments) ⇒ Object



87
88
89
90
91
92
93
# File 'app/components/primer/beta/nav_list/group.rb', line 87

def build_avatar_item(component_klass: NavList::Item, **system_arguments)
  super(
    component_klass: component_klass,
    selected_item_id: @selected_item_id,
    **system_arguments
  )
end

#build_item(component_klass: NavList::Item, **system_arguments) ⇒ Object



78
79
80
81
82
83
84
# File 'app/components/primer/beta/nav_list/group.rb', line 78

def build_item(component_klass: NavList::Item, **system_arguments)
  super(
    component_klass: component_klass,
    selected_item_id: @selected_item_id,
    **system_arguments
  )
end

#expand!Object

Cause this group to show its list of sub items when rendered. :nocov:



66
67
68
# File 'app/components/primer/beta/nav_list/group.rb', line 66

def expand!
  @expanded = true
end

#kindObject



95
96
97
# File 'app/components/primer/beta/nav_list/group.rb', line 95

def kind
  :group
end