Sha256: f47abcce88bfd0494c90824cb6bc6d642c41f33590f8255c73ca2d8d9ff7953c

Contents?: true

Size: 1.56 KB

Versions: 66

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

module Ariadne
  # Tab component to be used with bottom_tab_nav

  # Accessibility considerations:
  # aria-controls="tabpanelID": Use this if content is being conditionally controlled. Reference the ID of the content being controlled
  class BottomTabComponent < Ariadne::Component
    DEFAULT_TAG = :a
    TAG_OPTIONS = [DEFAULT_TAG].freeze

    DEFAULT_CLASSES = "ariadne-w-full ariadne-py-4 ariadne-flex ariadne-flex-col ariadne-justify-center ariadne-items-center ariadne-cursor-pointer [&>span]:ariadne-p-0 ariadne-border-y-2 ariadne-border-r-2 first:ariadne-border-l-2 ariadne-border-solid ariadne-border-black"
    TAB_BACKGROUND_COLOR_CLASSES = "aria-selected:ariadne-bg-gray-200"

    DEFAULT_ATTRIBUTES = {
      "data-action": "click->options#select",
      "data-options-target": "option",
      role: "tab",
      tabindex: "0",
    }

    renders_one :icon, Ariadne::HeroiconComponent

    # @example Default
    #
    #   <%= render(Ariadne::BottomTabComponent.new) { "Example" } %>
    #
    # @param tag [Symbol, String] The rendered tag name.
    # @param classes [String] <%= link_to_classes_docs %>
    # @param attributes [Hash] <%= link_to_attributes_docs %>
    def initialize(tag: DEFAULT_TAG, classes: "", active: false, attributes: {})
      @tag = check_incoming_tag(DEFAULT_TAG, tag)
      @classes = merge_class_names(
        DEFAULT_CLASSES,
        TAB_BACKGROUND_COLOR_CLASSES,
        classes,
      )

      @attributes = DEFAULT_ATTRIBUTES
        .merge({ "aria-selected": active })
        .merge(attributes)
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.59-x64-mingw-ucrt app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.59-aarch64-linux app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.59-x86_64-darwin app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.59-x86_64-linux app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.59-arm64-darwin app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.59 app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.58-x86_64-darwin app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.58-aarch64-linux app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.58-arm64-darwin app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.58-x64-mingw-ucrt app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.58 app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.58-x86_64-linux app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.57-arm64-darwin app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.57-aarch64-linux app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.57-x86_64-darwin app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.57-x86_64-linux app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.57-x64-mingw-ucrt app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.57 app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.55-x86_64-linux app/components/ariadne/bottom_tab_component.rb
ariadne_view_components-0.0.55-arm64-darwin app/components/ariadne/bottom_tab_component.rb