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)
Lead card — the first slide, shown by default on every page:
lead_review: :founder — Julia Billen's founder quote card (DEFAULT)
lead_review: false — no lead card, customer reviews only
lead_review: 12345 — pin ReviewsIo#12345 as the first card
Examples:
Landing page — founder card shown by default
<%= render Www::ReviewsIo::ReviewSliderComponent.new(
product_line: 'floor-heating',
see_all_url: cms_link('/floor-heating/reviews')
) %>
Homepage
<%= render Www::ReviewsIo::ReviewSliderComponent.new(
tags: ['for-homepage'],
per_page: 3,
navigation: :dots,
autoplay: true,
show_header: false
) %>
Opt out of the lead card
<%= render Www::ReviewsIo::ReviewSliderComponent.new(
product_line: 'snow-melting',
lead_review: false
) %>
Constant Summary collapse
- DEFAULT_REVIEWS_COUNT =
Default reviews count.
8- AVATAR_PALETTE =
Avatar colour palette.
%w[#c0392b #2e7d32 #1565c0 #6a1e5e #00695c #e65100].freeze
- FOUNDER_LEAD =
Sentinel +lead_review+ value selecting the founder quote card.
:founder- FOUNDER =
Founder lead card content. Shown as the first slide unless +lead_review+
overrides it. The portrait uses the env-configurable top-level
FOUNDER_IMAGE_ID constant (see config/initializers/reviews_io.rb). { name: 'Julia Billen', title: 'Owner & President, WarmlyYours', quote: "I picked the name ‘WarmlyYours’ because I really felt that it embodied " \ "how we wanted to treat our customers and how we wanted them to see us – as a partner.", link: '/company' }.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, lead_review: FOUNDER_LEAD) ⇒ ReviewSliderComponent
constructor
A new instance of ReviewSliderComponent.
-
#render? ⇒ Boolean
Whether the carousel has anything to show — at least one review or the founder lead card.
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, lead_review: FOUNDER_LEAD) ⇒ ReviewSliderComponent
Returns a new instance of ReviewSliderComponent.
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 120 121 122 123 124 125 126 |
# File 'app/components/www/reviews_io/review_slider_component.rb', line 89 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, lead_review: FOUNDER_LEAD ) @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 @lead_review = lead_review super() end |
Instance Method Details
#render? ⇒ Boolean
Whether the carousel has anything to show — at least one review or the
founder lead card.
132 133 134 |
# File 'app/components/www/reviews_io/review_slider_component.rb', line 132 def render? reviews.any? || founder_card? end |