Class: Ariadne::UI::Heroicon::Component

Inherits:
BaseComponent
  • Object
show all
Includes:
IconHelper, HeroiconsHelper
Defined in:
app/components/ariadne/ui/heroicon/component.rb

Overview

Examples:

Default

<%= render(Ariadne::UI::Heroicon::Component.new(icon: :check, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE)) %>
<%= render(Ariadne::UI::Heroicon::Component.new(icon: :check, variant: HeroiconsHelper::Icon::VARIANT_SOLID)) %>

Medium

<%= render(Ariadne::UI::Heroicon::Component.new(icon: :"user-group", variant: HeroiconsHelper::Icon::VARIANT_OUTLINE, size: :md)) %>

Helper

<%= ariadne_heroicon(icon: :check, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE) %>

Constant Summary

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::INTEGER_TYPES, FetchOrFallbackHelper::InvalidValueError, FetchOrFallbackHelper::TRUE_OR_FALSE

Constants inherited from BaseComponent

BaseComponent::ACCEPT_ANYTHING

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from AttributesHelper

AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES

Instance Attribute Summary collapse

Instance Method Summary collapse

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_fallback, #fetch_or_raise, #fetch_or_raise_boolean, #fetch_or_raise_integer

Methods included from LoggerHelper

#logger, #silence_deprecations?, #silence_warnings?

Methods inherited from BaseComponent

#class_for, #component, component_id, #component_id, component_name, #html_attributes, i18n_scope, #in_turbo_frame, #in_turbo_stream, #options, stimulus_name, #styles, translate, #validate_aria_label!

Methods included from ViewHelper

generate_id

Methods included from AttributesHelper

#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes, #prepend_action, #prepend_controller, #prepend_data_attribute

Methods included from ViewComponent::StyleVariants

#merged_styles

Constructor Details

#initialize(**options) ⇒ Component

Returns a new instance of Component.



41
42
43
44
45
46
47
# File 'app/components/ariadne/ui/heroicon/component.rb', line 41

def initialize(**options)
  super

  check_icon_presence!(icon, variant)

  @heroicon = heroicon(@icon, variant: @variant)
end

Instance Attribute Details

#dark_modeObject

Returns the value of attribute dark_mode.



25
26
27
# File 'app/components/ariadne/ui/heroicon/component.rb', line 25

def dark_mode
  @dark_mode
end

Instance Method Details

#innerObject



53
54
55
# File 'app/components/ariadne/ui/heroicon/component.rb', line 53

def inner
  ActiveSupport::SafeBuffer.new(@heroicon.inner)
end

#svg_attributesObject



49
50
51
# File 'app/components/ariadne/ui/heroicon/component.rb', line 49

def svg_attributes
  tag.attributes(html_attrs.except(:class).merge(@heroicon.attributes.except("class", "aria-hidden")))
end