Class: Polaris::BadgeComponent
- 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_PIP_MAPPINGS =
{ PROGRESS_DEFAULT => "", :incomplete => "Polaris-Badge-Pip--progressIncomplete", :partially_complete => "Polaris-Badge-Pip--progressPartiallyComplete", :complete => "Polaris-Badge-Pip--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_PIP_MAPPINGS =
{ STATUS_DEFAULT => "", :success => "Polaris-Badge-Pip--statusSuccess", :info => "Polaris-Badge-Pip--statusInfo", :attention => "Polaris-Badge-Pip--statusAttention", :critical => "Polaris-Badge-Pip--statusCritical", :warning => "Polaris-Badge-Pip--statusWarning", :new => "Polaris-Badge-Pip--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
- #badge_pip_arguments ⇒ Object
-
#initialize(progress: PROGRESS_DEFAULT, size: SIZE_DEFAULT, status: STATUS_DEFAULT, **system_arguments) ⇒ BadgeComponent
constructor
A new instance of BadgeComponent.
Methods included from ViewHelper
#polaris_body_styles, #polaris_html_classes, #polaris_html_styles, #polaris_icon_source
Methods included from StylesListHelper
Methods included from OptionHelper
#append_option, #prepend_option
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #fetch_or_fallback_nested
Methods included from ClassNameHelper
Constructor Details
#initialize(progress: PROGRESS_DEFAULT, size: SIZE_DEFAULT, status: STATUS_DEFAULT, **system_arguments) ⇒ BadgeComponent
Returns a new instance of BadgeComponent.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/components/polaris/badge_component.rb', line 48 def initialize( progress: PROGRESS_DEFAULT, size: SIZE_DEFAULT, status: STATUS_DEFAULT, **system_arguments ) @progress = progress @status = status @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 |
Instance Method Details
#badge_pip_arguments ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'app/components/polaris/badge_component.rb', line 67 def badge_pip_arguments {tag: "span"}.tap do |args| args[:classes] = class_names( "Polaris-Badge-Pip", PROGRESS_PIP_MAPPINGS[fetch_or_fallback(PROGRESS_OPTIONS, @progress, PROGRESS_DEFAULT)], STATUS_PIP_MAPPINGS[fetch_or_fallback(STATUS_OPTIONS, @status, STATUS_DEFAULT)] ) end end |