Class: Yattho::Alpha::ButtonMarketing

Inherits:
Component
  • Object
show all
Defined in:
app/components/yattho/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

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

Constructor Details

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

Returns a new instance of ButtonMarketing.

Examples:

Schemes

<%= render(Yattho::Alpha::ButtonMarketing.new(mr: 2)) { "Default" } %>
<%= render(Yattho::Alpha::ButtonMarketing.new(scheme: :primary, mr: 2)) { "Primary" } %>
<%= render(Yattho::Alpha::ButtonMarketing.new(scheme: :outline)) { "Outline" } %>
<div class="color-bg-emphasis">
  <%= render(Yattho::Alpha::ButtonMarketing.new(scheme: :transparent)) { "Transparent" } %>
</div>

Sizes

<%= render(Yattho::Alpha::ButtonMarketing.new(mr: 2)) { "Default" } %>
<%= render(Yattho::Alpha::ButtonMarketing.new(variant: :large)) { "Large" } %>

Parameters:

  • scheme (Symbol) (defaults to: DEFAULT_SCHEME)

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

  • variant (Symbol) (defaults to: DEFAULT_VARIANT)

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

  • tag (Symbol) (defaults to: DEFAULT_TAG)

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

  • type (Symbol) (defaults to: DEFAULT_TYPE)

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

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/components/yattho/alpha/button_marketing.rb', line 46

def initialize(
  scheme: DEFAULT_SCHEME,
  variant: DEFAULT_VARIANT,
  tag: DEFAULT_TAG,
  type: DEFAULT_TYPE,
  **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]
  )
end

Instance Method Details

#callObject



65
66
67
# File 'app/components/yattho/alpha/button_marketing.rb', line 65

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