Class: Pulse::BorderBox

Inherits:
Component
  • Object
show all
Defined in:
app/components/pulse/border_box.rb,
app/components/pulse/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}?".freeze
DEFAULT_ROW_SCHEME =
:default
ROW_SCHEME_MAPPINGS =
{
  DEFAULT_ROW_SCHEME => '',
  :neutral => 'Box-row--gray',
  :info => 'Box-row--blue',
  :warning => 'Box-row--yellow'
}.freeze

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of BorderBox.

Parameters:

  • padding (Symbol) (defaults to: DEFAULT_PADDING)

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

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'app/components/pulse/border_box.rb', line 88

def initialize(padding: DEFAULT_PADDING, **system_arguments)
  @system_arguments = deny_tag_argument(**system_arguments)
  @system_arguments[:tag] = :div
  @system_arguments[:classes] = class_names(
    'pulse-bg-white pulse-border pulse-border-gray-300 pulse-border-solid',
    'pulse-border-[1px] pulse-rounded-md',
    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,
    class: class_names
    # 'pulse-divide-y pulse-divide-gray-300',
    # 'pulse-border-b pulse-border-gray-300 pulse-border-solid'

  }
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'app/components/pulse/border_box.rb', line 110

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