Class: Polaris::ThumbnailComponent
- Includes:
- ActiveModel::Validations
- Defined in:
- app/components/polaris/thumbnail_component.rb
Constant Summary collapse
- SIZE_DEFAULT =
:medium
- SIZE_MAPPINGS =
{ small: "Polaris-Thumbnail--sizeSmall", medium: "Polaris-Thumbnail--sizeMedium", large: "Polaris-Thumbnail--sizeLarge" }
- SIZE_OPTIONS =
SIZE_MAPPINGS.keys
Constants included from ViewHelper
ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#transparent ⇒ Object
readonly
Returns the value of attribute transparent.
Instance Method Summary collapse
-
#initialize(alt: nil, size: SIZE_DEFAULT, source: nil, transparent: false, **system_arguments) ⇒ ThumbnailComponent
constructor
A new instance of ThumbnailComponent.
- #renders? ⇒ 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(alt: nil, size: SIZE_DEFAULT, source: nil, transparent: false, **system_arguments) ⇒ ThumbnailComponent
Returns a new instance of ThumbnailComponent.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/components/polaris/thumbnail_component.rb', line 21 def initialize( alt: nil, size: SIZE_DEFAULT, source: nil, transparent: false, **system_arguments ) @alt = alt @size = size @source = source @transparent = transparent @system_arguments = system_arguments end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
7 8 9 |
# File 'app/components/polaris/thumbnail_component.rb', line 7 def size @size end |
#transparent ⇒ Object (readonly)
Returns the value of attribute transparent.
7 8 9 |
# File 'app/components/polaris/thumbnail_component.rb', line 7 def transparent @transparent end |
Instance Method Details
#renders? ⇒ Boolean
36 37 38 |
# File 'app/components/polaris/thumbnail_component.rb', line 36 def renders? source.present? || icon.present? end |
#system_arguments ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/components/polaris/thumbnail_component.rb', line 40 def system_arguments @system_arguments.tap do |opts| opts[:tag] = :span opts[:classes] = class_names( @system_arguments[:classes], "Polaris-Thumbnail", SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, @size, SIZE_DEFAULT)], "Polaris-Thumbnail--transparent": @transparent ) end end |