Class: Primer::ProgressBarComponent

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

Defined Under Namespace

Classes: Item

Constant Summary collapse

SIZE_DEFAULT =
:default
SIZE_MAPPINGS =
{
  SIZE_DEFAULT => "",
  :small => "Progress--small",
  :large => "Progress--large",
}.freeze
SIZE_OPTIONS =
SIZE_MAPPINGS.keys

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from FetchOrFallbackHelper

#fetch_or_fallback

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(size: SIZE_DEFAULT, percentage: 0, **kwargs) ⇒ ProgressBarComponent

Returns a new instance of ProgressBarComponent.



36
37
38
39
40
41
42
43
44
45
# File 'app/components/primer/progress_bar_component.rb', line 36

def initialize(size: SIZE_DEFAULT, percentage: 0, **kwargs)
  @kwargs = kwargs
  @kwargs[:classes] = class_names(
    @kwargs[:classes],
    "Progress",
    SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]
  )
  @kwargs[:tag] = :span

end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/components/primer/progress_bar_component.rb', line 47

def render?
  items.any?
end