Class: Primer::OcticonComponent
- Includes:
- OcticonsHelper, ClassNameHelper
- Defined in:
- app/components/primer/octicon_component.rb
Constant Summary collapse
- SIZE_DEFAULT =
:small- SIZE_MAPPINGS =
{ SIZE_DEFAULT => 16, :medium => 32, :large => 64, }.freeze
- SIZE_OPTIONS =
SIZE_MAPPINGS.keys
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(icon:, size: SIZE_DEFAULT, **kwargs) ⇒ OcticonComponent
constructor
A new instance of OcticonComponent.
Methods included from ClassNameHelper
Methods included from FetchOrFallbackHelper
Constructor Details
#initialize(icon:, size: SIZE_DEFAULT, **kwargs) ⇒ OcticonComponent
Returns a new instance of OcticonComponent.
16 17 18 19 20 21 |
# File 'app/components/primer/octicon_component.rb', line 16 def initialize(icon:, size: SIZE_DEFAULT, **kwargs) @icon, @kwargs = icon, kwargs @kwargs[:height] = SIZE_MAPPINGS[size.to_sym] @kwargs[:class] = class_names(@kwargs[:class], Primer::Classify.call(**@kwargs)[:class]) end |
Instance Method Details
#call ⇒ Object
23 24 25 |
# File 'app/components/primer/octicon_component.rb', line 23 def call octicon(@icon, **@kwargs) end |