Class: Polaris::CardComponent
- Defined in:
- app/components/polaris/card_component.rb
Constant Summary collapse
- FOOTER_ACTION_ALIGNMENT_DEFAULT =
:right
- FOOTER_ACTION_ALIGNMENT_MAPPINGS =
{ FOOTER_ACTION_ALIGNMENT_DEFAULT => "", :left => "Polaris-LegacyCard__LeftJustified" }
- FOOTER_ACTION_ALIGNMENT_OPTIONS =
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
- #footer_classes ⇒ Object
-
#initialize(title: "", actions: [], sectioned: true, subdued: false, borders: true, footer_action_alignment: FOOTER_ACTION_ALIGNMENT_DEFAULT, **system_arguments) ⇒ CardComponent
constructor
A new instance of CardComponent.
- #render_footer? ⇒ Boolean
- #system_arguments ⇒ Object
Methods included from ViewHelper
#polaris_body_styles, #polaris_html_classes, #polaris_html_styles, #polaris_icon_source
Methods included from StylesListHelper
Methods included from OptionHelper
#append_option, #prepend_option
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #fetch_or_fallback_nested
Methods included from ClassNameHelper
Constructor Details
#initialize(title: "", actions: [], sectioned: true, subdued: false, borders: true, 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 |
# File 'app/components/polaris/card_component.rb', line 20 def initialize( title: "", actions: [], sectioned: true, subdued: false, borders: true, footer_action_alignment: FOOTER_ACTION_ALIGNMENT_DEFAULT, **system_arguments ) @title = title @actions = actions @sectioned = sectioned @subdued = subdued @borders = borders @footer_action_alignment = @system_arguments = system_arguments end |
Instance Method Details
#footer_classes ⇒ Object
55 56 57 58 59 60 |
# File 'app/components/polaris/card_component.rb', line 55 def class_names( "Polaris-LegacyCard__Footer", FOOTER_ACTION_ALIGNMENT_MAPPINGS[fetch_or_fallback(FOOTER_ACTION_ALIGNMENT_OPTIONS, @footer_action_alignment, FOOTER_ACTION_ALIGNMENT_DEFAULT)] ) end |
#render_footer? ⇒ Boolean
51 52 53 |
# File 'app/components/polaris/card_component.rb', line 51 def .present? || .any? end |
#system_arguments ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/components/polaris/card_component.rb', line 38 def system_arguments @system_arguments.tap do |opts| opts[:tag] = :div opts[:classes] = class_names( opts[:classes], "Polaris-LegacyCard", "Polaris-LegacyCard--subdued": @subdued, "Polaris-LegacyCard--withoutTitle": @title.blank?, "Polaris-LegacyCard--borderless": !@borders ) end end |