Sha256: c7deaf8481a1011d2a4b2c8f01fc1ebdc6990b2716d9df7a298b77230adf3921

Contents?: true

Size: 1.08 KB

Versions: 33

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Primer
  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 < Primer::BaseComponent
        status :alpha
        audited_at "2023-02-01"

        # @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

33 entries across 33 versions & 2 rubygems

Version Path
primer_view_components-0.1.9 app/components/primer/alpha/segmented_control/item.rb
primer_view_components-0.1.8 app/components/primer/alpha/segmented_control/item.rb
primer_view_components-0.1.7 app/components/primer/alpha/segmented_control/item.rb
primer_view_components-0.1.6 app/components/primer/alpha/segmented_control/item.rb
primer_view_components-0.1.5 app/components/primer/alpha/segmented_control/item.rb
primer_view_components-0.1.4 app/components/primer/alpha/segmented_control/item.rb
primer_view_components-0.1.3 app/components/primer/alpha/segmented_control/item.rb
primer_view_components-0.1.2 app/components/primer/alpha/segmented_control/item.rb
primer_view_components-0.1.1 app/components/primer/alpha/segmented_control/item.rb
primer_view_components-0.1.0 app/components/primer/alpha/segmented_control/item.rb
primer_view_components-0.0.123 app/components/primer/alpha/segmented_control/item.rb
primer_view_components-0.0.122 app/components/primer/alpha/segmented_control/item.rb
primer_view_components-0.0.121 app/components/primer/alpha/segmented_control/item.rb