Repository navigation
docs(react): rebuild the React docs around the plane hooks - #248
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1f822941e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
a1f8229 to
3fc7e3f
Compare
3fc7e3f to
f35e674
Compare
0552531 to
c04b068
Compare
…247) ## Stack Context First of three PRs that cut `color-kit/react` down to state utilities and performance primitives (#247 → #248 → #249). This one sits on #246 (`docs/syntax-colors`) and is additive: the new hooks land next to the existing components, which now delegate to them. ## What? New headless hooks. They own no DOM and take one plane, `ColorPlaneSpec = { color, axes? }`, where `axes` is the driver's `ColorAreaAxes`. - **`useColorPlaneRenderer(plane, options)`** is the `ColorPlane` rasterizer reshaped into a hook. - It keeps the WebGL path, the CPU fallback, the context-loss / restore handling and GPU cleanup on unmount. - It keeps the render-key dedupe (moving along an axis channel does not repaint), the DPR × `resolutionScale` × quality-scaled backing store, and rAF + `ResizeObserver` redraws. - It returns a stable callback `ref`, a `canvasKey` and the active `renderer`. The caller must use `canvasKey` as the canvas `key`: a canvas is locked to its first context kind, so the GPU ↔ CPU swap needs a fresh element. The hook warns once if the key is dropped. - **Geometry hooks** return memoized points plus `toSvgPath` / `toSvgCompoundPath` data for a `0 0 100 100` viewBox. They keep the layers' sync-at-rest / worker-while-dragging behaviour. - `useGamutBoundary` and `useChromaBand`. `useChromaBand` takes core's `ChromaBandMode`: `'clamped'` / `'proportional'`. - `useContrastRegion` returns `path` (contours) and `fillPath` (closed fill polygons). It keeps frozen drag sampling, the stable-fill fallback, the boundary snapping and closure, and `onMetrics`. Its non-rendering geometry moved out of `contrast-region-layer.tsx` into `contrast-region-geometry.ts`. - `useFallbackPoints` returns the sRGB and Display P3 fallback points. - **`useAdaptiveQuality(profile)`** is `ColorArea`'s frame-cost quality controller, extracted. - `ColorPlane` and `ColorArea` now run on `useColorPlaneRenderer` and `useAdaptiveQuality`, so the existing component tests cover the hooks too. - New tests: `use-color-plane-renderer.test.tsx` and `plane-geometry-hooks.test.tsx` (39 cases). They port the WebGL lifecycle, CPU fallback and edge-behaviour cases, and the contrast fill-side, APCA polarity, sampling and worker-metrics cases. - A changeset (`'color-kit': minor`) for the new hooks. ## Why? Approved API reduction: `color-kit/react` keeps state and perf primitives, and UI components go. Landing the hooks first keeps every step green and lets #249 delete the components without losing the renderer or the overlay math. ## Validation - `pnpm lint`, `pnpm build` (including DTS and the docs build), `pnpm test` (core 921, driver 157, react 256, docs 938), `pnpm format:check`, `pnpm agents:check:strict`, `pnpm check:preprod` and `pnpm --filter @color-kit/docs typecheck` all pass. - `eval-dependencies.test.ts` passes locally on macOS. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Rewrite the color-kit/react narrative, the React guide and the examples so they build pickers from the hooks and plain elements instead of the ColorArea/ColorSlider/ColorStringInput components: - plane-picker.tsx: a canvas painted by useColorPlaneRenderer, an SVG with useGamutBoundary overlays and a role="slider" thumb, with pointer input through the driver's createPointerDragController and keyboard/ARIA from colorFromColorAreaKey and getColorAreaValueText. useAdaptiveQuality feeds the renderer and overlays. - contrast-region.tsx and color-provider.tsx reuse PlanePicker; channel-inputs.tsx (in the guide) shows native range inputs and a text field built on the driver's string helpers. - New symbol notes for useColorPlaneRenderer and useContrastRegion; drop the component notes. Mention control-kit's Plane/Slider as an optional host. - Retarget the drag profiling scripts to the hook-based example (profile:plane-picker, test:plane-picker-drag) and update entry summaries and guide cross-references. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- PlanePicker follows only the pointer that started the drag, so a second finger can neither restart, move nor end it. - Disabling it mid-drag cancels the drag controller and drops pending updates; commits are ignored while disabled. - The thumb is painted with the state's displayed color (new 'displayed' prop), so the sRGB preview applies to it too. - aria-valuemin/aria-valuemax use the smaller and larger end of the x range, so descending axes stay valid. - Native range inputs report interaction 'keyboard' for key changes and 'pointer' for drags instead of always 'pointer'. - The /api/react overview says which hooks return paths (boundary, band, contrast region), points (fallback points) or a canvas handle (renderer), and scopes 'renders no elements' to the hooks, not the whole package. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The PlanePicker fixes pushed the /api/react page chunk past the docs bundle budget (202.6 kB of 200 kB). The controlled Color example now lives in the guide's Controlled section, and the API page links to it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
f35e674 to
2b8114f
Compare
|
Deployment failed for project color-kit with the following error: Learn More: https://vercel.com/pbrooms-projects?upgradeToPro=build-rate-limit |
…ly (#249) ## Stack Context Third of three (#247 → #248 → #249). Sits on #248. The hooks (#247) and the docs (#248) are already in place, so this PR only removes code. ## What? `color-kit/react` now exports state hooks and plane hooks only. - **Removed outright (not moved to another package):** `ColorArea`, `Thumb`, `ColorPlane`, `OutOfGamutLayer`, `Layer`, `Background`, `Line`, `Point`, `GamutBoundaryLayer`, `ChromaBandLayer`, `ContrastRegionLayer` / `ContrastRegionFill`, `FallbackPointsLayer`, `ColorSlider`, `SliderMarker`, `ChromaMarkers`, `ColorStringInput` and `ColorInput`. Their props and metrics types, their tests, and the internal helpers only they used (`assign-ref`, `use-focus-visible`, `use-measured-element-size`) go too. - **Dependencies:** - Dropped the optional `@color-kit/control-kit` peer and dev dependency, the `./color-input` subpath and its tsup entry, and the `onlyBuiltDependencies` allowance. - Dropped the dev dependencies no longer used, `axe-core` and `@testing-library/user-event`. - The lockfile update is removals only: 75 packages, control-kit and its radix tree. - **Renames (hard cut-over):** - `ColorAreaPerformanceProfile` → `ColorPlanePerformanceProfile`; `ColorAreaQualityLevel` → `ColorPlaneQualityLevel`. - `ColorPlaneRenderer` loses the deprecated `'canvas2d'` alias. - The root re-exports only the driver types used by the remaining signatures. - **Facade:** `build.mjs` no longer excludes the color-input files. `check-artifacts.mjs` drops the color-input guard. `test-exports.mjs` asserts the hooks exist (ESM and CJS) and the removed components stay absent. - **Size limits:** new `.size-limit.json` budgets for `color-kit/react` imports: - `Color + useColor`: 19.1 kB, budget 20 kB. - `useColorPlaneRenderer`: 16.1 kB, budget 17 kB. - The geometry hooks: 38.1 kB, budget 40 kB. - **Benches:** `color-area-interaction-bench` becomes `plane-interaction-bench` (`bench:plane-interaction`); the README is updated. The renderer bench is unchanged. - **Docs and repo text:** - README, the facade README, DESIGN §4–§5 and §8, and the backlog: IB-012 is closed as superseded, and the open `ContrastRegionLayer` follow-up now points at `useContrastRegion`. - Wording in driver doc comments (no API change). - The docs config (`@color-kit/react/color-input` alias, stale domain aliases) and the declarations test now cover `Color`, the hooks and `ColorContext`. - **Changeset:** `'color-kit': minor`, written as a breaking change per the pre-1.0 convention, with migration notes. **Export count:** 105 root exports (24 values) plus the `color-input` subpath on the base, down to 60 (13 values). ## Why? Approved decision: `color-kit/react` keeps state utilities and performance primitives. Generic UI controls are not color-specific; apps compose the hooks with their own elements or with control-kit, which has no color math and no color-kit dependency. Pre-1.0, so this is a hard cut-over. ## Validation - `pnpm lint`, `pnpm build` (including DTS), `pnpm test` (core 921, driver 157, react 104, docs 906), `pnpm format:check`, `pnpm agents:check:strict`, `pnpm --filter @color-kit/docs typecheck`, `pnpm check:preprod`, `pnpm size` and `pnpm check:artifacts:metadata` (publint + attw) all pass. - The browser check from #248 was repeated on this branch's production build. The `/api/react` picker drags continuously, the arrow keys step it, and `/guides/react` works, with no console errors. 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Stack Context
Second of three (#247 → #248 → #249). Sits on #247, which adds the hooks. The docs move off the components before #249 removes them, so each PR builds on its own.
What?
The React docs now build pickers from the hooks and plain elements.
examples/react/plane-picker.tsxexports a reusablePlanePicker:<canvas>painted byuseColorPlaneRenderer.<svg viewBox="0 0 100 100">overlay drawn through a render prop. The demo draws twouseGamutBoundaryedges.role="slider"thumb. Pointer input goes through the driver'screatePointerDragControllerwithnormalizeColorAreaPointerandcolorFromColorAreaPosition. Keyboard and ARIA come fromcolorFromColorAreaKeyandgetColorAreaValueText.useAdaptiveQualityfeeds the renderer and the overlays.contrast-region.tsxandcolor-provider.tsx(controlled) reusePlanePicker.channel-inputs.tsx(on the guide page) shows native range inputs withgetSliderGradientStylesrails, and a text field built on the driver's string helpers.color-area.tsx,color-slider.tsxandcolor-string-input.tsxare removed./api/reactand/guides/react.useColorPlaneRendereranduseContrastRegion; the component notes are removed.Plane/Slideras an optional host, without depending on it.profile:plane-pickerandtest:plane-picker-drag, and use the[data-picker-area]/[data-picker-thumb]selectors.Why?
The components go away in #249. The docs must show the supported way to build a picker: hooks for rendering and geometry, the driver for input math, and your own elements.
Validation
pnpm lint,pnpm build(including DTS and the docs bundle budget),pnpm test(core 921, driver 157, react 256, docs 949),pnpm format:check,pnpm agents:check:strict,pnpm check:preprodandpnpm --filter @color-kit/docs typecheckall pass./api/reactchunk stays under the 200 kB budget. It is 187 kB.vite preview,/api/reactand/guides/reactrender the canvas and the overlays.🤖 Generated with Claude Code