Class: Polaris::ActionList::ItemComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/polaris/action_list/item_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(url: nil, icon: nil, icon_name: nil, help_text: nil, active: false, destructive: false, external: false, **system_arguments) ⇒ ItemComponent

Returns a new instance of ItemComponent.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/components/polaris/action_list/item_component.rb', line 5

def initialize(
  url: nil,
  icon: nil,
  icon_name: nil,
  help_text: nil,
  active: false,
  destructive: false,
  external: false,
  **system_arguments
)
  @url = url
  @icon = icon || icon_name
  @help_text = help_text
  @active = active
  @destructive = destructive
  @external = external
  @system_arguments = system_arguments
end

Instance Method Details

#system_argumentsObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/components/polaris/action_list/item_component.rb', line 24

def system_arguments
  @system_arguments.tap do |opts|
    if @url.present?
      opts[:tag] = "a"
      opts[:href] = @url
      opts[:target] = "_blank" if @external
    else
      opts[:tag] = "button"
      opts[:type] = "button"
    end
    opts[:classes] = class_names(
      @system_arguments[:classes],
      "Polaris-ActionList__Item",
      "Polaris-ActionList--active": @active,
      "Polaris-ActionList--destructive": @destructive
    )
  end
end