Repository navigation
Tighten Download for Mac divider padding #7257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a86fb88
Tighten Download for Mac divider padding
lawrencecchen 79cdb6b
Fix Safari hover tint escaping DownloadButton's rounded corners
lawrencecchen 9604684
Trim divider padding and stop the Safari hover jump
lawrencecchen fdf67fa
Drop pill translateZ layer and add /debug tuner for both sizes
lawrencecchen 2aad309
Pin theme tokens in /debug preview so the pill has correct contrast
lawrencecchen eae114b
Apply tuned divider padding (both sizes)
lawrencecchen a413581
Render pill padding as inline px from a config
lawrencecchen d38c658
Show /debug buttons at actual size in front-screen context
lawrencecchen 9f39a9f
Add per-size reset buttons to /debug tuner
lawrencecchen 32f6b2f
Add per-value reset to each /debug slider
lawrencecchen fe8d7cd
Update tuned divider padding
lawrencecchen c464b6d
Remove /debug tuner and padOverride prop; ship only the button
lawrencecchen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| "use client"; | ||
|
|
||
| // Live tuner for the real DownloadButton. Renders both sizes at once and drives | ||
| // each one's padding via the component's `padOverride` prop, so the divider | ||
| // spacing can be dialed in per size and copied back into download-button.tsx. | ||
| // Diagnostic toggles (re-add transition, drop translateZ, magnify) exist to | ||
| // pin down the Safari hover jump. Reach it at /debug. Not linked from anywhere. | ||
|
|
||
| import { useState } from "react"; | ||
| import { DownloadButton } from "../components/download-button"; | ||
|
|
||
| type Pad = { | ||
| downloadLeft: number; | ||
| downloadRight: number; | ||
| caretLeft: number; | ||
| caretRight: number; | ||
| }; | ||
| type Size = "default" | "sm"; | ||
|
|
||
| const INITIAL: Record<Size, Pad> = { | ||
| default: { downloadLeft: 20, downloadRight: 10, caretLeft: 7, caretRight: 8 }, | ||
| sm: { downloadLeft: 16, downloadRight: 7, caretLeft: 5, caretRight: 8 }, | ||
| }; | ||
|
|
||
| const FIELDS: { key: keyof Pad; label: string; accent: string }[] = [ | ||
| { key: "downloadRight", label: "Left of divider (download pr)", accent: "#3b82f6" }, | ||
| { key: "caretLeft", label: "Right of divider (caret pl)", accent: "#f97316" }, | ||
| { key: "downloadLeft", label: "Outer left (before icon)", accent: "#9ca3af" }, | ||
| { key: "caretRight", label: "Outer right (after caret)", accent: "#9ca3af" }, | ||
| ]; | ||
|
|
||
| // px -> Tailwind spacing token (v4: 1 unit = 4px; .5 steps ok; else arbitrary) | ||
| function tw(prefix: string, px: number) { | ||
| if (px % 4 === 0) return `${prefix}-${px / 4}`; | ||
| if (px % 2 === 0) return `${prefix}-${px / 4}`; // e.g. 10 -> 2.5, 6 -> 1.5 | ||
| return `${prefix}-[${px}px]`; | ||
| } | ||
|
|
||
| export default function DownloadButtonDebug() { | ||
| const [pad, setPad] = useState<Record<Size, Pad>>(() => structuredClone(INITIAL)); | ||
| const [dark, setDark] = useState(false); | ||
| const [zoom, setZoom] = useState(3); | ||
| const [reTransition, setReTransition] = useState(false); | ||
| const [forceTranslateZ, setForceTranslateZ] = useState(false); | ||
| const [copied, setCopied] = useState(false); | ||
|
|
||
| const set = (size: Size, key: keyof Pad, v: number) => | ||
| setPad((p) => ({ ...p, [size]: { ...p[size], [key]: v } })); | ||
|
|
||
| const classesFor = (size: Size) => { | ||
| const p = pad[size]; | ||
| return { | ||
| download: `${tw("pl", p.downloadLeft)} ${tw("pr", p.downloadRight)}`, | ||
| caret: | ||
| p.caretLeft === p.caretRight | ||
| ? tw("px", p.caretLeft) | ||
| : `${tw("pl", p.caretLeft)} ${tw("pr", p.caretRight)}`, | ||
| }; | ||
| }; | ||
|
|
||
| const snippet = () => { | ||
| const d = classesFor("default"); | ||
| const s = classesFor("sm"); | ||
| return [ | ||
| "// download zone padding", | ||
| `default download: ${d.download} caret: ${d.caret}`, | ||
| `sm download: ${s.download} caret: ${s.caret}`, | ||
| "", | ||
| "// raw px", | ||
| `default: ${JSON.stringify(pad.default)}`, | ||
| `sm: ${JSON.stringify(pad.sm)}`, | ||
| ].join("\n"); | ||
| }; | ||
|
|
||
| const copy = async () => { | ||
| await navigator.clipboard.writeText(snippet()); | ||
| setCopied(true); | ||
| window.setTimeout(() => setCopied(false), 1200); | ||
| }; | ||
|
|
||
| const wrapClass = [ | ||
| reTransition ? "dbg-retrans" : "", | ||
| forceTranslateZ ? "dbg-tz" : "", | ||
| ] | ||
| .filter(Boolean) | ||
| .join(" "); | ||
|
|
||
| return ( | ||
| <div className="mx-auto max-w-6xl p-8"> | ||
| {/* Diagnostic CSS scoped to the previews */} | ||
| <style>{` | ||
| .dbg-retrans a, .dbg-retrans button { transition: background-color .15s ease !important; } | ||
| .dbg-retrans svg { transition: opacity .15s ease !important; } | ||
| .dbg-tz > div:first-child { transform: translateZ(0) !important; } | ||
| `}</style> | ||
|
|
||
| <h1 className="text-lg font-semibold">DownloadButton debug</h1> | ||
| <p className="mb-6 text-sm text-muted"> | ||
| Both sizes render the real component; sliders drive its{" "} | ||
| <code className="rounded bg-code-bg px-1">padOverride</code>. Hover each | ||
| button to check the jump. Copy classes into{" "} | ||
| <code className="rounded bg-code-bg px-1"> | ||
| web/app/[locale]/components/download-button.tsx | ||
| </code> | ||
| . | ||
| </p> | ||
|
|
||
| {/* toolbar */} | ||
| <div className="mb-6 flex flex-wrap items-center gap-5 text-sm"> | ||
| <label className="flex items-center gap-2"> | ||
| <input type="checkbox" checked={dark} onChange={(e) => setDark(e.target.checked)} /> | ||
| dark bg | ||
| </label> | ||
| <label className="flex items-center gap-2"> | ||
| zoom | ||
| <input type="range" min={1} max={8} step={0.5} value={zoom} | ||
| onChange={(e) => setZoom(Number(e.target.value))} /> | ||
| <span className="w-8 tabular-nums">{zoom}×</span> | ||
| </label> | ||
| <label className="flex items-center gap-2 text-blue-600"> | ||
| <input type="checkbox" checked={reTransition} | ||
| onChange={(e) => setReTransition(e.target.checked)} /> | ||
| re-add hover transition (diagnostic: should reintroduce the jump) | ||
| </label> | ||
| <label className="flex items-center gap-2 text-blue-600"> | ||
| <input type="checkbox" checked={forceTranslateZ} | ||
| onChange={(e) => setForceTranslateZ(e.target.checked)} /> | ||
| force translateZ on pill (diagnostic: should reintroduce the jump) | ||
| </label> | ||
| </div> | ||
|
|
||
| {/* previews + sliders, one column per size */} | ||
| <div className="grid gap-8 md:grid-cols-2"> | ||
| {(["default", "sm"] as const).map((size) => ( | ||
| <div key={size} className="rounded-xl border border-border p-4"> | ||
| <div className="mb-3 text-sm font-semibold uppercase tracking-wide text-muted"> | ||
| {size} | ||
| </div> | ||
|
|
||
| <div | ||
| className={dark ? "dark" : undefined} | ||
| style={{ | ||
| background: dark ? "#0a0a0a" : "#fafafa", | ||
| borderRadius: 12, | ||
| padding: "48px 24px", | ||
| overflow: "auto", | ||
| display: "flex", | ||
| justifyContent: "center", | ||
| }} | ||
| > | ||
| <div className={wrapClass} | ||
| style={{ transform: `scale(${zoom})`, transformOrigin: "center" }}> | ||
| <DownloadButton size={size} location="debug" padOverride={pad[size]} /> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="mt-4 space-y-3"> | ||
| {FIELDS.map((f) => ( | ||
| <div key={f.key}> | ||
| <div className="mb-1 flex items-center justify-between text-sm"> | ||
| <span className="flex items-center gap-2 font-medium"> | ||
| <span className="inline-block h-2 w-2 rounded-sm" | ||
| style={{ background: f.accent }} /> | ||
| {f.label} | ||
| </span> | ||
| <input type="number" min={0} max={40} value={pad[size][f.key]} | ||
| onChange={(e) => set(size, f.key, Number(e.target.value))} | ||
| className="w-14 rounded border border-border bg-transparent px-2 py-0.5 text-right text-sm" /> | ||
| </div> | ||
| <input type="range" min={0} max={40} step={1} value={pad[size][f.key]} | ||
| onChange={(e) => set(size, f.key, Number(e.target.value))} | ||
| className="w-full" /> | ||
| </div> | ||
| ))} | ||
| <div className="pt-1 font-mono text-xs text-muted"> | ||
| download {classesFor(size).download} · caret {classesFor(size).caret} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ))} | ||
| </div> | ||
|
|
||
| {/* output */} | ||
| <div className="mt-8"> | ||
| <button onClick={copy} | ||
| className="mb-2 rounded-md bg-foreground px-4 py-2 text-sm font-medium text-background"> | ||
| {copied ? "Copied ✓" : "Copy classes + px (both sizes)"} | ||
| </button> | ||
| <pre className="overflow-auto rounded-lg border border-border bg-code-bg p-3 font-mono text-xs"> | ||
| {snippet()} | ||
| </pre> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.