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 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(scheme: DEFAULT_SCHEME, icon:, **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(scheme: DEFAULT_SCHEME, icon:, **system_arguments) ⇒ IconButton
Returns a new instance of IconButton.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/components/primer/icon_button.rb', line 29 def initialize(scheme: DEFAULT_SCHEME, icon:, **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] ) raise ArgumentError, "`aria-label` is required." if @system_arguments[:"aria-label"].nil? && !Rails.env.production? end |
Instance Method Details
#call ⇒ Object
42 43 44 45 46 |
# File 'app/components/primer/icon_button.rb', line 42 def call render(Primer::BaseButton.new(**@system_arguments)) do render(Primer::OcticonComponent.new(icon: @icon)) end end |