Class: Polaris::BannerComponent
- Defined in:
- app/components/polaris/banner_component.rb
Defined Under Namespace
Classes: SecondaryAction
Constant Summary collapse
- STATUS_DEFAULT =
:default- STATUS_MAPPINGS =
{ STATUS_DEFAULT => "", :success => "Polaris-Banner--statusSuccess", :info => "Polaris-Banner--statusInfo", :warning => "Polaris-Banner--statusWarning", :critical => "Polaris-Banner--statusCritical" }
- STATUS_OPTIONS =
STATUS_MAPPINGS.keys
- WITHIN_DEFAULT =
:page- WITHIN_MAPPINGS =
{ page: "Polaris-Banner--withinPage", container: "Polaris-Banner--withinContentContainer" }
- WITHIN_OPTIONS =
WITHIN_MAPPINGS.keys
- ICON_COLOR_MAPPINGS =
{ default: :base, success: :success, info: :highlight, warning: :warning, critical: :critical }
Constants included from ViewHelper
ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
- #default_icon(status) ⇒ Object
-
#initialize(status: STATUS_DEFAULT, within: WITHIN_DEFAULT, icon: nil, title: nil, **system_arguments) ⇒ BannerComponent
constructor
A new instance of BannerComponent.
- #render_icon ⇒ Object
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
Constructor Details
#initialize(status: STATUS_DEFAULT, within: WITHIN_DEFAULT, icon: nil, title: nil, **system_arguments) ⇒ BannerComponent
Returns a new instance of BannerComponent.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/components/polaris/banner_component.rb', line 40 def initialize( status: STATUS_DEFAULT, within: WITHIN_DEFAULT, icon: nil, title: nil, **system_arguments ) @status = status @icon = icon || default_icon(status) @title = title @system_arguments = system_arguments @system_arguments[:tabindex] = 0 @system_arguments[:role] = "status" @system_arguments[:classes] = class_names( @system_arguments[:classes], "Polaris-Banner", STATUS_MAPPINGS[fetch_or_fallback(STATUS_OPTIONS, status, STATUS_DEFAULT)], WITHIN_MAPPINGS[fetch_or_fallback(WITHIN_OPTIONS, within, WITHIN_DEFAULT)] ) end |
Instance Method Details
#default_icon(status) ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'app/components/polaris/banner_component.rb', line 66 def default_icon(status) case status when :success then "CircleTickMajor" when :critical then "DiamondAlertMajor" else "CircleInformationMajor" end end |
#render_icon ⇒ Object
62 63 64 |
# File 'app/components/polaris/banner_component.rb', line 62 def render_icon polaris_icon(name: @icon, color: ICON_COLOR_MAPPINGS[@status]) end |