Next to the reply button can we add jump to top?
Jump to top
Adding a "Jump to top" control in the sticky compose dock next to the collapsed Reply button (components/composer.tsx). It scrolls the window smoothly to the top (instant when the user prefers reduced motion). I'll keep it visible in both collapsed and open states so it's always reachable from the dock, style it as a button.secondary, and check the phone layout (Reply stays full-width-ish, jump-to-top sits beside it).
threadide@3d3eb87Added a Top button to the compose dock, right next to Reply. Pushed to thread/bf6bec05 (3d3eb87); no PR opened yet — say the word if you want one.
What it does
components/jump-to-top.tsx(new, client):window.scrollTo({ top: 0 }), smooth-scrolling unless the visitor hasprefers-reduced-motionon. Hasaria-label="Jump to top of thread"and an inline-SVG arrow (no Unicode glyphs, per the header-icon gotcha).components/composer.tsxrenders it in both states: beside Reply when collapsed, and at the right end of the open form's button row (after cancel), so you can get back to the opening post without discarding a draft. Motivation: the thread page now opens at the newest reply, so long threads had no quick way back up.
Styling (app/globals.css): outlined, like the home-page "New thread" CTA — 1px var(--text) border, no fill, hover fills --accent. Deliberately written as button.jump-top so it beats the generic button:hover rule (the thing that once turned the ☰ toggle into a grey square). On ≤560px phones it stays flex: none so Reply / Post keep being the wide thumb target.
Verified: tsc --noEmit clean; static mockup screenshot attached (phone collapsed, phone with form open, desktop). The app itself can't run in the sandbox (needs Postgres + GitHub OAuth).
Diff · 3 files
diff --git a/threadide/app/globals.css b/threadide/app/globals.css
@@ -423,9 +423,19 @@ form.compose .compose-error { margin: 6px 0 0; }
.compose-collapsed { display: flex; align-items: center; gap: 12px; font-size: 13px; }
@media (max-width: 560px) {
.compose-collapsed > button { flex: 1 1 auto; }
+ .compose-collapsed > button.jump-top { flex: none; }
}
/* Escape in the textarea or this link folds the form back up; the draft stays in memory. */
form.compose .row > button.link.compose-cancel { flex: none; }
+/* "Jump to top" (components/jump-to-top.tsx): outlined like the home-page CTA, so it reads as secondary
+ beside the solid Reply/Post button. Styled as button.jump-top so it beats the generic button:hover rule. */
+button.jump-top { display: inline-flex; align-items: center; gap: 6px; background: none; color: var(--text); border: 1px solid var(--text); padding: 7px 14px; flex: none; }
+button.jump-top:hover:not(:disabled) { background: var(--accent); color: var(--on-accent); opacity: 1; }
+form.compose .row > button.jump-top { margin-left: auto; }
+@media (max-width: 560px) {
+ /* Keep it a compact control on phones too (the generic rule above makes row buttons full-width). */
+ form.compose .row > button.jump-top { flex: none; }
+}
diff --git a/threadide/components/composer.tsx b/threadide/components/composer.tsx
@@ -3,6 +3,7 @@
import { AttachImages, imagesFromPaste, uploadImageFiles, type Attachment } from "./attach-images";
+import { JumpToTop } from "./jump-to-top";
@@ -115,6 +116,7 @@
<button type="button" onClick={() => setOpen(true)}>
Reply
</button>
+ <JumpToTop />
{body.trim() && <span className="muted">Draft kept</span>}
@@ -183,6 +185,7 @@
<button type="button" className="link compose-cancel" onClick={() => setOpen(false)} disabled={busy}>
cancel
</button>
+ <JumpToTop />
</div>
diff --git a/threadide/components/jump-to-top.tsx b/threadide/components/jump-to-top.tsx
new file mode 100644
+"use client";
+
+/**
+ * "Jump to top" for the docked composer: the thread page opens at the newest reply
+ * (components/scroll-to-latest.tsx), so long threads need a one-tap way back to the opening post.
+ * Smooth scroll unless the visitor prefers reduced motion. Outlined like the home-page CTA so it
+ * reads as secondary next to the solid Reply/Post button.
+ */
+export function JumpToTop({ className = "" }: { className?: string }) {
+ function jump() {
+ const reduce = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
+ window.scrollTo({ top: 0, behavior: reduce ? "instant" : "smooth" });
+ }
+ return (
+ <button type="button" className={`jump-top ${className}`.trim()} onClick={jump} aria-label="Jump to top of thread" title="Jump to top">
+ <svg width="12" height="12" viewBox="0 0 12 12" aria-hidden="true">
+ <path d="M2 10.5h8M6 8.5V2M3 5l3-3 3 3" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
+ </svg>
+ Top
+ </button>
+ );
+}Showing it only next to reply is good
Got it — removing the second Top button from the open form's button row so it only appears next to the collapsed Reply button.
threadide@a4ebdc8Done — Top now appears only beside the collapsed Reply button. Pushed to thread/bf6bec05 (a4ebdc8).
Changed
components/composer.tsx: removed the second<JumpToTop />from the open form's button row (the one after cancel). The collapsed-state one next to Reply is unchanged.app/globals.css: dropped the now-unusedform.compose .row > button.jump-toprules (margin-left: auto+ the phoneflex: none); updated the comment to say it's collapsed-state only.
components/jump-to-top.tsx itself is untouched. tsc --noEmit clean.
Still no PR opened for this branch — tell me if you want one.
Diff · 2 files
--- a/threadide/components/composer.tsx
+++ b/threadide/components/composer.tsx
@@ -185,7 +185,6 @@
<button type="button" className="link compose-cancel" onClick={() => setOpen(false)} disabled={busy}>
cancel
</button>
- <JumpToTop />
</div>
--- a/threadide/app/globals.css
+++ b/threadide/app/globals.css
@@ -427,15 +427,10 @@
-/* "Jump to top" (components/jump-to-top.tsx): outlined like the home-page CTA, so it reads as secondary
- beside the solid Reply/Post button. Styled as button.jump-top so it beats the generic button:hover rule. */
+/* "Jump to top" (components/jump-to-top.tsx): shown only beside the collapsed Reply button, outlined like the
+ home-page CTA so it reads as secondary. Styled as button.jump-top so it beats the generic button:hover rule. */
button.jump-top { display: inline-flex; align-items: center; gap: 6px; background: none; color: var(--text); border: 1px solid var(--text); padding: 7px 14px; flex: none; }
button.jump-top:hover:not(:disabled) { background: var(--accent); color: var(--on-accent); opacity: 1; }
-form.compose .row > button.jump-top { margin-left: auto; }
-@media (max-width: 560px) {
- /* Keep it a compact control on phones too (the generic rule above makes row buttons full-width). */
- form.compose .row > button.jump-top { flex: none; }
-}