Docs: bring CLAUDE.md, the transition roadmap and the README up to date

CLAUDE.md: localization now describes core's locale middleware,
$currentLocale/$altLocales and storefront.* Language Lines (there are
no lang/ files or SetLocale); the stack is Lunar 1.5, Postgres,
Meilisearch, Caddy, no Turbo; the design-reference section pointed at
files nobody has, and the component checklist was out of date.

CACHING-TRANSITION.md: records the 2026-11-06 changes (no Turbo, JSON
islands and writes, one bb_state cookie, prefetch instead of prerender),
a status table per task, the A4/A9 rework, and sources that the team
can actually reach.

README: known issues found while writing the boboko plugin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
lexxandClaude Opus 5.5 committed 2026-11-06 18:49:52 +02:00
1 parent f9b2756456
commit 81e70de70f
3 files changed
+114 -70

No files matched your search

+26 -45
View File
@@ -1,6 +1,10 @@
# Front-end Guidelines
This is a Laravel 12 e-commerce project using Lunar PHP (headless). These guidelines apply to all front-end work.
This is 3dealer.gr, a boboko shop: Laravel 12 + Lunar, on top of the shared `boboko/core` package. These guidelines apply to all front-end work.
> **These rules are moving into the `boboko` Claude Code plugin** (re-skills marketplace), so every boboko shop shares them. Once it's enabled here, this file keeps only 3dealer's own facts (Greek register, fonts, brand). Until then, this file is the reference.
>
> **Direction of the work in progress:** read [CACHING-TRANSITION.md](CACHING-TRANSITION.md) before touching catalogue pages, the header, the layout or any form.
---
@@ -16,35 +20,36 @@ ## Project Language Settings
## Localization
Uses classic Laravel localization (https://laravel.com/docs/13.x/localization) — no third-party i18n routing package.
**Locales** come from Lunar's languages table (the admin's **Languages** resource), not from config: Greek (`el`) is the default, English (`en`) is secondary. How it works: `vendor/boboko/core/docs/localization.md`.
**Locales:** Greek (`el`) is primary/default, English (`en`) is secondary. Set in `config('app.available_locales')` (`config/app.php`).
**URL structure:** every storefront route is prefixed with `{locale}`, including the default: `3dealer.gr/el/...` and `3dealer.gr/en/...`. A URL without a valid locale (including bare `/`) is redirected by core's `locale` middleware to the visitor's best `Accept-Language` match, else the default language. That redirect varies per visitor, so it must never be cached. Prefixing every locale keeps hreflang symmetrical and scales cleanly to a third language.
**URL structure:** every route is prefixed with `{locale}`, including the default — `3dealer.gr/el/...` and `3dealer.gr/en/...`. Bare root (`/`) 301-redirects to `/el` (see `routes/web.php`). This avoids the ambiguity of an unprefixed default locale (see the reasoning in project memory / past conversation — prefixing every locale keeps hreflang symmetrical and scales cleanly to a third language later).
**URL slugs are the same across both locales, permanently** — e.g. `/el/products/{x}` and `/en/products/{x}`, not `/el/proionta/{x}` vs `/en/products/{x}`. This is a deliberate, standing decision for this project, not a placeholder to revisit later. Only the visible content is translated, not the slug. Do not introduce per-locale translated slugs (e.g. a `lang/{locale}/routes.php` segment map) unless the user explicitly asks for that to change.
**URL slugs are the same across both locales, permanently**: `/el/products/{x}` and `/en/products/{x}`, not `/el/proionta/{x}` vs `/en/products/{x}`. This is a deliberate, standing decision, not a placeholder to revisit later. Only the visible content is translated, not the slug. Do not introduce per-locale translated slugs unless the user explicitly asks for that to change. (Catalogue URLs are moving to id + ASCII slug, `/el/products/123-blue-vase`, once core supports it; until then they use bare ids.)
**How it's wired:**
- All routes live inside `Route::prefix('{locale}')->where('locale', ...)->middleware('setlocale')` in `routes/web.php`.
- `App\Http\Middleware\SetLocale` validates the `{locale}` segment (404s if not in `available_locales`), calls `App::setLocale()`, and shares `$currentLocale`, `$altLocale`, and `$altLocaleUrl` (the same page in the other locale) to every view — this is what powers both the header's language switcher and the `<head>` hreflang tags in `resources/views/layouts/app.blade.php`. Don't recompute this logic elsewhere; read those shared variables instead.
- When adding a new route, put it inside that `{locale}` group and give it a route `name()` — the alt-locale URL generation in the middleware depends on the current route being named (falls back to the locale root if unnamed).
- When linking to a page in Blade, prefer `route('name', [...])` (locale is a normal route param, defaults to `app()->getLocale()` implicitly via the shared route group) over hand-built path strings, except for pages that don't have a controller/route yet (e.g. `/products`, `/contact`, `/cart` placeholders in the header currently use `url('/'.app()->getLocale().'/products')` — replace with `route()` once those pages exist).
- **Every controller action for a route inside the `{locale}` group must declare `$locale` as its first parameter, even if unused** — e.g. `show(string $locale, Product $product)`. Laravel's `ControllerDispatcher` ultimately calls the controller with `...array_values($parameters)`, i.e. **positionally**. If a route-bound model parameter (like `$product`) isn't preceded by a matching `$locale` parameter in the method signature, the resolved values shift out of position and the wrong value (the locale string) gets passed where the model was expected — a `TypeError` that's easy to misread as a binding failure. Closures with zero declared parameters are unaffected (PHP just ignores the extra positional arg), so this only bites real controller methods.
- Storefront routes live inside `Route::prefix('{locale}')->middleware('locale')` in `routes/web.php`. `locale` is core's `Modules\Core\Localization\Middleware\LocaleMiddleware`.
- The middleware sets the app locale and shares `$currentLocale` (e.g. `el`) and `$altLocales` (a collection of every *other* language: `code`, `name`, `url` of the same page) with every view. That's what powers the header's language switcher and the `<head>` hreflang tags in `resources/views/layouts/app.blade.php`. Don't recompute this; read those shared variables.
- When adding a new route, put it inside that `{locale}` group and give it a `name()`: the alternate-language URLs are generated from the current route's name (an unnamed route falls back to the other language's home page).
- When linking in Blade, use `route('name', [...])`, never hand-built paths. Inside the group the locale is filled in automatically.
- **Every controller action for a route inside the `{locale}` group must declare `$locale` as its first parameter, even if unused**, e.g. `show(string $locale, Product $product)`. Laravel's `ControllerDispatcher` calls the controller with `...array_values($parameters)`, i.e. **positionally**. If a route-bound model parameter (like `$product`) isn't preceded by a matching `$locale` parameter, the values shift and the locale string lands where the model was expected: a `TypeError` that's easy to misread as a binding failure. Closures with zero declared parameters are unaffected, so this only bites real controller methods.
**Where translatable strings go:**
- Most UI copy is editable by the client/marketing team via **Stoic** (the headless CMS) — don't hardcode it here.
- Small strings that don't need client editing (nav labels, aria-labels, tab labels, pluralized counts) go in Laravel's own lang files at **`lang/{locale}/*.php`** (project root, per Laravel 12+ convention — not `resources/lang`). Current file: `lang/el/general.php` / `lang/en/general.php`. Use `__('general.key')` or `trans_choice('general.key', $count, [...])` for pluralized strings.
- Page copy the client edits (home sections, FAQ, legal pages) comes from **Stoic** (the headless CMS). Don't hardcode it.
- UI labels (nav, buttons, aria-labels, tab labels, pluralized counts) are **`__('storefront.key')`** keys stored in the database as **Language Lines** (`spatie/laravel-translation-loader` through boboko/core), editable in the admin (Settings → Language Lines). Use `trans_choice('storefront.key', $count, [...])` for plurals. **Never add `lang/` files** for storefront strings.
- The defaults ship with core (`StorefrontTranslationsSeeder`). A key you add in the admin must also get into core's seeder (`php artisan boboko:translations:pull` in local mode; `bin/deploy` checks this), or other environments show the raw key.
---
## Tech Stack
- **Laravel 12** + **Lunar PHP 1.3** (headless e-commerce)
- **Laravel 12** (moving to 13) + **Lunar 1.5** through `boboko/core` (exact versions: core's `composer.json`)
- **Postgres**, **Meilisearch** (catalogue and search), **Docker**, **Caddy** in front of PHP-FPM
- **Blade** for templating (`@extends`, `@section`, `@yield`, components)
- **Tailwind CSS v4** via `@tailwindcss/vite` — zero config, `@import 'tailwindcss'` only
- **Stimulus JS** for interactivity — controllers registered in `resources/js/stimulus/index.js`
- **Stimulus JS** for interactivity — controllers registered in `resources/js/stimulus/index.js`; core's controllers come from `@boboko/core` (`registerCheckout`, `registerWishlist` in `app.js`), never copied
- **No Turbo.** Normal page navigation, plus Speculation Rules and View Transitions. Turbo is still installed and used in places (listing/search Frames, review Streams); don't add to it, and replace it when you rework that code (see CACHING-TRANSITION.md)
- **Popover API** (native browser) for overlays — no JS overlay libraries
- SQLite database, `npm run dev` for local asset compilation
- Local dev runs in Docker (`bin/dc`, or `bin/dc-core.sh` with a local boboko-core checkout: see `bin/core-mode`)
---
@@ -65,14 +70,6 @@ ## Key File Locations
---
## Design Reference
The Bluebeard template (`resources/css/bluebeard.css`) is used as a **reference only** for colors, spacing, typography, and effects. It is never imported or used directly. Everything is translated to Tailwind utilities or custom CSS where unavoidable.
The boboko project at `/Users/farenoubi/Projects/boboko-test` can be referenced for CSS architecture patterns.
---
## Tailwind vs. Custom CSS
**Prefer Tailwind utilities by default.** Write custom CSS only when something genuinely cannot be expressed as a utility:
@@ -103,31 +100,15 @@ ## Design Tokens
## Component Structure
### `resources/views/components/ui/` — atomic, reusable UI elements
### `resources/views/components/ui/`: atomic, reusable UI elements
Single-purpose, stateless or minimally stateful elements used across many contexts:
Single-purpose, stateless or minimally stateful elements used across many contexts: button, input, field, icon, badge, tabs, dropdown, pagination…
- `button.blade.php` ✓
- `input.blade.php`
- `input-group.blade.php`
- `icon.blade.php`
- `image.blade.php`
- `tabs.blade.php` / `tab.blade.php`
- `accordion.blade.php`
- `tooltip.blade.php`
- `badge.blade.php`
- etc.
### `resources/views/components/`: section-level or composite components
### `resources/views/components/` — section-level or composite components
Larger reusable blocks made of several elements, often with real content: header, footer, product card, review form…
Larger reusable blocks made of several elements, often with real content:
- `header.blade.php` ✓
- `footer.blade.php`
- `cta.blade.php`
- `product-card.blade.php`
- `contact-section.blade.php`
- etc.
**Check before you create.** Look in `components/ui/` and in core's views (`vendor/boboko/core/resources/views`) first, and extend an existing component with a prop rather than duplicating it.
---