Class: Polaris::BadgeComponent

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

Constant Summary collapse

PROGRESS_DEFAULT =
:default
PROGRESS_MAPPINGS =
{
  PROGRESS_DEFAULT => "",
  :incomplete => "Polaris-Badge--progressIncomplete",
  :partially_complete => "Polaris-Badge--progressPartiallyComplete",
  :complete => "Polaris-Badge--progressComplete"
}
PROGRESS_OPTIONS =
PROGRESS_MAPPINGS.keys
SIZE_DEFAULT =
:medium
SIZE_MAPPINGS =
{
  SIZE_DEFAULT => "",
  :small => "Polaris-Badge--sizeSmall"
}
SIZE_OPTIONS =
SIZE_MAPPINGS.keys
STATUS_DEFAULT =
:default
STATUS_MAPPINGS =
{
  STATUS_DEFAULT => "",
  :success => "Polaris-Badge--statusSuccess",
  :info => "Polaris-Badge--statusInfo",
  :attention => "Polaris-Badge--statusAttention",
  :critical => "Polaris-Badge--statusCritical",
  :warning => "Polaris-Badge--statusWarning",
  :new => "Polaris-Badge--statusNew"
}
STATUS_OPTIONS =
STATUS_MAPPINGS.keys

Constants included from ViewHelper

ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from ViewHelper

#polaris_body_styles, #polaris_icon_source, #polaris_inversed_colors

Methods included from OptionHelper

#append_option, #prepend_option

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(progress: PROGRESS_DEFAULT, size: SIZE_DEFAULT, status: STATUS_DEFAULT, **system_arguments) ⇒ BadgeComponent

Returns a new instance of BadgeComponent.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/components/polaris/badge_component.rb', line 33

def initialize(
  progress: PROGRESS_DEFAULT,
  size: SIZE_DEFAULT,
  status: STATUS_DEFAULT,
  **system_arguments
)
  @progress = progress

  @system_arguments = system_arguments
  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    "Polaris-Badge",
    PROGRESS_MAPPINGS[fetch_or_fallback(PROGRESS_OPTIONS, progress, PROGRESS_DEFAULT)],
    SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)],
    STATUS_MAPPINGS[fetch_or_fallback(STATUS_OPTIONS, status, STATUS_DEFAULT)]
  )
end