Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .github/assets/react-fabrio-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 117 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: CI
on:
push:
pull_request:
workflow_dispatch:

permissions:
contents: read
Expand All @@ -22,5 +23,120 @@ jobs:
- run: pnpm react-doctor
- run: pnpm format:check
- run: pnpm typecheck
- run: pnpm test
- run: pnpm test:coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
- run: pnpm build
- run: node scripts/check-docs.mjs

e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
with:
node-version: 24
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm exec playwright install --with-deps chromium firefox webkit
- run: pnpm test:e2e
- uses: actions/upload-artifact@v6
if: failure()
with:
name: playwright-failures
path: |
test-results/
playwright-report/
retention-days: 7

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
with:
node-version: 24
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: node scripts/check-docs.mjs
- run: pnpm docs:build
- run: pnpm exec playwright install --with-deps chromium
- run: pnpm docs:test
- uses: actions/upload-pages-artifact@v4
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
with:
path: apps/docs/dist/client
- uses: actions/upload-artifact@v6
if: failure()
with:
name: docs-playwright-failures
path: apps/docs/test-results/
retention-days: 7

publish:
name: Publish npm packages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [validate, e2e, docs]
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: npm-release
cancel-in-progress: false
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
with:
node-version: 24
cache: pnpm
registry-url: https://registry.npmjs.org
- run: pnpm install --frozen-lockfile
- name: Build library packages
run: pnpm build:packages
- name: Publish packages and create GitHub release
run: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

deploy-docs:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
needs: [validate, e2e, docs]
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: github-pages
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/configure-pages@v5
- name: Deploy documentation
id: deployment
uses: actions/deploy-pages@v4
- name: Check public documentation
env:
SITE_URL: ${{ steps.deployment.outputs.page_url }}
run: |
node --input-type=module <<'JS'
const base = process.env.SITE_URL.replace(/\/$/, "");
for (const path of ["/", "/docs/agents/domain/", "/llms.txt", "/llms-full.txt", "/docs/content.md", "/api/search.json"]) {
const response = await fetch(`${base}${path}`);
if (!response.ok) throw new Error(`${path}: ${response.status}`);
const text = await response.text();
if (text.length < 100) throw new Error(`Empty documentation: ${path}`);
if (!path.endsWith("/") && /<!doctype html/i.test(text)) throw new Error(`HTML fallback: ${path}`);
}
JS
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ playwright-report
*.njsproj
*.sln
*.sw?

# Generated documentation artifacts
apps/docs/.source/
apps/docs/.tanstack/
9 changes: 8 additions & 1 deletion .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"ignorePatterns": ["**/dist/**", "**/coverage/**", "pnpm-lock.yaml"]
"ignorePatterns": [
"**/dist/**",
"**/coverage/**",
"pnpm-lock.yaml",
"**/.source/**",
"**/.tanstack/**",
"**/routeTree.gen.ts"
]
}
36 changes: 32 additions & 4 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["react", "typescript", "oxc", "jsx-a11y", "import"],
"categories": { "correctness": "error" },
"ignorePatterns": ["**/dist/**", "**/coverage/**", "**/node_modules/**"],
"categories": {
"correctness": "error"
},
"ignorePatterns": [
"**/dist/**",
"**/coverage/**",
"**/node_modules/**",
"**/.source/**",
"**/.tanstack/**",
"**/routeTree.gen.ts"
],
"rules": {
"react/rules-of-hooks": "error",
"react/exhaustive-deps": "error",
"no-unused-vars": "error",
"import/no-cycle": "error",
"no-async-promise-executor": "error",
"react/only-export-components": ["warn", { "allowConstantExport": true }]
}
"react/only-export-components": [
"warn",
{
"allowConstantExport": true
}
]
},
"overrides": [
{
"files": ["apps/docs/src/routes/**/*.{ts,tsx}"],
"rules": {
"react/only-export-components": [
"warn",
{
"allowConstantExport": true,
"allowExportNames": ["Route"]
}
]
}
}
]
}
20 changes: 20 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Agent skills

### Issue tracker

Issues live in GitHub Issues for `Imunal/react-fabrio`.
See `apps/docs/content/agents/issue-tracker.md` before reading or publishing tickets.

### Triage labels

Use the five default triage labels.
See `apps/docs/content/agents/triage-labels.md` when applying triage roles.

### Domain docs

Single-context: root `GLOSSARY.md` and `apps/docs/content/architecture.md`.
See `apps/docs/content/agents/domain.md` before exploring the codebase.

### Product and implementation

Before changing public contracts, editing UX, assets, previews, or production, follow the task-specific reading paths in `apps/docs/content/agents/domain.md`. Documentation starts at `apps/docs/content/index.md`.
33 changes: 33 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Contributing

Use Node and pnpm versions declared in [package.json](package.json). Install dependencies with `pnpm install`, then run `pnpm dev` for the playground.

## Workflow

Read the [glossary](GLOSSARY.md), [architecture](apps/docs/content/architecture.md), and [relevant domain references](apps/docs/content/index.md). Keep changes in the owning package and update the reference that defines the changed contract. Add meaningful behavior tests for document fidelity, permissions, output correctness or customer workflows; avoid tests that duplicate implementation details.

The playground imports the exported product fixtures. Change those fixtures rather than maintaining copied example configurations. Keep API examples aligned with emitted declaration files.

## Code and test style

Define functions with `const` and arrow syntax. Build JSON contracts with Zod, infer their types using `z.infer`, and derive JSON Schema exports using `z.toJSONSchema`.

Write straightforward tests with explicit `// given`, `// when`, and `// then` sections. Keep setup, the action and assertions separate. Split independent behaviors into separate tests; use `test.each` for input tables instead of loops with assertions. Keep fixtures small and avoid hiding the tested behavior behind helpers.

## Verification

Run `pnpm typecheck`, `pnpm test`, `pnpm test:e2e`, `pnpm lint`, `pnpm format:check`, `pnpm build`, and `pnpm react-doctor` before release preparation. Install the configured Playwright browsers with `pnpm exec playwright install --with-deps chromium firefox webkit`. The E2E projects cover desktop Chromium (`desktop`), Firefox (`desktop-firefox`), WebKit (`desktop-webkit`), Pixel 7 (`mobile`), iPhone 13 (`mobile-webkit`) and iPad (`tablet-webkit`). These device profiles are browser emulation, not physical devices. Run all projects with `pnpm test:e2e`, or select one with `pnpm test:e2e --project desktop-firefox`. Touch drag tests use Chromium CDP and are skipped on other engines; the remaining mobile flows also run on WebKit. A missing browser or unavailable network is an incomplete check, not a pass.

For production changes inspect dimensions, PNG physical resolution metadata, clipping and SVG contents. For document changes verify save/reopen and undo/redo. For UI changes verify keyboard access and desktop/mobile flows. Run `node scripts/check-docs.mjs` for Markdown relative links. `tests/integration.tsx` compiles the documented integration examples as part of typecheck. Check schema-valid examples whenever contracts change.

Documentation lives in `apps/docs/content/`; see [documentation maintenance](apps/docs/content/documentation.md) for navigation, static verification and Pages deployment.

## Package boundaries and release preparation

Core owns physical documents and domain rules. Fabric adapts interactions and generates production artifacts. React owns lifecycle and subscriptions. UI owns default controls. Three-dimensional visualization remains optional; see [architecture](apps/docs/content/architecture.md).

Build before packing. Inspect tarball exports, declarations, dependencies and CSS; consume packages outside the workspace to catch accidental source aliases. Retain React 19 peers and MIT licensing. Prepare release notes that name unavailable features and compatibility changes.

Pushes to `main` publish library packages automatically after all CI checks pass. The five packages share one version, determined by Conventional Commits. See [Releasing packages](apps/docs/content/releasing.md) for npm authentication, commit conventions and recovery. Run publication locally only when explicitly requested.

For tickets, follow [issue tracker instructions](apps/docs/content/agents/issue-tracker.md) and [triage roles](apps/docs/content/agents/triage-labels.md).
32 changes: 32 additions & 0 deletions GLOSSARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# React Fabrio domain

The language of personalizing printed and engraved products.

## Language

**Product**: A physical item offered for personalization, with a defined set of sides and decoration areas.

**Side**: A named view of a product, such as front or back, containing one or more decoration areas.

**Decoration area**: A physically measured region that accepts personalized content and produces a separate production artifact.
_Avoid_: Canvas, page, print zone.

**Template**: A reusable arrangement of elements with rules defining what a customer may change.

**Slot**: A labeled, editable position in a template for customer text or an image.

**Element**: A single positioned piece of text, an image, or vector artwork in a decoration area.
_Avoid_: Layer when referring to content rather than its stacking position.

**Design document**: The customer's editable personalization across all decoration areas of a product.

**Mockup**: A visual representation of personalized artwork on a product photograph or model.

**Production artifact**: A file containing artwork prepared for one decoration area's printing or engraving process.
_Avoid_: Preview, screenshot.

**Bleed**: Extra artwork outside the finished edge that accommodates variation during cutting or production.

**Safe margin**: An inset from the finished edge intended to protect important content from production variation.

**Effective DPI**: The source pixels available per physical inch of a placed image after cropping and scaling.
56 changes: 52 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,57 @@
# react-fabrio
# React Fabrio

A lightweight, open-source React library for building intuitive product customization experiences.
<p align="center">
<img src=".github/assets/react-fabrio-logo.png" alt="React Fabrio logo" width="720" />
</p>

See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, commands, current architecture, and package validation.
[![CI](https://github.com/Imunal/react-fabrio/actions/workflows/ci.yml/badge.svg)](https://github.com/Imunal/react-fabrio/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/Imunal/react-fabrio/branch/main/graph/badge.svg)](https://codecov.io/gh/Imunal/react-fabrio)

React Fabrio is a React library for building product personalization editors for print and engraving. Configure it for apparel, drinkware, accessories, gifts and other products with customizable decoration areas.

Customers can edit text, images and vector artwork, then preview their design. Fabrio exports PNG files for printing and SVG files for engraving. Use the included editor or build your own interface with the React components.

The packages are still in development and have not been published. Run the playground from this repository to try them.

## Get started

You need Node.js 24.11+ and pnpm 12.14.x.

```sh
pnpm install
pnpm dev
```

Open the URL printed in the terminal to try the playground.

## Project structure

```text
apps/
playground/ Demo application
docs/ Documentation site and Markdown sources
packages/
core/ Product definitions, design documents, validation and history
fabric/ Canvas editing and PNG/SVG output
react/ Providers, hooks and editor lifecycle
ui/ Default editor, controls and styles
three/ Optional 3D mug preview
tests/ Library tests and integration examples
e2e/ Browser tests for editor workflows
scripts/ Repository tools
```

Products define their sides, decoration areas and editing rules through configuration. Designs store geometry in millimeters, independently of the canvas or screen size. Editing, previews and production use the same design document.

The default UI can be replaced with custom React controls. The 3D preview is optional. Your application handles uploads, storage, pricing and checkout. See [architecture](apps/docs/content/architecture.md) for package boundaries.

## Documentation

- [Quick Start](apps/docs/content/quick-start.md)
- [React integration](apps/docs/content/integration.md)
- [Full documentation](apps/docs/content/index.md)
- [Contributing](CONTRIBUTING.md)

## License

MIT. See [LICENSE](LICENSE).
[MIT](LICENSE)
19 changes: 19 additions & 0 deletions apps/docs/content/agents/domain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: "Domain orientation"
description: "Domain vocabulary and task-specific reading paths."
---

This repository has one domain context. Before exploring code, read the root [glossary](../../../../GLOSSARY.md) and [architecture](../architecture.md). For document, output or preview work, also read the [design document](../design-document.md), [production](../production.md) or [previews](../previews.md) reference.

Use the glossary's vocabulary in code, tests, issues and documentation. Record domain terms there; keep implementation details in reference documents.

| Task | Read before changing |
| ------------------------------------- | ---------------------------------------------------------------------------- |
| Configuration, permissions, templates | [Configuration](../configuration.md), [product status](../product.md) |
| Persistence, migration, history | [Design document](../design-document.md), [architecture](../architecture.md) |
| React integration, callbacks | [Integration](../integration.md), [API](../api.md) |
| UI, keyboard access, localization | [Editor UX](../editor-ux.md) |
| Uploads, text, SVG import | [Assets and fonts](../assets-and-fonts.md) |
| Previews or production | [Previews](../previews.md), [production](../production.md) |

Update the authoritative reference when its contract changes. Check the actual exported types before copying an API example. Explicitly distinguish available behavior from planned behavior. If a proposal changes a documented architectural choice, identify that choice and explain the trade-off before replacing it.
Loading
Loading