Class: Primer::ButtonGroupComponent

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

Overview

Use ButtonGroupComponent to render a series of buttons.

Constant Summary

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

Instance Method Summary collapse

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

Constructor Details

#initialize(**system_arguments) ⇒ ButtonGroupComponent

Returns a new instance of ButtonGroupComponent.

Examples:

Default

<%= render(Primer::ButtonGroupComponent.new) do |component|
  component.button { "Default" }
  component.button(scheme: :primary) { "Primary" }
  component.button(scheme: :danger) { "Danger" }
  component.button(scheme: :outline) { "Outline" }
  component.button(classes: "my-class") { "Custom class" }
end %>

Parameters:

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



21
22
23
24
25
26
27
28
29
# File 'app/components/primer/button_group_component.rb', line 21

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

  @system_arguments[:classes] = class_names(
    "BtnGroup",
    system_arguments[:classes]
  )
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/components/primer/button_group_component.rb', line 31

def render?
  buttons.any?
end