Class: Primer::OpenProject::DangerConfirmationDialog::ConfirmationCheckBox

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/open_project/danger_confirmation_dialog/confirmation_check_box.rb

Overview

This component is part of ‘Primer::OpenProject::DangerConfirmationDialog` and should not be used as a standalone component.

Constant Summary

Constants inherited from Component

Component::INVALID_ARIA_LABEL_TAGS

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Constants included from AttributesHelper

AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES

Instance Method Summary collapse

Methods inherited from Component

deprecated?, generate_id

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Methods included from AttributesHelper

#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Methods included from ExperimentalSlotHelpers

included

Methods included from ExperimentalRenderHelpers

included

Constructor Details

#initialize(check_box_id: self.class.generate_id, check_box_name:, **system_arguments) ⇒ ConfirmationCheckBox

Returns a new instance of ConfirmationCheckBox.

Parameters:

  • check_box_id (String) (defaults to: self.class.generate_id)

    The id of the check_box input.

  • check_box_name (String)

    The name of the check_box input.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/components/primer/open_project/danger_confirmation_dialog/confirmation_check_box.rb', line 13

def initialize(check_box_id: self.class.generate_id, check_box_name:, **system_arguments)
  @system_arguments = deny_tag_argument(**system_arguments)
  @system_arguments[:tag] = :div
  @system_arguments[:classes] = class_names(
    system_arguments[:classes],
    "DangerConfirmationDialog-confirmationCheckBox"
  )

  @check_box_arguments = {}
  @check_box_arguments[:id] = check_box_id
  @check_box_arguments[:name] = check_box_name
  @check_box_arguments[:data] = {
    target: "danger-confirmation-dialog-form-helper.checkbox",
    action: "change:danger-confirmation-dialog-form-helper#toggle"
  }
end

Instance Method Details

#callObject



30
31
32
33
34
# File 'app/components/primer/open_project/danger_confirmation_dialog/confirmation_check_box.rb', line 30

def call
  render(Primer::BaseComponent.new(**@system_arguments)) do
    render(Primer::Alpha::CheckBox.new(**@check_box_arguments.merge(label: trimmed_content)))
  end
end

#render?Boolean

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


36
37
38
39
40
# File 'app/components/primer/open_project/danger_confirmation_dialog/confirmation_check_box.rb', line 36

def render?
  raise ArgumentError, "ConfirmationCheckBox requires a content block" unless trimmed_content.present?

  true
end