Class: Ariadne::ButtonComponent
- Includes:
- IconHelper
- Defined in:
- app/components/ariadne/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_CLASS_MAPPINGS =
{ link: Ariadne::LinkComponent::DEFAULT_ACTIONABLE_CLASSES, none: "", default: "ariadne-text-slate-800 ariadne-bg-slate-50 hover:ariadne-bg-slate-100 ariadne-border-slate-300 focus:ariadne-ring-offset-slate-50 focus:ariadne-ring-slate-600", info: "ariadne-text-slate-800 ariadne-bg-slate-50 hover:ariadne-bg-slate-100 ariadne-border-slate-300 focus:ariadne-ring-offset-blue-50 focus:ariadne-ring-slate-600", success: "ariadne-text-green-800 ariadne-bg-green-50 hover:ariadne-bg-green-100 ariadne-border-green-300 focus:ariadne-ring-offset-green-50 focus:ariadne-ring-green-600", warning: "ariadne-text-yellow-800 ariadne-bg-yellow-50 hover:ariadne-bg-yellow-100 ariadne-border-yellow-300 focus:ariadne-ring-offset-yellow-50 focus:ariadne-ring-yellow-600", danger: "ariadne-text-red-800 ariadne-bg-red-50 hover:ariadne-bg-red-100 ariadne-border-red-300 focus:ariadne-ring-offset-red-50 focus:ariadne-ring-red-600", }.freeze
- VALID_SCHEMES =
SCHEME_CLASS_MAPPINGS.keys.freeze
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::INTEGER_TYPES, FetchOrFallbackHelper::InvalidValueError, FetchOrFallbackHelper::TRUE_OR_FALSE
Constants inherited from Component
Component::BASE_HIDDEN_CLASS, Component::BASE_MAIN_CLASSES, Component::BASE_WRAPPER_CLASSES, Component::INVALID_ARIA_LABEL_TAGS
Constants included from ActionViewExtensions::FormHelper
ActionViewExtensions::FormHelper::DEFAULT_FORM_CLASSES
Constants included from Status::Dsl
Constants included from ViewHelper
Instance Method Summary collapse
-
#initialize(tag: Ariadne::BaseButton::DEFAULT_TAG, type: Ariadne::BaseButton::DEFAULT_TYPE, scheme: DEFAULT_SCHEME, size: BaseButton::DEFAULT_SIZE, dropdown: false, classes: "", attributes: {}) ⇒ ButtonComponent
constructor
A new instance of ButtonComponent.
Methods included from IconHelper
#check_icon_presence!, ensure_valid_variant, #has_partial_icon?, #icon_presence!, #variant_presence!
Methods included from FetchOrFallbackHelper
#check_incoming_attribute, #check_incoming_tag, #check_incoming_value, #fetch_or_raise, #fetch_or_raise_boolean, #fetch_or_raise_integer
Methods included from LoggerHelper
#logger, #silence_deprecations?, #silence_warnings?
Methods included from ActionViewExtensions::FormHelper
Methods included from ClassNameHelper
Constructor Details
#initialize(tag: Ariadne::BaseButton::DEFAULT_TAG, type: Ariadne::BaseButton::DEFAULT_TYPE, scheme: DEFAULT_SCHEME, size: BaseButton::DEFAULT_SIZE, dropdown: false, classes: "", attributes: {}) ⇒ ButtonComponent
Returns a new instance of ButtonComponent.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'app/components/ariadne/button_component.rb', line 119 def initialize( tag: Ariadne::BaseButton::DEFAULT_TAG, type: Ariadne::BaseButton::DEFAULT_TYPE, scheme: DEFAULT_SCHEME, size: BaseButton::DEFAULT_SIZE, dropdown: false, classes: "", attributes: {} ) @tag = tag @type = type @attributes = attributes @id = @attributes[:id] @size = fetch_or_raise(Ariadne::BaseButton::VALID_SIZES, size) @scheme = fetch_or_raise(VALID_SCHEMES, scheme) @scheme = LINK_SCHEME if @tag == :a @classes = class_names( SCHEME_CLASS_MAPPINGS[@scheme], classes, ) end |