Class: Ariadne::UI::Dialog::Component

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

Overview

A ‘Dialog` is used to remove the user from the main application flow, to confirm actions, ask for disambiguation or to present small forms.

Constant Summary

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

Slots 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

#describedbyObject



99
100
101
# File 'app/components/ariadne/ui/dialog/component.rb', line 99

def describedby
  "#{@dialog_id}-description"
end

#labelledbyObject



95
96
97
# File 'app/components/ariadne/ui/dialog/component.rb', line 95

def labelledby
  "#{@dialog_id}-title"
end

#reveal_buttonObject

The button to open the dialog.

A link to open the dialog.

Parameters:

  • options (Hash)

    Same arguments as <%= link_to_component(Ariadne::UI::Button::Component) %>.\

  • options (Hash)

    Same arguments as <%= link_to_component(Ariadne::UI::Link::Component) %>.\



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/components/ariadne/ui/dialog/component.rb', line 44

renders_one :reveal, types: {
  button: lambda { |**options|
    component_data_attrs = {
      action: "#{stimulus_name}#open", # Use the component's stimulus_name method
    }
    options[:html_attrs] ||= {}
    # Ensure merge_data_attributes helper exists and is used correctly
    options[:html_attrs][:data] = merge_data_attributes(options.fetch(:html_attrs, {}), component_data_attrs)
    Ariadne::UI::Button::Component.new(**options) # Pass remaining options
  },
  link: lambda { |**options|
    component_data_attrs = {
      action: "#{stimulus_name}#open", # Use the component's stimulus_name method
    }
    options[:html_attrs] ||= {}
    # Ensure merge_data_attributes helper exists and is used correctly
    options[:html_attrs][:data] = merge_data_attributes(options.fetch(:html_attrs, {}), component_data_attrs)
    Ariadne::UI::Link::Component.new(**options) # Pass remaining options
  },
}

The button to open the dialog.

A link to open the dialog.

Parameters:

  • options (Hash)

    Same arguments as <%= link_to_component(Ariadne::UI::Button::Component) %>.\

  • options (Hash)

    Same arguments as <%= link_to_component(Ariadne::UI::Link::Component) %>.\



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/components/ariadne/ui/dialog/component.rb', line 44

renders_one :reveal, types: {
  button: lambda { |**options|
    component_data_attrs = {
      action: "#{stimulus_name}#open", # Use the component's stimulus_name method
    }
    options[:html_attrs] ||= {}
    # Ensure merge_data_attributes helper exists and is used correctly
    options[:html_attrs][:data] = merge_data_attributes(options.fetch(:html_attrs, {}), component_data_attrs)
    Ariadne::UI::Button::Component.new(**options) # Pass remaining options
  },
  link: lambda { |**options|
    component_data_attrs = {
      action: "#{stimulus_name}#open", # Use the component's stimulus_name method
    }
    options[:html_attrs] ||= {}
    # Ensure merge_data_attributes helper exists and is used correctly
    options[:html_attrs][:data] = merge_data_attributes(options.fetch(:html_attrs, {}), component_data_attrs)
    Ariadne::UI::Link::Component.new(**options) # Pass remaining options
  },
}