Class: Primer::OcticonComponent
- Includes:
- OcticonsHelper, ClassNameHelper
- 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 inherited from Component
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(icon:, size: SIZE_DEFAULT, **system_arguments) ⇒ OcticonComponent
constructor
A new instance of OcticonComponent.
Methods included from ClassNameHelper
Methods included from ViewHelper
Methods included from JoinStyleArgumentsHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean
Constructor Details
#initialize(icon:, size: SIZE_DEFAULT, **system_arguments) ⇒ OcticonComponent
Returns a new instance of OcticonComponent.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/components/primer/octicon_component.rb', line 31 def initialize(icon:, size: SIZE_DEFAULT, **system_arguments) @icon = 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 = @system_arguments.except(*Primer::Classify::VALID_KEYS, :classes).merge() end |
Class Method Details
.status ⇒ Object
48 49 50 |
# File 'app/components/primer/octicon_component.rb', line 48 def self.status Primer::Component::STATUSES[:beta] end |
Instance Method Details
#call ⇒ Object
44 45 46 |
# File 'app/components/primer/octicon_component.rb', line 44 def call octicon(@icon, { **@system_arguments }) end |