Class: Primer::Alpha::ButtonMarketing

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/alpha/button_marketing.rb

Overview

Use ‘ButtonMarketing` 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-signup-mktg",
  :outline => "btn-muted-mktg",
  :transparent => "btn-subtle-mktg"
}.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 inherited from Component

Component::INVALID_ARIA_LABEL_TAGS

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Constants included from Primer::AttributesHelper

Primer::AttributesHelper::PLURAL_ARIA_ATTRIBUTES, Primer::AttributesHelper::PLURAL_DATA_ATTRIBUTES

Instance Method Summary collapse

Methods inherited from Component

deprecated?, generate_id

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Methods included from Primer::AttributesHelper

#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Constructor Details

#initialize(scheme: DEFAULT_SCHEME, variant: DEFAULT_VARIANT, tag: DEFAULT_TAG, type: DEFAULT_TYPE, disabled: false, **system_arguments) ⇒ ButtonMarketing

Returns a new instance of ButtonMarketing.

Parameters:

  • scheme (Symbol) (defaults to: DEFAULT_SCHEME)

    <%= one_of(Primer::Alpha::ButtonMarketing::SCHEME_OPTIONS) %>

  • variant (Symbol) (defaults to: DEFAULT_VARIANT)

    <%= one_of(Primer::Alpha::ButtonMarketing::VARIANT_OPTIONS) %>

  • tag (Symbol) (defaults to: DEFAULT_TAG)

    <%= one_of(Primer::Alpha::ButtonMarketing::TAG_OPTIONS) %>

  • type (Symbol) (defaults to: DEFAULT_TYPE)

    <%= one_of(Primer::Alpha::ButtonMarketing::TYPE_OPTIONS) %>

  • disabled (Boolean) (defaults to: false)

    Whether or not the button is disabled. If true, this option forces ‘tag:` to `:button`.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/components/primer/alpha/button_marketing.rb', line 35

def initialize(
  scheme: DEFAULT_SCHEME,
  variant: DEFAULT_VARIANT,
  tag: DEFAULT_TAG,
  type: DEFAULT_TYPE,
  disabled: false,
  **system_arguments
)
  @system_arguments = system_arguments
  @system_arguments[:block] = false
  @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
  @system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE)
  @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]
  )
  @system_arguments[:disabled] = disabled
end

Instance Method Details

#callObject



56
57
58
# File 'app/components/primer/alpha/button_marketing.rb', line 56

def call
  render(Primer::Beta::BaseButton.new(**@system_arguments)) { content }
end