Skip to content

Commit 3a91aea

Browse files
Core rollout: PDP, Cart/Drawer, PLP, Search (#4)
## Summary - complete PDP phase with robust variant state sync (URL/form/media/price) and add-to-cart UX states - implement global cart drawer with keyboard accessibility, quantity/remove async flows, empty/error handling, and cart page async updates - add collection sort/filter behavior and progressive load-more; add predictive search with graceful fallback to full search - align CI/docs/workflow: branch strategy checks, smoke script, baseline performance notes, and updated README/CLAUDE/TODO
2 parents 305fe03 + 98450d2 commit 3a91aea

83 files changed

Lines changed: 3485 additions & 436 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,28 @@ on:
55
pull_request:
66

77
jobs:
8+
branch-strategy:
9+
name: Branch Strategy Check
10+
if: github.event_name == 'pull_request'
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Validate PR source and target branches
14+
run: |
15+
BASE="${{ github.base_ref }}"
16+
HEAD="${{ github.head_ref }}"
17+
18+
if [ "$BASE" = "staging" ] && [[ ! "$HEAD" =~ ^feat/ ]]; then
19+
echo "PRs to staging must come from feat/* branches. Got: $HEAD"
20+
exit 1
21+
fi
22+
23+
if [ "$BASE" = "main" ] && [ "$HEAD" != "staging" ]; then
24+
echo "PRs to main must come from staging. Got: $HEAD"
25+
exit 1
26+
fi
27+
28+
echo "Branch strategy check passed for $HEAD -> $BASE"
29+
830
quality:
931
name: Typecheck and Build
1032
runs-on: ubuntu-latest
@@ -19,6 +41,8 @@ jobs:
1941
run: bun run typecheck
2042
- name: Build assets
2143
run: bun run build
44+
- name: Ensure generated assets are committed
45+
run: git diff --exit-code -- assets snippets/vite-tag.liquid
2246

2347
theme-check:
2448
name: Theme Check

AGENTS.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# AGENTS.md - AI Contributor Guide
2+
3+
This file is for any AI coding assistant (Claude, Codex, Cursor, etc.) working in this repository.
4+
5+
## Goal
6+
7+
- Keep the starter aligned with Shopify docs-first patterns.
8+
- Keep TypeScript for behavior and Liquid for markup.
9+
- Keep customization safe via stable `data-js` contracts.
10+
11+
## Non-Negotiable Rules
12+
13+
- Do not generate cart/minicart/search HTML strings in TS.
14+
- Do not add `{% render 'vite-tag' %}` in sections/snippets.
15+
- Keep entrypoint routing centralized in `layout/theme.liquid`.
16+
- Keep API calls user-driven where required by this starter architecture.
17+
18+
## Where to Implement Changes
19+
20+
- Global bootstrap: `frontend/entrypoints/ts/theme.ts`
21+
- Cart drawer logic: `frontend/entrypoints/ts/cart/drawer.ts`
22+
- Cart page logic: `frontend/entrypoints/ts/cart/page.ts`
23+
- Product logic: `frontend/entrypoints/ts/product.ts` + `frontend/entrypoints/ts/product/*`
24+
- Collection logic: `frontend/entrypoints/ts/collection.ts`
25+
- Search drawer logic: `frontend/entrypoints/ts/search/drawer.ts`
26+
- Liquid markup: `sections/**`, `snippets/**`
27+
28+
## Shopify Patterns Required
29+
30+
- Cart mutations use bundled section rendering (`sections`, `sections_url`).
31+
- Single section rendering (`?section_id=`) is used only where explicitly intended (e.g. drawer hydration).
32+
- Locale-aware routes use `window.Shopify.routes.root`.
33+
34+
## Stable Data Contracts
35+
36+
- Cart drawer: `cart-drawer`, `cart-open`, `cart-close`, `cart-items`, `cart-empty`, `cart-subtotal`
37+
- Cart page: `cart-page`, `cart-page-items`, `cart-page-empty`, `cart-page-footer`, `cart-page-subtotal`
38+
- Product: `product-form`, `option-value`, `thumbnail`, `add-to-cart`, `cart-status`
39+
- Collection: `collection-root`, `collection-controls`, `collection-products`, `collection-load-more`, `collection-quick-buy`
40+
- Search drawer: `search-drawer`, `search-open`, `search-close`, `search-drawer-input`, `search-drawer-groups`
41+
42+
## Local Validation
43+
44+
Run these before considering work complete:
45+
46+
```bash
47+
bun run typecheck
48+
bun run build
49+
```
50+
51+
If available in the environment:
52+
53+
```bash
54+
theme-check
55+
```
56+
57+
## Branch-Linked Shopify Reminder
58+
59+
For branches connected directly to a Shopify theme, generated assets must be committed:
60+
61+
- `assets/*`
62+
- `assets/.vite/manifest.json`
63+
- `snippets/vite-tag.liquid`
64+
65+
## Suggested Work Loop for AI
66+
67+
1. Read `CLAUDE.md`, `README.md`, and this file.
68+
2. Edit TS behavior and Liquid markup in their correct layers.
69+
3. Preserve `data-js` hooks unless intentionally migrating both TS + Liquid.
70+
4. Run typecheck/build.
71+
5. Update docs/todo when architecture contracts change.

CLAUDE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,29 @@ loading is handled exclusively by the layout.
5959
`ts/gift-card.ts` is the only exception: loaded directly in `templates/gift_card.liquid`
6060
because that template uses `{% layout none %}`.
6161

62+
## TS/Liquid contract
63+
64+
**TS logic only, Liquid markup only.**
65+
66+
- Keep behavior and state orchestration in TypeScript modules under `frontend/entrypoints/ts/**`
67+
- Keep editable markup in Liquid sections/snippets under `sections/**` and `snippets/**`
68+
- Treat `data-js` attributes as the integration contract between TS and Liquid
69+
- Do not move markup generation into TS string templates for cart/minicart/search flows
70+
6271
## When to add JS
6372

6473
- **Global bootstrap only**: `frontend/entrypoints/ts/theme.ts`
6574
- **Shared logic/utilities** (e.g. modal, DOM helpers): `frontend/entrypoints/ts/utils/*`
6675
- **Template-specific logic**: the matching entrypoint (e.g. `frontend/entrypoints/ts/product.ts`)
6776
- **Never create a new entrypoint** without also updating the router in `layout/theme.liquid`
6877

78+
Current interaction ownership:
79+
- `ts/theme.ts`: global cart drawer bootstrap
80+
- `ts/product.ts`: PDP variants/media/add-to-cart states
81+
- `ts/collection.ts`: PLP sort/filter progressive interactions
82+
- `ts/cart.ts`: cart page quantity/remove interactions
83+
- `ts/search.ts`: predictive search interactions
84+
6985
## Theme preview
7086

7187
### Prerequisites
@@ -160,6 +176,11 @@ Before merging to `staging` or `main`, ensure:
160176
- `bun run build` passes
161177
- `theme-check` passes
162178
- Smoke test the templates touched by the PR
179+
- Verify manual QA on touched templates (PDP, PLP, cart page, minicart as relevant)
180+
181+
CI enforces branch flow:
182+
- PR to `staging` must come from `feat/*`
183+
- PR to `main` must come from `staging`
163184

164185
## Troubleshooting
165186

@@ -186,6 +207,14 @@ Before merging to `staging` or `main`, ensure:
186207
2. Goal (what it should do)
187208
3. Approve the plan before execution
188209

210+
### Start feature branch
211+
212+
```bash
213+
git checkout staging
214+
git pull
215+
git checkout -b feat/<feature-name>
216+
```
217+
189218
### Naming conventions
190219

191220
- TS entrypoints: match the Shopify `request.page_type` value

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,21 @@
2525
- Shared utilities in `frontend/entrypoints/ts/utils/`
2626
- `typecheck` gate with `tsc --noEmit`
2727

28+
- Core storefront interactions
29+
- PDP variant/media/price synchronization + add-to-cart status handling
30+
- Cart drawer with keyboard accessibility, quantity/remove async flows, and fallback to `/cart`
31+
- Cart page async quantity/remove flows with empty/error states
32+
- Collection sorting, filtering, and progressive load-more behavior
33+
- Search predictive suggestions with graceful fallback to full search
34+
2835
- Branch-linked deploy workflow
2936
- Built assets are committed to branch for Shopify Git-connected themes
3037
- CI validates quality gates (`typecheck`, `vite:build`, `theme-check`)
3138

39+
- AI-ready contributor workflow
40+
- Generic agent guide in `AGENTS.md`
41+
- Architecture + conventions in `CLAUDE.md`
42+
3243
---
3344

3445
## Scripts
@@ -125,6 +136,29 @@
125136

126137
---
127138

139+
## Customization Contract
140+
141+
- Keep TS modules focused on behavior/state only.
142+
- Put DOM events, async flows, and state sync in `frontend/entrypoints/ts/**`.
143+
- Keep Liquid focused on markup/content structure only.
144+
- Put editable HTML structure in `sections/**` and `snippets/**`.
145+
- Treat `data-js="..."` attributes as a stable public contract between TS and Liquid.
146+
- You can restyle or rearrange markup as long as required `data-js` hooks remain intact.
147+
148+
- Search drawer safe customization points:
149+
- Layout container and spacing in `sections/search-drawer.liquid`
150+
- Result card markup inside `frontend/entrypoints/ts/search/drawer.ts` (`createResultItem`)
151+
- Group ordering/labels inside `frontend/entrypoints/ts/search/drawer.ts` (`renderGroups`)
152+
153+
- Stable `data-js` contracts by module:
154+
- Cart drawer: `cart-drawer`, `cart-open`, `cart-close`, `cart-items`, `cart-empty`, `cart-subtotal`
155+
- Cart page: `cart-page`, `cart-page-items`, `cart-page-empty`, `cart-page-footer`, `cart-page-subtotal`
156+
- Product: `product-form`, `option-value`, `thumbnail`, `add-to-cart`, `cart-status`
157+
- Collection: `collection-root`, `collection-controls`, `collection-products`, `collection-load-more`, `collection-quick-buy`
158+
- Search drawer: `search-drawer`, `search-open`, `search-close`, `search-drawer-input`, `search-drawer-groups`
159+
160+
---
161+
128162
## Environment Configuration
129163

130164
- `.env` (local, gitignored)
@@ -165,6 +199,51 @@ Flow:
165199
3. QA on staging theme
166200
4. Merge `staging` into `main`
167201

202+
Enforcement in CI:
203+
- PRs to `staging` must come from `feat/*`
204+
- PRs to `main` must come from `staging`
205+
206+
## Start a Feature Branch
207+
208+
```bash
209+
git checkout staging
210+
git pull
211+
git checkout -b feat/<short-feature-name>
212+
```
213+
214+
Before opening a PR, run local quality gates:
215+
216+
```bash
217+
bun run typecheck
218+
bun run build
219+
# Optional when installed locally
220+
theme-check
221+
```
222+
223+
If the branch is Shopify Git-connected, commit generated build artifacts:
224+
- `assets/*`
225+
- `assets/.vite/manifest.json`
226+
- `snippets/vite-tag.liquid`
227+
228+
---
229+
230+
## Alias Examples
231+
232+
Use path aliases from `vite.config.js` for cleaner imports:
233+
234+
```ts
235+
import { addToCart } from '@ts/utils/cart';
236+
import '@css/main.css';
237+
```
238+
239+
---
240+
241+
## Linting Strategy
242+
243+
- TypeScript quality gate: `bun run typecheck`
244+
- Liquid quality gate: Theme Check in CI (`Theme Check` job)
245+
- Local checks: `bun run typecheck` and `bun run build` (plus optional `theme-check`)
246+
168247
---
169248

170249
## Troubleshooting

0 commit comments

Comments
 (0)