Class: Primer::BoxComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/box_component.rb

Overview

A basic wrapper component for most layout related needs.

Constant Summary

Constants inherited from Component

Component::STATUSES

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ViewHelper

#primer

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(**system_arguments) ⇒ BoxComponent

Returns a new instance of BoxComponent.

Examples:

Default

<%= render(Primer::BoxComponent.new) { "Your content here" } %>

Color and padding

<%= render(Primer::BoxComponent.new(bg: :gray, p: 3)) { "Hello world" } %>

Parameters:

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



13
14
15
16
# File 'app/components/primer/box_component.rb', line 13

def initialize(**system_arguments)
  @system_arguments = system_arguments
  @system_arguments[:tag] = :div
end

Class Method Details

.statusObject



22
23
24
# File 'app/components/primer/box_component.rb', line 22

def self.status
  Primer::Component::STATUSES[:stable]
end

Instance Method Details

#callObject



18
19
20
# File 'app/components/primer/box_component.rb', line 18

def call
  render(Primer::BaseComponent.new(**@system_arguments)) { content }
end