Class: Ariadne::UI::Banner::Component

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/ariadne/ui/banner/component.rb

Overview

Use this component to draw attention to important information.

### Events

|Name |Type |Bubbles |Cancelable | |:———|:——————-|:——-|:———-| |‘dismiss` |`CustomEvent<void>` |No |No |

Constant Summary collapse

DEFAULT_SCHEME =
:default
VALID_SCHEMES =
[DEFAULT_SCHEME, :danger, :warning, :info, :success].freeze

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 Method Summary collapse

Methods inherited from BaseComponent

audited_at, #class_for, #component, component_id, #component_id, component_name, generate_id, #html_attributes, i18n_scope, #merge_data_attributes, #merge_tailwind_classes, #options, stimulus_name, translate, #validate_aria_label!

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

Instance Method Details

#before_renderObject

Raises:

  • (ArgumentError)


80
81
82
83
84
# File 'app/components/ariadne/ui/banner/component.rb', line 80

def before_render
  raise ArgumentError, "Requires `dismiss_label`" if dismissible && dismiss_label.nil?

  @header_id = self.class.generate_id
end

#heroicon_or_defaultObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'app/components/ariadne/ui/banner/component.rb', line 86

def heroicon_or_default
  if heroicon?
    heroicon
  else
    icon = case scheme
    when :danger
      :"exclamation-circle"
    when :warning
      :"exclamation-triangle"
    when :info
      :"information-circle"
    when :success
      :"check-circle"
    else
      :"chat-bubble-bottom-center"
    end

    Ariadne::UI::Heroicon::Component.new(icon: icon, variant: :outline)
  end
end

#iconObject



56
57
58
# File 'app/components/ariadne/ui/banner/component.rb', line 56

def icon
  heroicon || infer_icon
end