Class: Primer::OpenProject::InlineMessage
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Primer::OpenProject::InlineMessage
- Defined in:
- app/components/primer/open_project/inline_message.rb
Overview
A simple component to render warning text.
The warning text is rendered in the “attention” Primer color and uses a leading alert Octicon for additional emphasis. This component is designed to be used “inline”, e.g. table cells, and in places where a Banner component might be overkill.
Constant Summary collapse
- SCHEME_OPTIONS =
SCHEME_ICON_MAPPINGS.keys.freeze
- DEFAULT_SIZE =
:medium- SIZE_OPTIONS =
[:small, DEFAULT_SIZE].freeze
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
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Constants included from AttributesHelper
AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Method Summary collapse
-
#initialize(scheme:, size: DEFAULT_SIZE, **system_arguments) ⇒ InlineMessage
constructor
A new instance of InlineMessage.
- #render? ⇒ Boolean
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Methods included from AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
Constructor Details
#initialize(scheme:, size: DEFAULT_SIZE, **system_arguments) ⇒ InlineMessage
Returns a new instance of InlineMessage.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/components/primer/open_project/inline_message.rb', line 36 def initialize(scheme:, size: DEFAULT_SIZE, **system_arguments) # rubocop:disable Lint/MissingSuper resolved_scheme = fetch_or_fallback(SCHEME_OPTIONS, scheme) resolved_size = fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE) @system_arguments = system_arguments @system_arguments[:tag] ||= :div @system_arguments[:classes] = class_names( @system_arguments[:classes], "InlineMessage" ) @system_arguments[:data] = merge_data( @system_arguments, { data: { size: resolved_size, variant: resolved_scheme } } ) @icon_arguments = { classes: "InlineMessageIcon" } if resolved_size == :small @icon_arguments[:icon] = SCHEME_SMALL_ICON_MAPPINGS[resolved_scheme] @icon_arguments[:size] = :xsmall else @icon_arguments[:icon] = SCHEME_ICON_MAPPINGS[resolved_scheme] end end |
Instance Method Details
#render? ⇒ Boolean
60 61 62 |
# File 'app/components/primer/open_project/inline_message.rb', line 60 def render? content.present? end |