Class: Www::ReviewsIo::ReviewSliderComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Www::ReviewsIo::ReviewSliderComponent
- Includes:
- Concerns::ReviewsIoSupport
- Defined in:
- app/components/www/reviews_io/review_slider_component.rb
Overview
Unified review track component — renders a Fancyapps carousel of review cards.
Used on the homepage (dots, autoplay, founder card) and every landing page
(arrows, product-line sourced reviews, section header with stats).
Data sources (at least one required):
product_line: 'floor-heating' — resolves SKUs via ltree
skus: ['SKU-001', 'SKU-002'] — explicit list
tags: ['for-homepage'] — JSONB tag filter
(sources are OR-combined when multiple are given)
Navigation variants:
navigation: :arrows — prev/next buttons (default, good for landing pages)
navigation: :dots — pagination dots + autoplay (good for homepage)
Founder card (optional — homepage only):
founder_name: 'Julia Billen'
founder_title: 'Owner & President, WarmlyYours'
founder_quote: 'I picked the name…'
founder_image_id: 1771
founder_link: '/company'
Examples:
Landing page
<%= render Www::ReviewsIo::ReviewSliderComponent.new(
product_line: 'floor-heating',
see_all_url: cms_link('/floor-heating/reviews')
) %>
Homepage (via _product_reviews_home partial)
<%= render Www::ReviewsIo::ReviewSliderComponent.new(
tags: ['for-homepage'],
reviews_count: 5,
per_page: 3,
navigation: :dots,
autoplay: true,
show_header: false,
founder_name: 'Julia Billen',
founder_title: 'Owner & President, WarmlyYours',
founder_quote: "I picked the name \u2018WarmlyYours\u2019 because I really felt that it embodied how we wanted to treat our customers and how we wanted them to see us \u2013 as a partner.",
founder_image_id: 1771,
founder_link: '/company'
) %>
Constant Summary collapse
- DEFAULT_REVIEWS_COUNT =
8- AVATAR_PALETTE =
%w[#c0392b #2e7d32 #1565c0 #6a1e5e #00695c #e65100].freeze
Instance Method Summary collapse
-
#initialize(tags: nil, product_line: nil, skus: nil, reviews_count: DEFAULT_REVIEWS_COUNT, see_all_url: nil, section_title: 'Customer Reviews', cta_label: 'View All Reviews', min_rating: nil, show_header: true, show_stats: false, border: nil, per_page: 3, navigation: :arrows, autoplay: false, sort: :date, storewide: false, founder_name: nil, founder_title: nil, founder_quote: nil, founder_image_id: nil, founder_link: nil) ⇒ ReviewSliderComponent
constructor
A new instance of ReviewSliderComponent.
- #render? ⇒ Boolean
Methods inherited from ApplicationComponent
#cms_link, #fetch_or_fallback, #image_asset_tag, #image_tag, #number_to_currency, #number_with_delimiter, #post_path, #post_url, #strip_tags
Constructor Details
#initialize(tags: nil, product_line: nil, skus: nil, reviews_count: DEFAULT_REVIEWS_COUNT, see_all_url: nil, section_title: 'Customer Reviews', cta_label: 'View All Reviews', min_rating: nil, show_header: true, show_stats: false, border: nil, per_page: 3, navigation: :arrows, autoplay: false, sort: :date, storewide: false, founder_name: nil, founder_title: nil, founder_quote: nil, founder_image_id: nil, founder_link: nil) ⇒ ReviewSliderComponent
Returns a new instance of ReviewSliderComponent.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'app/components/www/reviews_io/review_slider_component.rb', line 74 def initialize( tags: nil, product_line: nil, skus: nil, reviews_count: DEFAULT_REVIEWS_COUNT, see_all_url: nil, section_title: 'Customer Reviews', cta_label: 'View All Reviews', min_rating: nil, show_header: true, show_stats: false, border: nil, per_page: 3, navigation: :arrows, autoplay: false, sort: :date, storewide: false, founder_name: nil, founder_title: nil, founder_quote: nil, founder_image_id: nil, founder_link: nil ) @skus = skus @product_line = product_line @tags = Array().compact_blank.presence @reviews_count = reviews_count @see_all_url = see_all_url @section_title = section_title @cta_label = cta_label @min_rating = @show_header = show_header @show_stats = show_stats @border = border @per_page = per_page @navigation = @autoplay = autoplay @sort = sort @storewide = storewide @founder_name = founder_name @founder_title = founder_title @founder_quote = founder_quote @founder_image_id = founder_image_id @founder_link = founder_link super() end |
Instance Method Details
#render? ⇒ Boolean
121 122 123 |
# File 'app/components/www/reviews_io/review_slider_component.rb', line 121 def render? reviews.any? || founder_card? end |