Repository navigation
refactor(app): split PalettePage into sections - #12463
Merged
Merged
Conversation
Step 1 of 4: move CompPalette, Anchor, HistoryEntry, and WheelDot into app/src/sections/palette/types.ts, and oklchToRgb, starPoints, textOn, and deltaECellBg into app/src/sections/palette/paletteHelpers.ts. Brief: palette-page-split Co-Authored-By: Antigravity (Gemini 4 Argon) <noreply@google.com>
Step 2 of 4: move ChromaWheel, CodeBlock, and DeltaEMatrix into their own component files under app/src/sections/palette/, sharing tooltipSlotProps from paletteHelpers.ts. Brief: palette-page-split Co-Authored-By: Antigravity (Gemini 4 Argon) <noreply@google.com>
Step 3 of 4: extract HeroSection, PaletteGridSection, SemanticAnchorsSection, ContinuousCmapsSection, CopySnippetsSection, WcagContrastSection, DeltaESection, and LineageSection under app/src/sections/palette/, leaving PalettePage with state, effects, memos, and layout (144 lines). Brief: palette-page-split Co-Authored-By: Antigravity (Gemini 4 Argon) <noreply@google.com>
Step 4 of 4: add changelog.d/palette-page-split.md. Brief: palette-page-split Co-Authored-By: Antigravity (Gemini 4 Argon) <noreply@google.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The change still has an active moderate finding because the extracted palette rendering and interaction paths lack focused tests, leaving frontend patch coverage failing.
1 open issue
What changed in this PR
This pull request refactors PalettePage into focused palette sections and shared helper modules while preserving its rendered output and behavior. The extracted rendering and interaction paths currently lack focused component/page tests, leaving frontend patch coverage red.
Changes:
- Reduced
PalettePage.tsxto state, effects, derived data, metadata, and section composition. - Extracted eight sections and three helper components under
app/src/sections/palette/. - Centralized palette types, constants, color helpers, thresholds, and shared styles.
- Added a changelog fragment.
- Focused tests are still needed for the wheel, sorting, copying, tabs/OKLCH controls, and theme-dependent WCAG rendering.
| File | Description |
|---|---|
changelog.d/palette-page-split.md |
Documents the PalettePage section split. |
app/src/sections/palette/WcagContrastSection.tsx |
Renders the theme-aware WCAG contrast table. |
app/src/sections/palette/types.ts |
Defines shared palette, anchor, lineage, and wheel types. |
app/src/sections/palette/SemanticAnchorsSection.tsx |
Renders semantic anchor swatches and copy interactions. |
app/src/sections/palette/paletteHelpers.ts |
Provides shared palette data, color helpers, thresholds, and layout styles. |
app/src/sections/palette/PaletteGridSection.tsx |
Renders categorical swatches, sorting controls, tooltips, and copy actions. |
app/src/sections/palette/LineageSection.tsx |
Renders palette history and provenance information. |
app/src/sections/palette/HeroSection.tsx |
Renders the palette hero, wheel, and comparison controls. |
app/src/sections/palette/DeltaESection.tsx |
Renders ΔE explanations, matrices, and the legend. |
app/src/sections/palette/DeltaEMatrix.tsx |
Provides the reusable ΔE matrix renderer. |
app/src/sections/palette/CopySnippetsSection.tsx |
Renders language tabs, the OKLCH toggle, and code snippets. |
app/src/sections/palette/ContinuousCmapsSection.tsx |
Renders sequential and diverging continuous colormap previews. |
app/src/sections/palette/CodeBlock.tsx |
Provides the copyable code block component. |
app/src/sections/palette/ChromaWheel.tsx |
Provides the interactive hue–chroma wheel. |
app/src/pages/PalettePage.tsx |
Retains page state, effects, memoized data, metadata, and section composition. |
Review effort: Lite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
app/src/pages/PalettePage.tsxfrom 1,783 lines to 144 lines with no change in rendered markup, text, styles, or behaviour.CompPalette,Anchor,HistoryEntry,WheelDot) intoapp/src/sections/palette/types.tsand the colour helpers (oklchToRgb,starPoints,textOn,deltaECellBg) plus shared non-component constants (COMPARISONS,tooltipSlotProps,sectionSx,proseColumnSx) intoapp/src/sections/palette/paletteHelpers.tsso every.tsxfile exports only its component and satisfiesreact-refresh/only-export-components.app/src/sections/palette/ChromaWheel.tsx,app/src/sections/palette/CodeBlock.tsx, andapp/src/sections/palette/DeltaEMatrix.tsx.app/src/sections/palette/HeroSection.tsx,app/src/sections/palette/PaletteGridSection.tsx,app/src/sections/palette/SemanticAnchorsSection.tsx,app/src/sections/palette/ContinuousCmapsSection.tsx,app/src/sections/palette/CopySnippetsSection.tsx,app/src/sections/palette/WcagContrastSection.tsx,app/src/sections/palette/DeltaESection.tsx, andapp/src/sections/palette/LineageSection.tsx.changelog.d/palette-page-split.md. No files outside the brief's Constraints were touched.WcagContrastSection.tsxinto two adjacent ones with the same text, and an obsolete "Inline sub-components" banner comment went with the components it labelled). No fix commits were needed; Claude only added the PR reference to the fragment. For comparison, none of the three Jules variants of this split on 2026-10-29 kept the page intact.Plan
Brief
palette-page-split, package 1 of 1, as written:Brief
Split PalettePage into sections without changing what it renders
Branch
gemini/palette-page-split· package 1 of 1Goal
app/src/pages/PalettePage.tsxis 1,783 lines: three helper components, fourcolour helpers, and one page component with eight numbered sections. Split it
the way DebugPage and MapPage were split (PR #12457), so each section lives in
its own file under
app/src/sections/palette/and the page keeps only state,effects, and layout. This is a pure refactor: the rendered page, its text, its
markup, and its behaviour stay exactly the same.
Context
app/src/sections/debug/andapp/src/sections/map/(one component per file, named exports, shared helpers in a non-component
module such as
app/src/sections/debug/debugFormat.ts).hue–chroma wheel, 2. palette grid and sort toggle, 3. semantic anchors,
3b. continuous cmaps, 4. copy snippets, 5. WCAG contrast, 6. ΔE colour
distance, 7. lineage. Helper components:
ChromaWheel,CodeBlock,DeltaEMatrix. Helpers:oklchToRgb,starPoints,textOn,deltaECellBg. Types:CompPalette,Anchor,HistoryEntry,WheelDot.app/src/pages/PalettePage.helpers.tsandapp/src/pages/PalettePage.snippet.test.tsalready exist and stay as they are.whole sections, cut JSX apart with string slicing so elements lost their
closing tags, invented markup (a solid separator where a dashed border was),
typed props as
anybehindeslint-disablecomments, and committed helperscripts. Claude will compare the rendered page against
mainelement byelement, so any visible change will be found.
Steps
app/src/sections/palette/(a types module and a non-component helpersmodule; a component file that also exports functions breaks React fast
refresh and fails lint).
ChromaWheel,CodeBlock, andDeltaEMatrixinto their own files.the state and handlers it owns as typed props.
Constraints
text with your edit tool. No regex,
sed, or script-based slicing, and nohelper scripts in the repository.
obvious improvement. State, effects, and memos stay in
PalettePage; add nonew hooks.
anyand noeslint-disableanywhere; type props with the existingtypes.
app/src/pages/PalettePage.tsx, new files underapp/src/sections/palette/, and one fragment underchangelog.d/.Acceptance
All of these, run from the repository root of the clone:
Each convention check below must print nothing:
yarn lintmust report no warnings, not only no errors.Decide yourself / report back
and whether a very small section stays inline in the page. Document the
choices in the hand-over.
in markup or behaviour, and any existing test that would need more than an
import change.
Test plan
cd app && yarn lint—Done in 8.38s.(0 errors, 0 warnings)cd app && yarn fm:check—All matched files use Prettier code style!cd app && yarn type-check—Done in 4.12s.cd app && yarn test—Test Files 113 passed (113), Tests 1197 passed (1197)cd app && yarn build—Done in 5.59s.PYTHON_DOTENV_DISABLED=1 uv run python -m tools.changelog check --base origin/main—the diff against origin/main passes the fragment ruleConvention checks:
git diff --name-only origin/main...HEAD | grep -v -E '^(app/src/pages/PalettePage\.tsx|app/src/sections/palette/|changelog\.d/)'(empty output)grep -rn -E 'eslint-disable|: any\b|as any|<any>' app/src/pages/PalettePage.tsx app/src/sections/palette/(empty output)[ "$(wc -l < app/src/pages/PalettePage.tsx)" -le 450 ] || echo "PalettePage.tsx is still too long"(empty output;PalettePage.tsxis 144 lines)Claude:
/palettebuilt frommainand from this branch against the production API, clicked through ten states (load, wheel expanded, two comparison palettes, CVD sort, two language tabs, OKLCH on, copy a swatch, wheel collapsed):<main>HTML byte-identical at every step, emotion class names included (they hash the styles), no page errorsClaude: frontend gates on the branch (lint without warnings, Prettier, type-check, 1,210 tests, build)
codecov/patch/frontendstays red: the page never had render tests, and moved code counts as new; section render tests are the next Gemini taskDecisions
app/src/sections/palette/types.tsforCompPalette,Anchor,HistoryEntry, andWheelDot, andapp/src/sections/palette/paletteHelpers.tsfor the four colour helpers (oklchToRgb,starPoints,textOn,deltaECellBg), ΔE thresholds (DE_T_BAD,DE_T_WARN,DE_T_OK), shared comparison palettes (COMPARISONS), and shared layout/tooltip style constants (tooltipSlotProps,sectionSx,proseColumnSx) so.tsxcomponent files export only components.HeroSection.tsx,PaletteGridSection.tsx,SemanticAnchorsSection.tsx,ContinuousCmapsSection.tsx,CopySnippetsSection.tsx,WcagContrastSection.tsx,DeltaESection.tsx,LineageSection.tsx), co-locating each section's private data constants (HYBRID_V3_CVD,PURE_CVD_GREEDY,ANCHORS,LANG_LABELS,WCAG_TABLE,DE_LEGEND,HISTORY) inside the section component that renders them.Open steps and questions