Sha256: 4c2ebed3bbf34420f66c706615c92db3660f1c902170b368beee9779d6042d09

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Yattho
  module Alpha
    class SegmentedControl
      # SegmentedControl::Item is a private component that is only used by SegmentedControl
      # It wraps the Button and IconButton components to provide the correct styles
      class Item < Yattho::BaseComponent
        status :alpha

        # @param label [String] The label to use
        # @param selected [Boolean] Whether the item is selected
        # @param icon [Symbol] The icon to use
        # @param hide_labels [Symbol] Whether to only show the icon
        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
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yattho_view_components-0.1.1 app/components/yattho/alpha/segmented_control/item.rb
yattho_view_components-0.0.1 app/components/yattho/alpha/segmented_control/item.rb