# Admin interface

The admin is built on [Tabler](https://tabler.io) 1.7.5, compiled from its Sass sources with Vite. SyncSHOP's look comes from design tokens, not from component CSS, so a Tabler upgrade or a rebrand is a change to a few variables. The design rules are in `_docs/design/DESIGN.md`.

## Building

```bash
npm install
npm run build      # or `npm run dev` while working on styles
```

Fonts (Inter, JetBrains Mono) are self-hosted from `packages/core/resources/fonts`. Nothing is loaded from Google Fonts or any other CDN, and a test fails if a stylesheet, script or view links to another server.

## Where the styles live

| File | What it holds |
|---|---|
| `packages/core/resources/scss/admin/admin.scss` | Entry point: fonts, then tokens, then Tabler configured with `@use '@tabler/core/scss/tabler' with (…)`, then the overrides |
| `packages/core/resources/scss/admin/_syncshop-variables.scss` | The design tokens: palette and roles for light and dark. Declares values only |
| `packages/core/resources/scss/admin/_syncshop-admin.scss` | The only override file. Tabler builds its surfaces from its own grey ramp, so the page, surface, text, border, link and focus roles are set here as `light-dark()` custom properties, along with the sidebar frame |
| `packages/core/resources/scss/admin/_syncshop-fonts.scss` | `@font-face` rules |

Don't write hex values or component CSS in Blade, and don't edit files under `node_modules`. If a variable can't express something, add a token.

## Light and dark

The theme follows the system setting until someone picks Light or Dark in the header; the choice is kept in the browser (`localStorage`, key `ss-theme`). Both themes are designed: dark uses lighter surfaces and borders instead of shadows.

## Components

Screens are built from Blade components rather than hand-written markup:

| Component | Use |
|---|---|
| `<x-layouts.admin :title>` | The page: frame, header, title, `breadcrumbs` and `actions` slots |
| `<x-form.field>` | Label, input/select/textarea, help and error, wired for screen readers; `prefix`/`suffix` for units such as `lei` |
| `<x-form.checkbox>`, `<x-form.switch>` | Checkbox and on/off setting; an unticked box still submits `0` |
| `<x-status-badge tone>` | A status with an icon and a word (`success`, `warning`, `danger`, `info`, `pending`, `primary`, `accent`, `neutral`) |
| `<x-empty-state>` | Empty list: first run with an action, or "nothing matches" |
| `<x-filter-bar>`, `<x-list-footer>` | List filters, the range shown, rows per page and page links |
| `<x-delete-button>` | Delete through the shared confirmation; the button repeats the consequence |
| `<x-breadcrumbs>`, `<x-icon>` | Breadcrumbs and inline icons |

In development, `/admin/kit` shows every component with sample data. The page doesn't exist in production.

## Icons

Icons are [Tabler Icons](https://tabler.io/icons) (MIT) plus SyncSHOP's own `ss-*` set, rendered inline with `<x-icon name="truck" />`. To use a new icon, add its name to `packages/core/resources/icons/manifest.json` and run:

```bash
npm run assets
```

The script copies the listed icons into `packages/core/resources/icons`, and the admin's logo and favicons into `public/syncshop`, without embedded metadata. Its output is committed, so production doesn't need Node.

## Admin menu

Modules add their sidebar entries in their service provider through `SyncShop\Modules\Platform\Contracts\AdminMenu`:

```php
$this->app->make(AdminMenu::class)->add(new MenuItem(
    label: 'orders.menu.title',
    route: 'admin.orders.index',
    icon: 'shopping-cart',
    active: 'admin.orders.*',
    order: 20,
));
```
