Skip to content

About

Google reviews carousel as a standalone Angular Element for a Squarespace code block

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Google Reviews Carousel

A rotating carousel of Google reviews, built as a standalone Angular Element and designed to be pasted into a Squarespace code block. Reviews are baked in from a static JSON file at build time, so the finished main.js is a single self-contained script with no runtime API calls, backend, or third-party embed.

How it works

  • src/app/reviews-carousel.ts — the <app-reviews-carousel> custom element. Autoplay pauses on hover, focus, and an explicit pause button; it never starts under prefers-reduced-motion; and it follows the WAI-ARIA carousel pattern (one visible slide, others inert, live region announcements only while rotation is stopped).
  • src/app/star-rating.ts — a small <app-star-rating> presentational component used for both the header summary and each review.
  • src/app/review.ts — the Review / Business / ReviewsData types that shape the data file.
  • src/data/reviews.json — the reviews and business summary, imported directly into the bundle. This repo is public, so it ships with generic placeholder reviews rather than a real customer's data — see Using real reviews below.
  • src/main.ts — registers ReviewsCarousel as app-reviews-carousel via createCustomElement, so the built script works as a plain custom element with no Angular bootstrapping required on the host page.

Styling uses Shadow DOM encapsulation, so Squarespace's site-wide theme CSS can't leak in and the carousel's own styles can't leak out. Colors can be overridden from the host page with CSS custom properties (--grc-accent-color, --grc-star, --grc-bg, --grc-border, --grc-text, --grc-muted, --grc-max-width, etc.) set on the app-reviews-carousel element.

Updating the reviews

Edit src/data/reviews.json:

{
  "business": {
    "name": "Your Business Name",
    "url": "https://www.google.com/maps/search/?api=1&query=Your+Business+Name",
    "rating": 4.9,
    "reviewCount": 27
  },
  "reviews": [
    { "author": "Alex M.", "rating": 5, "date": "2 weeks ago", "text": "..." }
  ]
}

avatarUrl is optional per review; without it, the carousel shows a circle with the author's initial.

Using real reviews

src/data/reviews.json ships with generic placeholder content since this repo is public. To build with a real business's reviews without publishing them:

  1. Save the real data as src/data/kc-pet-nanny-reviews.json — the .gitignore already excludes this exact filename, so it stays local. Using a different filename? Add it to .gitignore too.
  2. Before running a production build, temporarily copy it over the tracked file: cp src/data/kc-pet-nanny-reviews.json src/data/reviews.json.
  3. Build (npm run build), then revert src/data/reviews.json (git checkout src/data/reviews.json) so the placeholder stays in version control.

Development server

npm start

Open http://localhost:4200/ — src/index.html renders <app-reviews-carousel> directly so you can preview it while editing.

Building for embedding

npm run build

This produces dist/google-reviews-carousel/browser/main.js — a single, unhashed, self-contained JavaScript file. To embed the carousel on a Squarespace page, add a Code Block with:

<app-reviews-carousel></app-reviews-carousel>
<script type="module" src="https://your-host/main.js"></script>

main.js needs to be hosted somewhere reachable by the page (e.g. Squarespace file storage, a CDN, or another static host) since Squarespace code blocks don't accept uploaded .js files directly.

Useful attributes on <app-reviews-carousel>:

Attribute Default Description
autoplay-ms 6000 Milliseconds between slides. Set to 0 to disable autoplay.
heading What our customers say Heading text above the carousel.

Running unit tests

npm test

Runs the Vitest suite (*.spec.ts files) via the Angular CLI's unit-test builder.

About

Google reviews carousel as a standalone Angular Element for a Squarespace code block

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages