Class: Primer::OcticonComponent
- Defined in:
- app/components/primer/octicon_component.rb
Overview
Renders an [Octicon](primer.style/octicons/) with <%= link_to_system_arguments_docs %>.
Constant Summary collapse
- SIZE_DEFAULT =
:small- SIZE_MAPPINGS =
{ SIZE_DEFAULT => 16, :medium => 32, :large => 64 }.freeze
- SIZE_OPTIONS =
SIZE_MAPPINGS.keys
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(icon_name = nil, icon: nil, size: SIZE_DEFAULT, **system_arguments) ⇒ OcticonComponent
constructor
A new instance of OcticonComponent.
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
Constructor Details
#initialize(icon_name = nil, icon: nil, size: SIZE_DEFAULT, **system_arguments) ⇒ OcticonComponent
Returns a new instance of OcticonComponent.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/components/primer/octicon_component.rb', line 29 def initialize(icon_name = nil, icon: nil, size: SIZE_DEFAULT, **system_arguments) @icon = icon_name || icon @system_arguments = system_arguments @system_arguments[:class] = Primer::Classify.call(**@system_arguments)[:class] @system_arguments[:height] ||= SIZE_MAPPINGS[size] # Filter out classify options to prevent them from becoming invalid html attributes. # Note height and width are both classify options and valid html attributes. = @system_arguments.slice(:height, :width) @system_arguments = add_test_selector(@system_arguments).except(*Primer::Classify::VALID_KEYS, :classes).merge() end |
Instance Method Details
#call ⇒ Object
42 43 44 |
# File 'app/components/primer/octicon_component.rb', line 42 def call octicon(@icon, { **@system_arguments }) end |