Class: Polaris::CardComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/polaris/card_component.rb

Constant Summary collapse

:right
{
  FOOTER_ACTION_ALIGNMENT_DEFAULT => "",
  :left => "Polaris-Card__LeftJustified"
}
FOOTER_ACTION_ALIGNMENT_MAPPINGS.keys

Constants included from ViewHelper

ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from ViewHelper

#polaris_body_styles, #polaris_icon_source, #polaris_inversed_colors

Methods included from OptionHelper

#append_option, #prepend_option

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(title: "", actions: [], sectioned: true, subdued: false, footer_action_alignment: FOOTER_ACTION_ALIGNMENT_DEFAULT, **system_arguments) ⇒ CardComponent

Returns a new instance of CardComponent.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/components/polaris/card_component.rb', line 20

def initialize(
  title: "",
  actions: [],
  sectioned: true,
  subdued: false,
  footer_action_alignment: FOOTER_ACTION_ALIGNMENT_DEFAULT,
  **system_arguments
)
  @title = title
  @actions = actions
  @sectioned = sectioned
  @footer_action_alignment = footer_action_alignment

  @system_arguments = system_arguments
  @system_arguments[:tag] = :div
  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    "Polaris-Card",
    "Polaris-Card--subdued": subdued
  )
end

Instance Method Details



46
47
48
49
50
51
# File 'app/components/polaris/card_component.rb', line 46

def footer_classes
  class_names(
    "Polaris-Card__Footer",
    FOOTER_ACTION_ALIGNMENT_MAPPINGS[fetch_or_fallback(FOOTER_ACTION_ALIGNMENT_OPTIONS, @footer_action_alignment, FOOTER_ACTION_ALIGNMENT_DEFAULT)]
  )
end

#render_footer?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/components/polaris/card_component.rb', line 42

def render_footer?
  primary_footer_action.present? || secondary_footer_actions.any?
end