Class: Ariadne::FlashComponent
- Includes:
- IconHelper
- Defined in:
- app/components/ariadne/flash_component.rb
Overview
Use ‘FlashComponent` to inform users of successful messages, pending actions, or urgent notices.
Constant Summary collapse
- DEFAULT_SCHEME =
:default- DISMISSIBLE_SCHEME_CLASS_MAPPINGS =
{ default: "text-blue-500 bg-blue-50 hover:bg-blue-100 focus:ring-offset-blue-50 focus:ring-blue-600", info: "text-blue-500 bg-blue-50 hover:bg-blue-100 focus:ring-offset-blue-50 focus:ring-blue-600", success: "text-green-500 bg-green-50 hover:bg-green-100 focus:ring-offset-green-50 focus:ring-green-600", warning: "text-yellow-500 bg-yellow-50 hover:bg-yellow-100 focus:ring-offset-yellow-50 focus:ring-yellow-600", danger: "text-red-500 bg-red-50 hover:bg-red-100 focus:ring-offset-red-50 focus:ring-red-600", }.freeze
- VALID_DISMISSIBLE_SCHEMES =
DISMISSIBLE_SCHEME_CLASS_MAPPINGS.keys.freeze
- BG_SCHEME_CLASS_MAPPINGS =
{ default: "bg-blue-50", info: "bg-blue-50", success: "bg-green-50", warning: "bg-yellow-50", danger: "bg-red-50", }.freeze
- VALID_BG_SCHEMES =
BG_SCHEME_CLASS_MAPPINGS.keys.freeze
- CONTENT_SCHEME_CLASS_MAPPINGS =
{ default: "text-blue-700", info: "text-blue-700", success: "text-green-700", warning: "text-yellow-700", danger: "text-red-700", }.freeze
- VALID_CONTENT_SCHEMES =
CONTENT_SCHEME_CLASS_MAPPINGS.keys.freeze
Constants included from FetchOrFallbackHelper
Ariadne::FetchOrFallbackHelper::InvalidValueError, Ariadne::FetchOrFallbackHelper::TRUE_OR_FALSE
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Instance Method Summary collapse
-
#initialize(tag: :div, dismissible: false, scheme: DEFAULT_SCHEME, classes: "", attributes: {}) ⇒ FlashComponent
constructor
A new instance of FlashComponent.
Methods included from IconHelper
#check_icon_presence!, #has_partial_icon?, #icon_presence!, #variant_presence!
Methods included from FetchOrFallbackHelper
#check_incoming_attribute, #check_incoming_tag, #check_incoming_value, #fetch_or_raise, #fetch_or_raise_boolean
Methods included from LoggerHelper
#logger, #silence_deprecations?, #silence_warnings?
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from ClassNameHelper
Constructor Details
#initialize(tag: :div, dismissible: false, scheme: DEFAULT_SCHEME, classes: "", attributes: {}) ⇒ FlashComponent
Returns a new instance of FlashComponent.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'app/components/ariadne/flash_component.rb', line 98 def initialize(tag: :div, dismissible: false, scheme: DEFAULT_SCHEME, classes: "", attributes: {}) @dismissible = dismissible @tag = check_incoming_tag(:div, tag) @scheme = fetch_or_raise(VALID_CONTENT_SCHEMES, scheme) @classes = class_names( CONTENT_SCHEME_CLASS_MAPPINGS[@scheme], classes ) @attributes = attributes end |