reworked gradient generation#131
Conversation
|
You have run out of free Bugbot PR reviews for this billing cycle. This will reset on March 15. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: d5e5c61 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughReplaces the previous screenshot-driven gradient pipeline with a palette-matched system. Removed the old gradient-generation domain (color-extraction, K‑means, chroma-js, node‑vibrant, sharp, server API route) and tests. Added image-side color analysis (extractColorPalette/signature), a deterministic palette builder (palette.ts), and generateGradientOptions producing six gradient styles. UI changes centralize gradients in a new gradientOptionsAtom, remove the isAnalyzingColors prop, add a Gradient Playground page, and adjust layout helpers (beam mask/direction). Dependency changes include removing chroma-js/culori/node-vibrant/sharp and adding mesh-gradient. Sequence Diagram(s)sequenceDiagram
actor User
participant PlaygroundUI as Playground UI
participant ColorAnalysis as Color Analysis
participant PaletteGen as Palette Generator
participant Atoms as State (gradientOptionsAtom)
participant GradientUI as Gradient Components
User->>PlaygroundUI: Upload or select screenshot
PlaygroundUI->>ColorAnalysis: extractColorSignatureFromImage(dataUrl)
activate ColorAnalysis
Note over ColorAnalysis: sample pixels → compute buckets\nderive dominant/accent hues, brightness, strength
ColorAnalysis-->>PlaygroundUI: ColorSignature + ColorPalette
deactivate ColorAnalysis
PlaygroundUI->>PaletteGen: generateGradientOptions(signature)
activate PaletteGen
Note over PaletteGen: build 6 gradient styles\n(mesh, aurora, linear bold, radial glow, linear soft, muted wash)
PaletteGen-->>PlaygroundUI: AdvancedGradient[]
deactivate PaletteGen
PlaygroundUI->>Atoms: set gradientOptionsAtom(AdvancedGradient[])
Atoms-->>GradientUI: notify subscribers / provide gradients
GradientUI->>GradientUI: render swatches (customGradientToCss)
GradientUI-->>User: display gradient previews
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a59d007581
ℹ️ 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".
| setGradientOptions([]); | ||
|
|
||
| try { | ||
| const colorPalette = await analyzeColors(dataUrl); | ||
| const analysis = await extractColorSignatureFromImage(dataUrl); | ||
| if (!analysis) return; |
There was a problem hiding this comment.
Add fallback when color analysis returns null
If extractColorSignatureFromImage returns null, the function exits right after clearing gradientOptions, so the options stay empty. Downstream UI treats “no gradients” as “still analyzing” (the picker shows skeletons and the workspace hides the canvas when gradientOptions.length === 0), so a failed decode (e.g., corrupted image, SVG with external refs) leaves the user stuck with no gradients even though analysis has finished. Consider restoring previous options or setting a default fallback when analysis fails.
Useful? React with 👍 / 👎.
Summary by CodeRabbit
New Features
Improvements
Behavior Changes