Class: FlexiAdmin::Components::Resources::GridView::CardComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- FlexiAdmin::Components::Resources::GridView::CardComponent
- Includes:
- Helpers::LinkHelper
- Defined in:
- lib/flexi_admin/components/resources/grid_view/card_component.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#header ⇒ Object
Returns the value of attribute header.
-
#image ⇒ Object
Returns the value of attribute image.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #description_value ⇒ Object
- #header_value ⇒ Object
- #image_src ⇒ Object
-
#initialize(resource, title, header, description, image) ⇒ CardComponent
constructor
A new instance of CardComponent.
- #media? ⇒ Boolean
- #media_attachment ⇒ Object
- #render_media ⇒ Object
- #title_value ⇒ Object
Methods included from Helpers::LinkHelper
Constructor Details
#initialize(resource, title, header, description, image) ⇒ CardComponent
Returns a new instance of CardComponent.
9 10 11 12 13 14 15 |
# File 'lib/flexi_admin/components/resources/grid_view/card_component.rb', line 9 def initialize(resource, title, header, description, image) @resource = resource @title = title @header = header @description = description @image = image end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/flexi_admin/components/resources/grid_view/card_component.rb', line 7 def description @description end |
#header ⇒ Object
Returns the value of attribute header.
7 8 9 |
# File 'lib/flexi_admin/components/resources/grid_view/card_component.rb', line 7 def header @header end |
#image ⇒ Object
Returns the value of attribute image.
7 8 9 |
# File 'lib/flexi_admin/components/resources/grid_view/card_component.rb', line 7 def image @image end |
#resource ⇒ Object
Returns the value of attribute resource.
7 8 9 |
# File 'lib/flexi_admin/components/resources/grid_view/card_component.rb', line 7 def resource @resource end |
#title ⇒ Object
Returns the value of attribute title.
7 8 9 |
# File 'lib/flexi_admin/components/resources/grid_view/card_component.rb', line 7 def title @title end |
Instance Method Details
#description_value ⇒ Object
59 60 61 62 63 |
# File 'lib/flexi_admin/components/resources/grid_view/card_component.rb', line 59 def description_value return unless description description.formatted_value(description.value[resource]) end |
#header_value ⇒ Object
53 54 55 56 57 |
# File 'lib/flexi_admin/components/resources/grid_view/card_component.rb', line 53 def header_value return unless header header.formatted_value(header.value[resource]) end |
#image_src ⇒ Object
21 22 23 24 25 26 |
# File 'lib/flexi_admin/components/resources/grid_view/card_component.rb', line 21 def image_src return unless image return if .blank? image.src(, variant: :thumb) end |
#media? ⇒ Boolean
28 29 30 31 32 33 |
# File 'lib/flexi_admin/components/resources/grid_view/card_component.rb', line 28 def media? return false unless image return false if .blank? true end |
#media_attachment ⇒ Object
17 18 19 |
# File 'lib/flexi_admin/components/resources/grid_view/card_component.rb', line 17 def @media_attachment ||= image.value[resource] end |
#render_media ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/flexi_admin/components/resources/grid_view/card_component.rb', line 35 def render_media case .content_type.split("/").first when "image" content_tag :img, nil, src: image_src, style: "object-fit: cover; width: 100%; height: 180px;" when "video" content_tag :video, nil, src: image_src, style: "object-fit: cover; width: 100%; height: 180px;", controls: true, onmouseover: "this.play()", onmouseout: "this.pause()" end end |
#title_value ⇒ Object
47 48 49 50 51 |
# File 'lib/flexi_admin/components/resources/grid_view/card_component.rb', line 47 def title_value return unless title title.formatted_value(title.value[resource]) end |