Class: Primer::ProgressBarComponent::Item

Inherits:
ViewComponent::Slot
  • Object
show all
Includes:
ClassNameHelper
Defined in:
app/components/primer/progress_bar_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(percentage: 0, bg: :green, **kwargs) ⇒ Item

Returns a new instance of Item.

Parameters:

  • percentage (Integer) (defaults to: 0)

    Percentage completion of item.

  • bg (Symbol) (defaults to: :green)

    Color of item.

  • kwargs (Hash)

    <%= link_to_style_arguments_docs %>



65
66
67
68
69
70
71
72
73
# File 'app/components/primer/progress_bar_component.rb', line 65

def initialize(percentage: 0, bg: :green, **kwargs)
  @percentage = percentage
  @kwargs = kwargs

  @kwargs[:tag] = :span
  @kwargs[:bg] = bg
  @kwargs[:style] = "width: #{@percentage}%;"
  @kwargs[:classes] = class_names("Progress-item", @kwargs[:classes])
end

Instance Attribute Details

#kwargsObject (readonly)

Returns the value of attribute kwargs.



60
61
62
# File 'app/components/primer/progress_bar_component.rb', line 60

def kwargs
  @kwargs
end