Initial Commit
This commit is contained in:
74
openspec/changes/enterprise-react-image/proposal.md
Normal file
74
openspec/changes/enterprise-react-image/proposal.md
Normal file
@@ -0,0 +1,74 @@
|
||||
# OpenSpec Change: enterprise-react-image
|
||||
|
||||
- **Change ID**: enterprise-react-image
|
||||
- **Package**: `@suaveplan/react-image`
|
||||
- **Category**: react
|
||||
- **Target path**: `react/media/react-image`
|
||||
- **Status**: PROPOSED
|
||||
- **Date**: 2026-04-24
|
||||
- **Reference spec**: `/mnt/s/web/suaveplan/enterprise/react-image.md`
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
Deliver `@suaveplan/react-image` on genesis from scratch at enterprise quality. Zero-external-runtime React image UI library: base `Image` (lazy, blurhash, skeleton, srcSet), `Avatar`/`AvatarGroup` (initials fallback, status), `ImageComparison` (slider), `ImageCropper` (drag handles), `ImageFilter` (CSS filter presets), `ImageGallery` (masonry), `ImageMagnifier`, `ImageOverlay`, `ImagePlaceholder`, `Lightbox` (thumbnails, controls), `ZoomImage`. Supporting hooks: `useImageLoader`, `useImagePreloader`, `useImageDimensions`, `useImageColor`, `useLightbox`. Utils: `blurhashToDataURL`, `decodeBlurhash`, `getFilterCSS`.
|
||||
|
||||
---
|
||||
|
||||
## Current-state audit (genesis)
|
||||
|
||||
Package does not exist on genesis — fresh build.
|
||||
|
||||
---
|
||||
|
||||
## Available workspace deps on genesis
|
||||
|
||||
| Package | Role |
|
||||
|---|---|
|
||||
| `@suaveplan/error` (`workspace:^`) | `ImageError` |
|
||||
| `@suaveplan/react-translate` (`workspace:^`) | i18n |
|
||||
| `zod` (`catalog:forms`) | Image config schemas |
|
||||
| `@opentelemetry/api` (`catalog:observability`) | `image.load` span |
|
||||
|
||||
External: `tslib catalog:build`. React 18 peer.
|
||||
|
||||
---
|
||||
|
||||
## Public API surface
|
||||
|
||||
11 components, 5 hooks, 3 utils — all listed in Summary above.
|
||||
|
||||
---
|
||||
|
||||
## New additions for genesis
|
||||
|
||||
1. **`ImageError`** — codes: `IMAGE_LOAD_FAILED`, `IMAGE_DECODE_FAILED`, `IMAGE_CROP_INVALID`.
|
||||
2. **OTel `image.load` span** — attributes: `image.src`, `image.format`.
|
||||
3. **Stories** — every component with default, loading, error, interactive, playground.
|
||||
4. **Playwright E2E** — `Image` lazy-loads on scroll; `ImageCropper` drag handles; `Lightbox` keyboard navigation.
|
||||
|
||||
---
|
||||
|
||||
## File layout
|
||||
|
||||
```text
|
||||
react/media/react-image/
|
||||
package.json
|
||||
tsconfig.json
|
||||
vitest.config.ts
|
||||
src/
|
||||
index.ts
|
||||
components/
|
||||
image/ avatar/ image-comparison/ image-cropper/
|
||||
image-filter/ image-gallery/ image-magnifier/
|
||||
image-overlay/ image-placeholder/ lightbox/ zoom-image/
|
||||
hooks/
|
||||
use-image-loader/ use-image-preloader/ use-image-dimensions/
|
||||
use-image-color/ use-lightbox/
|
||||
utils/
|
||||
blurhash/ filter-presets/
|
||||
types/
|
||||
e2e/
|
||||
image.spec.ts
|
||||
```
|
||||
82
openspec/changes/enterprise-react-image/tasks.md
Normal file
82
openspec/changes/enterprise-react-image/tasks.md
Normal file
@@ -0,0 +1,82 @@
|
||||
# Tasks: enterprise-react-image
|
||||
|
||||
**Change ID**: enterprise-react-image
|
||||
**Package**: `@suaveplan/react-image`
|
||||
**Target path**: `react/media/react-image`
|
||||
**Prerequisite packages on Verdaccio**: `@suaveplan/error`, `@suaveplan/react-translate`
|
||||
|
||||
---
|
||||
|
||||
## 0. Pre-flight (non-negotiable)
|
||||
|
||||
- [ ] 0.1 Confirm clean working tree (`git status` reports nothing) and no in-flight worktrees with uncommitted work (`git worktree list` then `git status` in each)
|
||||
- [ ] 0.2 If any worktrees exist under `.claude/worktrees/`, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (`git worktree remove`) before opening a new one — code that has been lost twice on main is the failure mode this guards against.
|
||||
- [ ] 0.3 Confirm the package set in `MANIFEST.md` matches `find packages -maxdepth 3 -name package.json` count. Drift here means a prior change archived without regenerating the manifest.
|
||||
|
||||
## 1. Scaffold
|
||||
|
||||
- [ ] Create directory tree per proposal layout.
|
||||
- [ ] Write `package.json` at `0.1.0` with `"sideEffects": false`, exports map.
|
||||
- [ ] Dependencies: `@suaveplan/error workspace:^`, `@suaveplan/react-translate workspace:^`, `zod catalog:forms`, `@opentelemetry/api catalog:observability`, `tslib catalog:build`.
|
||||
- [ ] Write `tsconfig.json`, `vitest.config.ts`, scripts.
|
||||
|
||||
---
|
||||
|
||||
## 2. Error codes and types
|
||||
|
||||
- [ ] Define `ImageError` extending `SuaveplanError`; codes: `IMAGE_LOAD_FAILED`, `IMAGE_DECODE_FAILED`, `IMAGE_CROP_INVALID`.
|
||||
- [ ] Define all component prop types in `src/types/`.
|
||||
|
||||
---
|
||||
|
||||
## 3. Utils
|
||||
|
||||
- [ ] `src/utils/blurhash/` — `decodeBlurhash(hash, width, height): Uint8ClampedArray`, `blurhashToDataURL(hash, width, height): string`. Write test + md.
|
||||
- [ ] `src/utils/filter-presets/` — `getFilterCSS(preset: FilterPreset): string` (grayscale, sepia, blur, brightness, contrast, invert). Write test + md.
|
||||
|
||||
---
|
||||
|
||||
## 4. Hooks
|
||||
|
||||
For each hook (`useImageLoader`, `useImagePreloader`, `useImageDimensions`, `useImageColor`, `useLightbox`):
|
||||
|
||||
- [ ] Implement hook. `useImageLoader` emits OTel `image.load` span. Throws `ImageError` on failure.
|
||||
- [ ] Write test (≤500 lines) + stories (playground) + md. `{ timeout: 10000 }`.
|
||||
|
||||
---
|
||||
|
||||
## 5. Components
|
||||
|
||||
For each component:
|
||||
|
||||
- [ ] Implement with i18n via `useTranslation`, forward ref, a11y attributes.
|
||||
- [ ] **Image** — lazy loading via `IntersectionObserver`, blurhash placeholder, skeleton fallback, `srcSet`.
|
||||
- [ ] **Avatar/AvatarGroup** — initials fallback, status indicator (online/offline/busy/away), group overlap.
|
||||
- [ ] **ImageComparison** — draggable split slider; keyboard adjustable.
|
||||
- [ ] **ImageCropper** — drag-handle crop selection; validates bounds (throws `ImageError(IMAGE_CROP_INVALID)` on invalid).
|
||||
- [ ] **ImageFilter** — CSS filter presets via `getFilterCSS`; preview toggle.
|
||||
- [ ] **ImageGallery** — masonry layout via CSS columns or absolute positioning.
|
||||
- [ ] **ImageMagnifier** — hover-activated lens at configurable zoom level.
|
||||
- [ ] **ImageOverlay** — gradient/reveal overlay wrapper.
|
||||
- [ ] **ImagePlaceholder** — SVG with `aria-label`.
|
||||
- [ ] **Lightbox** — portal-rendered; keyboard nav (Left/Right/Esc); thumbnails; close on backdrop.
|
||||
- [ ] **ZoomImage** — pinch-to-zoom (touch) + wheel-zoom; pan when zoomed.
|
||||
- [ ] Write test + stories (default, loading, error, interactive, playground) + md for each.
|
||||
|
||||
---
|
||||
|
||||
## 6. E2E
|
||||
|
||||
- [ ] `e2e/image.spec.ts` — Playwright:
|
||||
- `Image` with lazy-load: scroll into view → `img` src set.
|
||||
- `ImageCropper` drag: drag handle, verify crop rect changes.
|
||||
- `Lightbox`: click image → lightbox opens; press Right → next image; press Esc → closes.
|
||||
|
||||
---
|
||||
|
||||
## 7. Verify and publish
|
||||
|
||||
- [ ] `bunx turbo lint typecheck test --filter=@suaveplan/react-image` — green.
|
||||
- [ ] `bunx turbo test:coverage --filter=@suaveplan/react-image` — 100%.
|
||||
- [ ] `bun scripts/publish.ts --package @suaveplan/react-image`.
|
||||
- [ ] Archive change folder.
|
||||
Reference in New Issue
Block a user