From 0649b44462e869e33c13837999f735c227ba0ffb Mon Sep 17 00:00:00 2001 From: Chris Huynh Date: Tue, 19 Nov 2024 11:44:52 -0600 Subject: [PATCH] further implement tabs, cleanup --- .../app/components/pathogen/tab.html.erb | 5 +- .../pathogen/app/components/pathogen/tab.rb | 124 +++--------------- .../components/pathogen/tabs_panel.html.erb | 20 ++- .../app/components/pathogen/tabs_panel.rb | 26 ++-- .../default.html.erb | 9 +- 5 files changed, 49 insertions(+), 135 deletions(-) diff --git a/embedded_gems/pathogen/app/components/pathogen/tab.html.erb b/embedded_gems/pathogen/app/components/pathogen/tab.html.erb index 2c425224f6..23f492f2b2 100644 --- a/embedded_gems/pathogen/app/components/pathogen/tab.html.erb +++ b/embedded_gems/pathogen/app/components/pathogen/tab.html.erb @@ -1,2 +1,5 @@ -<%= link_to "#", class: 'inline-block p-4 border-b-2 rounded-t-lg', role: "tab", aria: { controls: @controls, selected: @selected } do %>hi <%= @text %> +<%= render Pathogen::BaseComponent.new(**@wrapper_arguments) do %> +<%= render Pathogen::BaseComponent.new(**@system_arguments) do %> +<%= @text %> <% end %> +<% end %> \ No newline at end of file diff --git a/embedded_gems/pathogen/app/components/pathogen/tab.rb b/embedded_gems/pathogen/app/components/pathogen/tab.rb index 9dab6081a1..b306a21d28 100644 --- a/embedded_gems/pathogen/app/components/pathogen/tab.rb +++ b/embedded_gems/pathogen/app/components/pathogen/tab.rb @@ -1,133 +1,41 @@ # frozen_string_literal: true module Pathogen - # This component is part of navigation components such as `Primer::Alpha::TabNav` - # and `Primer::Alpha::UnderlineNav` and should not be used by itself. - # - # @accessibility - # `Tab` renders the selected anchor tab with `aria-current="page"` by default. - # When the selected tab does not correspond to the current page, such as in a nested inner tab, make sure to use aria-current="true" class Tab < Pathogen::Component - # status :alpha + TAG_DEFAULT = :a - DEFAULT_ARIA_CURRENT_FOR_ANCHOR = :page - ARIA_CURRENT_OPTIONS_FOR_ANCHOR = [true, DEFAULT_ARIA_CURRENT_FOR_ANCHOR].freeze - # Panel controlled by the Tab. This will not render anything in the tab itself. - # It will provide a accessor for the Tab's parent to call and render the panel - # content in the appropriate place. - # Refer to `UnderlineNav` and `TabNav` implementations for examples. - # - # @param system_arguments [Hash] <%= link_to_system_arguments_docs %> - # renders_one :panel, lambda { |**system_arguments| - # return unless @with_panel - - # deny_tag_argument(**system_arguments) - # system_arguments[:id] = @panel_id - # system_arguments[:tag] = :div - # system_arguments[:role] ||= :tabpanel - # system_arguments[:tabindex] = 0 - # system_arguments[:hidden] = true unless @selected - - # label_present = aria('label', system_arguments) || aria('labelledby', system_arguments) - # unless label_present - # if @id.present? - # system_arguments[:'aria-labelledby'] = @id - # elsif !Rails.env.production? - # raise ArgumentError, 'Panels must be labelled. Either set a unique `id` on the tab, or set an `aria-label` directly on the panel' - # end - # end - - # Primer::BaseComponent.new(**system_arguments) - # } - - # Icon to be rendered in the Tab left. - # - # @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::Beta::Octicon) %>. - # renders_one :icon, lambda { |icon = nil, **system_arguments| - # system_arguments[:classes] = class_names( - # @icon_classes, - # system_arguments[:classes] - # ) - # Primer::Beta::Octicon.new(icon, **system_arguments) - # } - - # The Tab's text. - # - # @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::Beta::Text) %>. - # renders_one :text, Primer::Beta::Text - - # Counter to be rendered in the Tab right. - # - # @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::Beta::Counter) %>. - # renders_one :counter, Primer::Beta::Counter + WRAPPER_CLASSES = 'inline-flex items-center justify-center mr-2' attr_reader :selected - # @param list [Boolean] Whether the Tab is an item in a `