Class: Primer::PopoverComponent::Body

Inherits:
Slot
  • Object
show all
Defined in:
app/components/primer/popover_component.rb

Overview

:nodoc:

Constant Summary collapse

CARET_DEFAULT =
:top
CARET_MAPPINGS =
{
  CARET_DEFAULT => "",
  :bottom => "Popover-message--bottom",
  :bottom_right => "Popover-message--bottom-right",
  :bottom_left => "Popover-message--bottom-left",
  :left => "Popover-message--left",
  :left_bottom => "Popover-message--left-bottom",
  :left_top => "Popover-message--left-top",
  :right => "Popover-message--right",
  :right_bottom => "Popover-message--right-bottom",
  :right_top => "Popover-message--right-top",
  :top_left => "Popover-message--top-left",
  :top_right => "Popover-message--top-right"
}.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(caret: CARET_DEFAULT, large: false, **system_arguments) ⇒ Body

Returns a new instance of Body.

Parameters:

  • caret (Symbol) (defaults to: CARET_DEFAULT)

    <%= one_of(Primer::PopoverComponent::Body::CARET_MAPPINGS.keys) %>

  • large (Boolean) (defaults to: false)

    Whether to use the large version of the component.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'app/components/primer/popover_component.rb', line 95

def initialize(caret: CARET_DEFAULT, large: false, **system_arguments)
  @system_arguments = system_arguments
  @system_arguments[:classes] = class_names(
    system_arguments[:classes],
    "Popover-message Box",
    CARET_MAPPINGS[fetch_or_fallback(CARET_MAPPINGS.keys, caret, CARET_DEFAULT)],
    "Popover-message--large" => large
  )
  @system_arguments[:p] ||= 4
  @system_arguments[:mt] ||= 2
  @system_arguments[:mx] ||= :auto
  @system_arguments[:text_align] ||= :left
  @system_arguments[:box_shadow] ||= :large
end

Instance Method Details

#componentObject



110
111
112
# File 'app/components/primer/popover_component.rb', line 110

def component
  Primer::BoxComponent.new(**@system_arguments)
end