Class: Www::ReviewsIo::ReviewSliderComponent

Inherits:
ApplicationComponent show all
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

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.

Parameters:

  • tags (Array<String>) (defaults to: nil)

    Primary source — JSONB tag filter (e.g. ['for-homepage'])

  • product_line (String) (defaults to: nil)

    Fallback source — fills remaining slots when tags yield fewer
    than reviews_count results. Also works as a standalone source.

  • skus (Array<String>) (defaults to: nil)

    Alternative explicit SKU list (used instead of product_line)

  • reviews_count (Integer) (defaults to: DEFAULT_REVIEWS_COUNT)

    Target number of reviews to display (default 8)

  • min_rating (Integer, nil) (defaults to: nil)

    Minimum star rating filter

  • per_page (Integer) (defaults to: 3)

    Slides visible at once (default 3)

  • navigation (Symbol) (defaults to: :arrows)

    :arrows or :dots

  • autoplay (Boolean) (defaults to: false)

    Auto-advance slides

  • show_header (Boolean) (defaults to: true)

    Section title + intro text

  • show_stats (Boolean) (defaults to: false)

    Aggregate rating/count line in header

  • section_title (String) (defaults to: 'Customer Reviews')
  • see_all_url (String, nil) (defaults to: nil)

    CTA link below carousel

  • cta_label (String) (defaults to: 'View All Reviews')
  • border (Symbol, nil) (defaults to: nil)

    :top :bottom :both

  • sort (Symbol) (defaults to: :date)

    :date (default) or :rating (highest first)

  • storewide (Boolean) (defaults to: false)

    When true, show aggregate stats for all visible reviews and
    fetch a mixed high-rated carousel (replaces legacy
    StoreAndProductsSliderComponent). Ignores tags/product_line/skus.

  • founder_* (...)

    Optional founder quote card shown as first slide



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(tags).compact_blank.presence
  @reviews_count    = reviews_count
  @see_all_url      = see_all_url
  @section_title    = section_title
  @cta_label        = cta_label
  @min_rating       = min_rating
  @show_header      = show_header
  @show_stats       = show_stats
  @border           = border
  @per_page         = per_page
  @navigation       = 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

Returns:

  • (Boolean)


121
122
123
# File 'app/components/www/reviews_io/review_slider_component.rb', line 121

def render?
  reviews.any? || founder_card?
end