Skip to content

refactor(react)!: remove UI components; ship state and plane hooks only - #249

Merged
pbroom merged 2 commits into
mainfrom
refactor/react-remove-ui-components
Oct 10, 2026
Merged

pbroom merged 2 commits into
mainfrom
refactor/react-remove-ui-components

Conversation

@pbroom

@pbroom pbroom commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

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 docs(react): rebuild the React docs around the plane hooks #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

@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
color-kit Ready Ready Preview Oct 10, 2026 2:57am UTC

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T02:52:01.422877Z ed32792 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This was referenced Oct 9, 2026

pbroom commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ed327922fd

ℹ️ 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".

Comment thread .changeset/react-hooks-only.md
@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[High impact] Removes all UI components from the React package.

The PR appears safe to merge, with a non-blocking fix needed for the public provider example.

Summary

color-kit/react now keeps color state and plane hooks while removing its UI components.

  • React no longer renders the color area, plane, and overlay components.
  • React no longer renders color sliders or their markers.
  • React no longer ships its text inputs or the color-input subpath.
  • React apps now compose picker UI from state and plane hooks.

pbroom explicitly intends the component and subpath removals. The contrast-reference mapping issue is recorded by pbroom as an existing follow-up.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  State["Color / useColor"] --> Plane["Plane specification"]
  Plane --> Renderer["useColorPlaneRenderer"]
  Plane --> Geometry["Geometry hooks"]
  Renderer --> Canvas["Caller-owned canvas"]
  Geometry --> SVG["Caller-owned SVG"]
  Driver["color-kit/driver"] --> Input["Caller-owned input handlers"]
  Input --> State
Loading

Reviews (1) · Last reviewed commit: "refactor(react)!: remove UI components; ..." · Reviewed by Greptile

@greptile-apps

greptile-apps Bot commented Oct 9, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P2 Provider example stops compiling packages/react/src/color-area.tsx:285 ▶

    Removing these components leaves the public Color example in packages/react/src/color.tsx importing and rendering ColorArea, ColorSlider and ColorStringInput. The generated API reference includes that example, so readers who copy it now get missing-export errors. Replace it with a provider example built from the retained hooks and native elements.

pbroom added a commit that referenced this pull request Oct 10, 2026
ColorPlane still accepts the deprecated alias at runtime, so its exported
ColorPlaneRenderer type keeps it too; only the new hook's option type is
narrower. Dropping the alias stays with the component removal (#249) and
its breaking changeset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pbroom
pbroom force-pushed the docs/react-hooks-guide branch from a1f8229 to 3fc7e3f Compare October 10, 2026 02:12
@pbroom
pbroom force-pushed the refactor/react-remove-ui-components branch from ed32792 to e6d6fe7 Compare October 10, 2026 02:12
@pbroom
pbroom force-pushed the docs/react-hooks-guide branch from 3fc7e3f to f35e674 Compare October 10, 2026 02:39
@pbroom
pbroom force-pushed the refactor/react-remove-ui-components branch from e6d6fe7 to c3695c2 Compare October 10, 2026 02:39

pbroom commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner Author

Merge activity

  • Oct 10, 6:47 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Oct 10, 8:41 PM UTC: Graphite rebased this pull request as part of a merge.
  • Oct 10, 8:41 PM UTC: @pbroom merged this pull request with Graphite.

pbroom added a commit that referenced this pull request Oct 10, 2026
ColorPlane still accepts the deprecated alias at runtime, so its exported
ColorPlaneRenderer type keeps it too; only the new hook's option type is
narrower. Dropping the alias stays with the component removal (#249) and
its breaking changeset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
pbroom added a commit that referenced this pull request Oct 10, 2026
…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)
@pbroom
pbroom changed the base branch from docs/react-hooks-guide to graphite-base/249 October 10, 2026 20:37
pbroom added a commit that referenced this pull request Oct 10, 2026
## 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.tsx`** exports a reusable `PlanePicker`:
  - A `<canvas>` painted by `useColorPlaneRenderer`.
  - An `<svg viewBox="0 0 100 100">` overlay drawn through a render prop. The demo draws two `useGamutBoundary` edges.
  - A `role="slider"` thumb. Pointer input goes through the driver's `createPointerDragController` with `normalizeColorAreaPointer` and `colorFromColorAreaPosition`. Keyboard and ARIA come from `colorFromColorAreaKey` and `getColorAreaValueText`.
  - `useAdaptiveQuality` feeds the renderer and the overlays.
- **Other examples:**
  - `contrast-region.tsx` and `color-provider.tsx` (controlled) reuse `PlanePicker`.
  - New `channel-inputs.tsx` (on the guide page) shows native range inputs with `getSliderGradientStyles` rails, and a text field built on the driver's string helpers.
  - `color-area.tsx`, `color-slider.tsx` and `color-string-input.tsx` are removed.
- **Narrative pages:**
  - Rewrote `/api/react` and `/guides/react`.
  - New symbol notes for `useColorPlaneRenderer` and `useContrastRegion`; the component notes are removed.
  - Updated cross-references in the performance, contrast-palette and headless-picker guides, the plane intro, and the entry summaries.
  - The callout names control-kit's `Plane` / `Slider` as an optional host, without depending on it.
- **API sidebar:** the react domains are now Color / Plane renderer / Plane geometry / Performance.
- **Scripts:** retargeted the drag profiling scripts to the hook-based example. They are now `profile:plane-picker` and `test: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:preprod` and `pnpm --filter @color-kit/docs typecheck` all pass.
- **Bundle budget:** the channel-inputs example moved to the guide page so the `/api/react` chunk stays under the 200 kB budget. It is 187 kB.
- **Browser check:** on a production build served with `vite preview`, `/api/react` and `/guides/react` render the canvas and the overlays.
  - A pointer drag moves the thumb continuously (21 distinct positions over 21 frames).
  - The arrow keys step the focused thumb, and the hue slider repaints the WebGL plane.
  - The contrast fill stays on screen while dragging, and the text field commits and reverts as described.
  - No console errors from real interaction.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@pbroom
pbroom changed the base branch from graphite-base/249 to main October 10, 2026 20:39
pbroom and others added 2 commits October 10, 2026 20:40
color-kit/react now exports the Color provider/context, useColor,
useMultiColor, the color store, and the plane hooks (useColorPlaneRenderer,
useGamutBoundary, useChromaBand, useContrastRegion, useFallbackPoints,
useAdaptiveQuality). The UI components are removed outright rather than
moved: ColorArea, Thumb, ColorPlane, OutOfGamutLayer, Layer, Background,
Line, Point, GamutBoundaryLayer, ChromaBandLayer, ContrastRegionLayer,
ContrastRegionFill, FallbackPointsLayer, ColorSlider, SliderMarker,
ChromaMarkers, ColorStringInput and ColorInput, with their tests, prop
types and the unused internal helpers they relied on.

- Drop the optional @color-kit/control-kit peer/dev dependency, the
  ./color-input subpath and tsup entry, the onlyBuiltDependencies
  allowance, and the now-unused axe-core and user-event dev deps; update
  the lockfile.
- Rename ColorArea quality types to ColorPlanePerformanceProfile /
  ColorPlaneQualityLevel; drop the deprecated 'canvas2d' renderer alias.
- Facade: stop excluding color-input from the react copy; test-exports
  asserts the hooks exist and the removed components stay absent.
- Add size-limit budgets for color-kit/react imports.
- Retarget the react benches (plane-interaction-bench), update README,
  DESIGN, the backlog and driver doc comments, and the docs declaration
  test; add a breaking changeset (minor, pre-1.0).

BREAKING CHANGE: the color-kit/react UI components and the
@color-kit/react/color-input subpath are removed; build pickers from the
hooks and color-kit/driver.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Color's JSDoc example (shown in the API reference and editor hovers)
imported ColorArea, ColorSlider and ColorStringInput, which no longer
exist. It now composes useColorPlaneRenderer and a native range input
under the provider. Comments, test names and bench labels that still
named ContrastRegionLayer, ColorPlane or ColorInput now name the hooks
or the driver behaviour, and the README example no longer reuses the
ColorPlane name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pbroom
pbroom force-pushed the refactor/react-remove-ui-components branch from c3695c2 to 470f905 Compare October 10, 2026 20:40
@vercel

vercel Bot commented Oct 10, 2026

Copy link
Copy Markdown

Deployment failed for project color-kit with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/pbrooms-projects?upgradeToPro=build-rate-limit

@pbroom
pbroom merged commit dc60fa3 into main Oct 10, 2026
5 of 6 checks passed
@pbroom
pbroom deleted the refactor/react-remove-ui-components branch October 10, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant