Class: Primer::ButtonComponent
- Defined in:
- app/components/primer/button_component.rb
Overview
Use ‘Button` for actions (e.g. in forms). Use links for destinations, or moving from one page to another.
Constant Summary collapse
- DEFAULT_SCHEME =
:default- LINK_SCHEME =
:link- SCHEME_MAPPINGS =
{ DEFAULT_SCHEME => "", :primary => "btn-primary", :danger => "btn-danger", :outline => "btn-outline", :invisible => "btn-invisible", LINK_SCHEME => "btn-link" }.freeze
- SCHEME_OPTIONS =
SCHEME_MAPPINGS.keys
- DEFAULT_VARIANT =
:medium- VARIANT_MAPPINGS =
{ :small => "btn-sm", DEFAULT_VARIANT => "", :large => "btn-large" }.freeze
- VARIANT_OPTIONS =
VARIANT_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
-
#initialize(scheme: DEFAULT_SCHEME, variant: DEFAULT_VARIANT, group_item: false, block: false, caret: false, **system_arguments) ⇒ ButtonComponent
constructor
A new instance of ButtonComponent.
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, variant: DEFAULT_VARIANT, group_item: false, block: false, caret: false, **system_arguments) ⇒ ButtonComponent
Returns a new instance of ButtonComponent.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'app/components/primer/button_component.rb', line 86 def initialize( scheme: DEFAULT_SCHEME, variant: DEFAULT_VARIANT, group_item: false, block: false, caret: false, **system_arguments ) @scheme = scheme @caret = caret @system_arguments = system_arguments @system_arguments[:classes] = class_names( system_arguments[:classes], SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)], VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)], "btn" => !link?, "btn-block" => block, "BtnGroup-item" => group_item ) end |