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.
src/app/reviews-carousel.ts— the<app-reviews-carousel>custom element. Autoplay pauses on hover, focus, and an explicit pause button; it never starts underprefers-reduced-motion; and it follows the WAI-ARIA carousel pattern (one visible slide, othersinert, 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— theReview/Business/ReviewsDatatypes 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— registersReviewsCarouselasapp-reviews-carouselviacreateCustomElement, 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.
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.
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:
- Save the real data as
src/data/kc-pet-nanny-reviews.json— the.gitignorealready excludes this exact filename, so it stays local. Using a different filename? Add it to.gitignoretoo. - Before running a production build, temporarily copy it over the tracked file:
cp src/data/kc-pet-nanny-reviews.json src/data/reviews.json. - Build (
npm run build), then revertsrc/data/reviews.json(git checkout src/data/reviews.json) so the placeholder stays in version control.
npm startOpen http://localhost:4200/ — src/index.html renders <app-reviews-carousel> directly so you can preview it while editing.
npm run buildThis 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. |
npm testRuns the Vitest suite (*.spec.ts files) via the Angular CLI's unit-test builder.