Class: Primer::Beta::BorderBox

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/beta/border_box.rb,
app/components/primer/beta/border_box/header.rb

Overview

‘BorderBox` is a Box component with a border.

Defined Under Namespace

Classes: Header

Constant Summary collapse

DEFAULT_PADDING =
:default
PADDING_MAPPINGS =
{
  DEFAULT_PADDING => "",
  :condensed => "Box--condensed",
  :spacious => "Box--spacious"
}.freeze
PADDING_SUGGESTION =
"Perhaps you could consider using :padding options of #{PADDING_MAPPINGS.keys.to_sentence}?"
DEFAULT_ROW_SCHEME =
:default
ROW_SCHEME_MAPPINGS =
{
  DEFAULT_ROW_SCHEME => "",
  :neutral => "Box-row--gray",
  :info => "Box-row--blue",
  :warning => "Box-row--yellow"
}.freeze

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, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Constructor Details

#initialize(padding: DEFAULT_PADDING, **system_arguments) ⇒ BorderBox

Returns a new instance of BorderBox.

Parameters:

  • padding (Symbol) (defaults to: DEFAULT_PADDING)

    <%= one_of(Primer::Beta::BorderBox::PADDING_MAPPINGS.keys) %>

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



75
76
77
78
79
80
81
82
83
84
85
86
# File 'app/components/primer/beta/border_box.rb', line 75

def initialize(padding: DEFAULT_PADDING, **system_arguments)
  @system_arguments = deny_tag_argument(**system_arguments)
  @system_arguments[:tag] = :div
  @system_arguments[:classes] = class_names(
    "Box",
    PADDING_MAPPINGS[fetch_or_fallback(PADDING_MAPPINGS.keys, padding, DEFAULT_PADDING)],
    system_arguments[:classes]
  )

  @system_arguments[:system_arguments_denylist] = { [:p, :pt, :pb, :pr, :pl] => PADDING_SUGGESTION }
  @list_arguments = { tag: :ul }
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'app/components/primer/beta/border_box.rb', line 88

def render?
  rows.any? || header.present? || body.present? || footer.present?
end