Class: Primer::BorderBoxComponent

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

Overview

BorderBox is a Box component with a border.

Defined Under Namespace

Classes: Body, Footer, Header, Row

Constant Summary

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from FetchOrFallbackHelper

#fetch_or_fallback

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(**kwargs) ⇒ BorderBoxComponent

Returns a new instance of BorderBoxComponent.

Examples:

350|Header, body, rows, and footer

<%= render(Primer::BorderBoxComponent.new) do |component|
  component.slot(:header) { "Header" }
  component.slot(:body) { "Body" }
  component.slot(:row) { "Row one" }
  component.slot(:row) { "Row two" }
  component.slot(:row) { "Row three" }
  component.slot(:footer) { "Footer" }
end %>

Parameters:

  • kwargs (Hash)

    <%= link_to_style_arguments_docs %>



24
25
26
27
28
29
30
31
# File 'app/components/primer/border_box_component.rb', line 24

def initialize(**kwargs)
  @kwargs = kwargs
  @kwargs[:tag] = :div
  @kwargs[:classes] = class_names(
    "Box",
    kwargs[:classes]
  )
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/components/primer/border_box_component.rb', line 33

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