Method: Primer::Alpha::SegmentedControl#initialize

Defined in:
app/components/primer/alpha/segmented_control.rb

#initialize(hide_labels: HIDE_LABELS_DEFAULT, full_width: FULL_WIDTH_DEFAULT, size: Primer::Beta::Button::DEFAULT_SIZE, **system_arguments) ⇒ SegmentedControl

Returns a new instance of SegmentedControl.

Parameters:

  • hide_labels (Boolean) (defaults to: HIDE_LABELS_DEFAULT)

    Whether to hide the labels and only show the icons

  • full_width (Boolean) (defaults to: FULL_WIDTH_DEFAULT)

    If the component should be full width

  • size (Symbol) (defaults to: Primer::Beta::Button::DEFAULT_SIZE)

    <%= one_of(Primer::Beta::Button::SIZE_OPTIONS) %>

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>

[View source]

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/components/primer/alpha/segmented_control.rb', line 43

def initialize(hide_labels: HIDE_LABELS_DEFAULT, full_width: FULL_WIDTH_DEFAULT, size: Primer::Beta::Button::DEFAULT_SIZE, **system_arguments)
  @full_width = full_width
  @size = size
  @hide_labels = hide_labels

  @system_arguments = system_arguments
  @system_arguments[:tag] = :ul
  @system_arguments[:role] = "list"
  @system_arguments[:classes] = class_names(
    system_arguments[:classes],
    SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)],
    "SegmentedControl",
    "SegmentedControl--iconOnly": hide_labels,
    "SegmentedControl--fullWidth": full_width
  )

  validate_aria_label
end