Class: Ariadne::LinkComponent
- Defined in:
- app/components/ariadne/link_component.rb
Overview
Use Link for navigating from one page to another. Link styles anchor tags with default styling and hover text-decoration.
Constant Summary collapse
- DEFAULT_TAG =
:a- TAG_OPTIONS =
[DEFAULT_TAG, :span].freeze
- DEFAULT_CLASSES =
"ariadne-cursor-pointer"- DEFAULT_ACTIONABLE_CLASSES =
" ariadne-cursor-pointer ariadne-underline ariadne-decoration-double ariadne-font-semibold hover:ariadne-text-button-text-color focus:ariadne-outline-none focus:ariadne-ring-2 focus:ariadne-ring-offset-2 focus:ariadne-ring-purple-500"
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
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::INTEGER_TYPES, FetchOrFallbackHelper::InvalidValueError, FetchOrFallbackHelper::TRUE_OR_FALSE
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(tag: DEFAULT_TAG, href:, actionable: false, classes: "", attributes: {}) ⇒ LinkComponent
constructor
A new instance of LinkComponent.
Methods included from ActionViewExtensions::FormHelper
Methods included from ClassNameHelper
Methods included from LoggerHelper
#logger, #silence_deprecations?, #silence_warnings?
Methods included from FetchOrFallbackHelper
#check_incoming_attribute, #check_incoming_tag, #check_incoming_value, #fetch_or_raise, #fetch_or_raise_boolean, #fetch_or_raise_integer
Constructor Details
#initialize(tag: DEFAULT_TAG, href:, actionable: false, classes: "", attributes: {}) ⇒ LinkComponent
Returns a new instance of LinkComponent.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/components/ariadne/link_component.rb', line 47 def initialize(tag: DEFAULT_TAG, href:, actionable: false, classes: "", attributes: {}) @tag = check_incoming_tag(DEFAULT_TAG, tag) @attributes = attributes @attributes[:href] = href @id = @attributes[:id] @classes = class_names(DEFAULT_CLASSES, classes) @classes << DEFAULT_ACTIONABLE_CLASSES if actionable end |
Instance Method Details
#call ⇒ Object
59 60 61 62 63 |
# File 'app/components/ariadne/link_component.rb', line 59 def call render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) do content.to_s + tooltip.to_s end end |