class Primer::StateComponent

Component for rendering the status of an item.

def call

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

def initialize(

Parameters:
  • system_arguments (Hash) -- <%= link_to_system_arguments_docs %>
  • size (Symbol) -- <%= one_of(Primer::StateComponent::SIZE_OPTIONS) %>
  • tag (Symbol) -- HTML tag for element. <%= one_of(Primer::StateComponent::TAG_OPTIONS) %>
  • color (Symbol) -- Background color. <%= one_of(Primer::StateComponent::COLOR_OPTIONS) %>
  • title (String) -- `title` HTML attribute.

Other tags:
    Example: Sizes -
    Example: Colors -
    Example: Default -
def initialize(
  title:,
  color: COLOR_DEFAULT,
  tag: TAG_DEFAULT,
  size: SIZE_DEFAULT,
  **system_arguments
)
  @system_arguments = system_arguments
  @system_arguments[:title] = title
  @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, TAG_DEFAULT)
  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    "State",
    COLOR_MAPPINGS[fetch_or_fallback(COLOR_OPTIONS, color, COLOR_DEFAULT)],
    SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]
  )
end