Class: Primer::IconButton
- Defined in:
- app/components/primer/icon_button.rb
Overview
Use ‘IconButton` to render Icon-only buttons without the default button styles.
Constant Summary collapse
- DEFAULT_SCHEME =
:default- SCHEME_MAPPINGS =
{ DEFAULT_SCHEME => "", :danger => "btn-octicon-danger" }.freeze
- SCHEME_OPTIONS =
SCHEME_MAPPINGS.keys
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
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(icon:, scheme: DEFAULT_SCHEME, box: false, **system_arguments) ⇒ IconButton
constructor
A new instance of IconButton.
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:, scheme: DEFAULT_SCHEME, box: false, **system_arguments) ⇒ IconButton
Returns a new instance of IconButton.
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/components/primer/icon_button.rb', line 45 def initialize(icon:, scheme: DEFAULT_SCHEME, box: false, **system_arguments) @icon = icon @system_arguments = system_arguments @system_arguments[:classes] = class_names( "btn-octicon", SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)], system_arguments[:classes], "Box-btn-octicon" => box ) validate_aria_label end |
Instance Method Details
#call ⇒ Object
59 60 61 62 63 |
# File 'app/components/primer/icon_button.rb', line 59 def call render(Primer::BaseButton.new(**@system_arguments)) do render(Primer::OcticonComponent.new(icon: @icon)) end end |