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 =
{ none: "", default: "ariadne-text-purple-800 ariadne-bg-purple-50 hover:ariadne-bg-purple-100 ariadne-border-purple-300 focus:ariadne-ring-offset-purple-50 focus:ariadne-ring-purple-600", info: "ariadne-text-blue-800 ariadne-bg-blue-50 hover:ariadne-bg-blue-100 ariadne-border-blue-300 focus:ariadne-ring-offset-blue-50 focus:ariadne-ring-blue-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_BODY_CLASSES, Component::BASE_HTML_CLASSES, 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, 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, classes: "", attributes: {}) ⇒ ButtonComponent
Returns a new instance of ButtonComponent.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'app/components/ariadne/button_component.rb', line 118 def initialize( tag: Ariadne::BaseButton::DEFAULT_TAG, type: Ariadne::BaseButton::DEFAULT_TYPE, scheme: DEFAULT_SCHEME, size: BaseButton::DEFAULT_SIZE, classes: "", attributes: {} ) @tag = tag @type = type @scheme = scheme @attributes = attributes @id = @attributes[:id] @size = fetch_or_raise(Ariadne::BaseButton::VALID_SIZES, size) @scheme = fetch_or_raise(VALID_SCHEMES, scheme) @classes = class_names( SCHEME_CLASS_MAPPINGS[@scheme], classes, ) end |