Class: Yattho::Alpha::SegmentedControl::Item

Inherits:
BaseComponent show all
Defined in:
app/components/yattho/alpha/segmented_control/item.rb

Overview

SegmentedControl::Item is a private component that is only used by SegmentedControl It wraps the Button and IconButton components to provide the correct styles

Constant Summary

Constants inherited from BaseComponent

BaseComponent::SELF_CLOSING_TAGS

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

Instance Method Summary collapse

Methods inherited from BaseComponent

#call

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

Constructor Details

#initialize(label:, selected: false, icon: nil, hide_labels: false, **system_arguments) ⇒ Item

Returns a new instance of Item.

Parameters:

  • label (String)

    The label to use

  • selected (Boolean) (defaults to: false)

    Whether the item is selected

  • icon (Symbol) (defaults to: nil)

    The icon to use

  • hide_labels (Symbol) (defaults to: false)

    Whether to only show the icon



15
16
17
18
19
20
21
22
23
24
25
# File 'app/components/yattho/alpha/segmented_control/item.rb', line 15

def initialize(label:, selected: false, icon: nil, hide_labels: false, **system_arguments)
  @icon = icon
  @hide_labels = hide_labels
  @label = label
  @selected = selected

  @system_arguments = system_arguments
  @system_arguments[:'data-action'] = "click:segmented-control#select" if system_arguments[:href].nil?
  @system_arguments[:'aria-current'] = selected
  @system_arguments[:scheme] = :invisible
end