Sha256: d0c2dbd3a17f943554629bb53f1473061948b2b4cbae349445efdaf88cd83ca8

Contents?: true

Size: 1.61 KB

Versions: 24

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

module Ariadne
  # A container for a row of tags.
  # @accessibility This component requires you to pass in a `sr_label`
  # attribute, which will be used to label the tabs for screen readers.
  class TabBarComponent < Ariadne::Component
    DEFAULT_TAG = :nav
    TAG_OPTIONS = [DEFAULT_TAG].freeze

    DEFAULT_CLASSES = "ariadne--mb-px ariadne-flex ariadne-space-x-8 ariadne-bg-transparent"

    # Tabs to be rendered. For more information, refer to <%= link_to_component(Ariadne::TabComponent) %>.
    #
    # @param selected [Boolean] Whether the tab is selected.
    # @param classes [String] <%= link_to_classes_docs %>
    # @param attributes [Hash] <%= link_to_attributes_docs %>
    renders_many :tabs, lambda { |selected: false, classes: "", attributes: {}|
      Ariadne::TabComponent.new(
        selected: selected,
        classes: classes,
        attributes: attributes
      )
    }

    # @example Default
    #
    #   <%= render(Ariadne::TabBarComponent.new(sr_label: "Navigation tabs")) { "Example" } %>
    #
    # @param tag [Symbol, String] The rendered tag name.
    # @param sr_label [String] A label to introduce these tabs for screen readers.
    # @param classes [String] <%= link_to_classes_docs %>
    # @param attributes [Hash] <%= link_to_attributes_docs %>
    def initialize(tag: DEFAULT_TAG, sr_label:, classes: "", attributes: {})
      @tag = check_incoming_tag(DEFAULT_TAG, tag)
      @classes = class_names(
        DEFAULT_CLASSES,
        classes
      )
      @sr_label = sr_label
      @attributes = attributes
      @attributes[:"aria-label"] ||= "Tabs"
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.12 app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.12-x86_64-linux app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.12-x86_64-darwin app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.12-x64-mingw32 app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.12-x64-mingw-ucrt app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.12-arm64-darwin app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.12-aarch64-linux app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.11 app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.11-x86_64-linux app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.11-x86_64-darwin app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.11-x64-mingw32 app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.11-x64-mingw-ucrt app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.11-arm64-darwin app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.11-aarch64-linux app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.10 app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.10-x86_64-linux app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.10-x86_64-darwin app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.10-x64-mingw32 app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.10-x64-mingw-ucrt app/components/ariadne/tab_bar_component.rb
ariadne_view_components-0.0.10-arm64-darwin app/components/ariadne/tab_bar_component.rb