Class: Primer::ButtonMarketingComponent
- Defined in:
- app/components/primer/button_marketing_component.rb
Overview
Use buttons for actions (e.g. in forms). Use links for destinations, or moving from one page to another.
Constant Summary collapse
- DEFAULT_SCHEME =
:default- SCHEME_MAPPINGS =
{ DEFAULT_SCHEME => "", :primary => "btn-primary-mktg", :outline => "btn-outline-mktg", :transparent => "btn-transparent" }.freeze
- SCHEME_OPTIONS =
SCHEME_MAPPINGS.keys
- DEFAULT_VARIANT =
:default- VARIANT_MAPPINGS =
{ DEFAULT_VARIANT => "", :large => "btn-large-mktg" }.freeze
- VARIANT_OPTIONS =
VARIANT_MAPPINGS.keys
- DEFAULT_TAG =
:button- TAG_OPTIONS =
[DEFAULT_TAG, :a].freeze
- DEFAULT_TYPE =
:button- TYPE_OPTIONS =
[DEFAULT_TYPE, :submit].freeze
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, variant: DEFAULT_VARIANT, tag: DEFAULT_TAG, type: DEFAULT_TYPE, **system_arguments) ⇒ ButtonMarketingComponent
constructor
A new instance of ButtonMarketingComponent.
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, tag: DEFAULT_TAG, type: DEFAULT_TYPE, **system_arguments) ⇒ ButtonMarketingComponent
Returns a new instance of ButtonMarketingComponent.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/components/primer/button_marketing_component.rb', line 45 def initialize( scheme: DEFAULT_SCHEME, variant: DEFAULT_VARIANT, tag: DEFAULT_TAG, type: DEFAULT_TYPE, **system_arguments ) @system_arguments = system_arguments @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG) if @system_arguments[:tag] == :a @system_arguments[:role] = :button else @system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE) end @system_arguments[:classes] = class_names( "btn-mktg", SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)], VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)], system_arguments[:classes] ) end |
Instance Method Details
#call ⇒ Object
69 70 71 |
# File 'app/components/primer/button_marketing_component.rb', line 69 def call render(Primer::BaseComponent.new(**@system_arguments)) { content } end |