Skip to content

💭 Dream window: gradient-style — Reverse color stops (exact mirror) + spans no longer lose their start - #136

Merged
argyleink merged 2 commits into
mainfrom
dream/gs-1120
Nov 22, 2026
Merged

argyleink merged 2 commits into
mainfrom
dream/gs-1120

Conversation

@argyleink

Copy link
Copy Markdown
Owner

Problem

  • There was no way to flip a gradient's colors end to end. Rotating the angle only works for linear gradients; radial (center vs edge) and conic gradients can't be reversed at all without retyping every stop by hand.
  • Output bug: when you drag the second slider of an auto-placed middle stop (for example blue at 50% stretched to 50%..70%), the CSS came out as #00f 70%. The solid band disappeared from both the preview and the copied CSS, because the span's start was dropped whenever it matched the stop's auto slot.

Solution

  • New reverseStops() (src/utils/stops.ts) reverses the stop list and mirrors every position p -> 100% - p. Spans a..b become 100-b..100-a and hints mirror too.
    • It resolves CSS fixup first (CSS Images 3 §3.5.3: a stop placed before an earlier one is clamped up to it), so hard-stop presets like Stripes, whose spans are written as 0% 40%, reverse exactly.
    • Lengths mirror through calc(100% - 20px). Auto stops and hints stay auto. The result is an exact mirror for repeating gradients too.
  • A Reverse button sits next to "Add a random color". It's disabled for a single stop, and it's undoable through the existing history.
  • Span output fix in gradientString.ts, plus the in-component fallback serializer: a stop drops its start position only when it isn't a span.
  • html { -webkit-tap-highlight-color: transparent }

Impact

  • Pixel-verified: every multi-stop HD example (18 presets: linear, radial, conic, repeating, hard stops, hints) was reversed in Chromium and compared against the original flipped. The max channel difference was ≤ 1/255 for all 18. Stripes and the hard-stop bars were 254/255 off before the fixup handling.
  • Checked at 390px, 1440px and reduced-motion with no console errors. Reverse twice gives back the original, Ctrl+Z restores, and tap highlight computes to rgba(0, 0, 0, 0).
  • 8 new unit tests, 64 in total, and lint passes.

🤖 Generated with Claude Code

argyleink and others added 2 commits November 20, 2026 03:52
…spans that start on the auto slot

- reverseStops(): flips the stop list and mirrors every position p -> 100% - p
  after resolving CSS fixup, so hard-stop presets like Stripes reverse exactly;
  px/em positions mirror via calc(); auto stops/hints stay auto
- Reverse button next to 'Add a random color' (undoable)
- Output fix: a span whose start equals the auto slot (e.g. dragging the 2nd
  slider of a middle stop to 50%..70%) was written as 'blue 70%', losing the band
- html { -webkit-tap-highlight-color: transparent }

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for hd-gradients ready!

Name Link
🔨 Latest commit 07c2e70
🔍 Latest deploy log https://app.netlify.com/projects/hd-gradients/deploys/6b0034c468316d36f6a3d8f7
😎 Deploy Preview https://deploy-preview-136--hd-gradients.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

argyleink added a commit that referenced this pull request Nov 20, 2026
argyleink added a commit that referenced this pull request Nov 20, 2026
argyleink added a commit that referenced this pull request Nov 20, 2026
argyleink added a commit that referenced this pull request Nov 20, 2026
@argyleink

Copy link
Copy Markdown
Owner Author

Screenshots

before-1440.png

after-1440.png

before-390.png

after-390.png

@argyleink
argyleink merged commit 19246f1 into main Nov 22, 2026
5 checks passed
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