Class: Primer::DetailsComponent

Inherits:
Component
  • Object
show all
Includes:
ViewComponent::Slotable
Defined in:
app/components/primer/details_component.rb

Overview

overlay - options are ‘none`, `default` and `dark`. Dictates the type of overlay to render with. button - options are `default` and `reset`. default will make the target a default primer “.btn`

reset will remove all styles from the <summary> element.

Defined Under Namespace

Classes: Body, Summary

Constant Summary collapse

NO_OVERLAY =
:none
OVERLAY_MAPPINGS =
{
  NO_OVERLAY => "",
  :default => "details-overlay",
  :dark => "details-overlay details-overlay-dark",
}.freeze

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(overlay: NO_OVERLAY, reset: false, **system_arguments) ⇒ DetailsComponent

Returns a new instance of DetailsComponent.



22
23
24
25
26
27
28
29
30
# File 'app/components/primer/details_component.rb', line 22

def initialize(overlay: NO_OVERLAY, reset: false, **system_arguments)
  @system_arguments = system_arguments
  @system_arguments[:tag] = :details
  @system_arguments[:classes] = class_names(
    system_arguments[:classes],
    OVERLAY_MAPPINGS[fetch_or_fallback(OVERLAY_MAPPINGS.keys, overlay, NO_OVERLAY)],
    "details-reset" => reset
  )
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/components/primer/details_component.rb', line 32

def render?
  summary.present? && body.present?
end