Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
strackoverflow committed May 22, 2023
1 parent 77a2d74 commit 8193ef0
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions app/components/primer/beta/icon_button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,25 @@ def initialize(icon:, scheme: DEFAULT_SCHEME, wrapper_arguments: {}, show_toolti
@aria_label = aria("label", @system_arguments)
@aria_description = aria("description", @system_arguments)

return unless @show_tooltip

@tooltip_arguments = {
for_id: @system_arguments[:id],
direction: tooltip_direction
}

if @show_tooltip
# If we have both an `aria-label` and a `aria-description`, we create a `Tooltip` with the description type and keep the `aria-label` in the button.
# Otherwise, the `aria-label` is used as the tooltip text, which is the `aria-labelled-by` of the button, so we don't set it in the button.
if @aria_label.present? && @aria_description.present?
@system_arguments.delete(:"aria-description")
@system_arguments[:aria].delete(:description) if @system_arguments.include?(:aria)
@tooltip_arguments[:text] = @aria_description
@tooltip_arguments[:type] = :description
else
@system_arguments.delete(:"aria-label")
@system_arguments[:aria].delete(:label) if @system_arguments.include?(:aria)
@tooltip_arguments[:text] = @aria_label
@tooltip_arguments[:type] = :label
end
# If we have both an `aria-label` and a `aria-description`, we create a `Tooltip` with the description type and keep the `aria-label` in the button.
# Otherwise, the `aria-label` is used as the tooltip text, which is the `aria-labelled-by` of the button, so we don't set it in the button.
if @aria_label.present? && @aria_description.present?
@system_arguments.delete(:"aria-description")
@system_arguments[:aria].delete(:description) if @system_arguments.include?(:aria)
@tooltip_arguments[:text] = @aria_description
@tooltip_arguments[:type] = :description
else
@system_arguments.delete(:"aria-label")
@system_arguments[:aria].delete(:label) if @system_arguments.include?(:aria)
@tooltip_arguments[:text] = @aria_label
@tooltip_arguments[:type] = :label
end
end

Expand Down

0 comments on commit 8193ef0

Please sign in to comment.