Class: Polaris::Tabs::TabComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/polaris/tabs/tab_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(title:, url: nil, active: false, **system_arguments) ⇒ TabComponent

Returns a new instance of TabComponent.



4
5
6
7
8
9
10
11
12
13
14
# File 'app/components/polaris/tabs/tab_component.rb', line 4

def initialize(
  title:,
  url: nil,
  active: false,
  **system_arguments
)
  @title = title
  @url = url
  @active = active
  @system_arguments = system_arguments
end

Instance Method Details

#system_argumentsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/components/polaris/tabs/tab_component.rb', line 16

def system_arguments
  @system_arguments.tap do |opts|
    opts[:rol] = "tab"
    opts[:tabindex] = "0"
    if @url.present?
      opts[:tag] = "a"
      opts[:href] = @url
    else
      opts[:tag] = "button"
      opts[:type] = "button"
    end
    opts[:classes] = class_names(
      @system_arguments[:classes],
      "Polaris-LegacyTabs__Tab",
      "Polaris-LegacyTabs__Tab--selected": @active
    )
  end
end