Class: Primer::Beta::Button
- Defined in:
- app/components/primer/beta/button.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 => "Button--primary", :secondary => "Button--secondary", :default => "Button--secondary", :danger => "Button--danger", :outline => "btn-outline", :invisible => "Button--invisible", LINK_SCHEME => "btn-link" }.freeze
- SCHEME_OPTIONS =
SCHEME_MAPPINGS.keys
- DEFAULT_SIZE =
:medium- SIZE_MAPPINGS =
{ :small => "Button--small", :medium => "Button--medium", :large => "Button--large", DEFAULT_SIZE => "Button--medium" }.freeze
- SIZE_OPTIONS =
SIZE_MAPPINGS.keys
- DEFAULT_ALIGN_CONTENT =
:center- ALIGN_CONTENT_MAPPINGS =
{ :start => "Button-content--alignStart", :center => "", DEFAULT_ALIGN_CONTENT => "" }.freeze
- ALIGN_CONTENT_OPTIONS =
ALIGN_CONTENT_MAPPINGS.keys
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
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, size: DEFAULT_SIZE, full_width: false, align_content: DEFAULT_ALIGN_CONTENT, **system_arguments) ⇒ Button
constructor
A new instance of Button.
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, size: DEFAULT_SIZE, full_width: false, align_content: DEFAULT_ALIGN_CONTENT, **system_arguments) ⇒ Button
Returns a new instance of Button.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'app/components/primer/beta/button.rb', line 143 def initialize( scheme: DEFAULT_SCHEME, size: DEFAULT_SIZE, full_width: false, align_content: DEFAULT_ALIGN_CONTENT, **system_arguments ) @scheme = scheme @system_arguments = system_arguments @id = @system_arguments[:id] @align_content_classes = class_names( "Button-content", system_arguments[:classes], ALIGN_CONTENT_MAPPINGS[fetch_or_fallback(ALIGN_CONTENT_OPTIONS, align_content, DEFAULT_ALIGN_CONTENT)] ) @system_arguments[:classes] = class_names( system_arguments[:classes], SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)], SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)], "Button" => !link?, "Button--fullWidth" => full_width ) end |