Skip to content

Commit 0fb09ce

Browse files
mahanticodexStar Lord
authored
Polish floating timeline and sidebar actions (#515)
Signed-off-by: Arjun Mahanti <[email protected]> Signed-off-by: Codex <[email protected]> Signed-off-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz> Co-authored-by: Codex <[email protected]> Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
1 parent 30251dd commit 0fb09ce

13 files changed

Lines changed: 193 additions & 49 deletions

‎docs/unread.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ but do not borrow one participant's avatar. Previews reuse the sidebar's existin
146146
profile map and media routing; absent pictures use initials, humans use circles,
147147
and agents use squircles. Avatar artwork is decorative; the button's accessible
148148
name gives the conversation count and direction without implying a DM-first target.
149-
The controls retain the current prominent treatment. Thread-only rows participate.
149+
The controls use shared prominent buttons with an inverse surface, with
150+
interruptible tooltip-style transitions and reduced-motion support. Hidden cues
151+
remain inert during exit. Thread-only rows participate.
150152
The controls measure existing rendered badges/dots—no extra unread
151153
subscriptions or relay reads just to show them. Search-filtered rows do not
152154
participate. Collapsed sections use the summary's position and expand when revealed.

‎src/bundled/channels/Channels.module.css‎

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,21 +209,45 @@
209209
gap: var(--space-half);
210210
padding-block-end: var(--sidebar-padding);
211211
}
212-
/* The cue floats over scrolled rows, so it needs the panel surface beneath
213-
it. `display: grid` keeps the wrapper flush with the control so no sliver
214-
of fill shows around the pill. */
212+
/* Keep the prominent unread cue while matching the timeline reveal motion. */
215213
.unreadEdge {
216214
position: absolute;
217215
left: 50%;
218216
display: grid;
219-
transform: translateX(-50%);
217+
transform: translateX(-50%) translateY(2px) scale(0.97);
220218
z-index: 3;
221219
isolation: isolate;
222220
width: max-content;
223221
max-width: calc(100% - var(--space-2));
224-
border-radius: var(--radius-capsule);
225222
background: var(--affordance-prominent);
226223
box-shadow: var(--shadow-sm);
224+
border-radius: var(--radius-capsule);
225+
visibility: hidden;
226+
pointer-events: none;
227+
opacity: 0;
228+
filter: blur(2px);
229+
transition:
230+
opacity var(--duration-fast) var(--easing-state),
231+
transform var(--duration-fast) var(--easing-settle),
232+
filter var(--duration-fast) var(--easing-state),
233+
visibility 0s var(--duration-fast);
234+
}
235+
.unreadEdge[data-visible="true"] {
236+
visibility: visible;
237+
pointer-events: auto;
238+
opacity: 1;
239+
transform: translateX(-50%) translateY(0) scale(1);
240+
filter: blur(0);
241+
transition-duration: var(--duration-state);
242+
transition-delay: 0s;
243+
}
244+
@media (prefers-reduced-motion: reduce) {
245+
.unreadEdge,
246+
.unreadEdge[data-visible="true"] {
247+
transform: translateX(-50%);
248+
filter: none;
249+
transition-property: opacity, visibility;
250+
}
227251
}
228252

229253
.unreadEdge [class~="buzz-button-label"] {
@@ -260,7 +284,7 @@
260284
top: var(--space-5);
261285
}
262286
.unreadEdge[data-edge="below"] {
263-
bottom: 0.25rem;
287+
bottom: 0;
264288
}
265289
.channelSection {
266290
position: relative;

‎src/bundled/channels/SidebarUnread.test.tsx‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,12 @@ it("removes both counts and previews when unread markers disappear", async () =>
215215
<SidebarUnread dmPreviews={previews}>{row("dm", 340)}</SidebarUnread>,
216216
);
217217
await measure();
218-
expect(
219-
screen.getByRole("button", { name: "1 unread conversation below" }),
220-
).toBeInTheDocument();
218+
const cue = screen.getByRole("button", {
219+
name: "1 unread conversation below",
220+
});
221+
const surface = cue.closest("[data-visible]");
222+
expect(surface).toHaveAttribute("data-visible", "true");
223+
expect(surface).not.toHaveAttribute("inert");
221224
view.rerender(
222225
<SidebarUnread dmPreviews={previews}>
223226
<button type="button" data-channel-id="dm" data-top="340">
@@ -230,4 +233,21 @@ it("removes both counts and previews when unread markers disappear", async () =>
230233
expect(
231234
screen.queryByRole("button", { name: /unread conversation/ }),
232235
).not.toBeInTheDocument();
236+
// Keep the surface for its exit transition, but exclude hidden controls.
237+
expect(surface).toBeInTheDocument();
238+
expect(surface).toHaveAttribute("inert");
239+
expect(surface).toHaveAttribute("aria-hidden", "true");
240+
expect(surface).toHaveAttribute("data-visible", "false");
241+
view.rerender(
242+
<SidebarUnread dmPreviews={previews}>{row("dm", 340)}</SidebarUnread>,
243+
);
244+
fireEvent.scroll(screen.getByRole("navigation"));
245+
await measure();
246+
expect(
247+
screen.getByRole("button", {
248+
name: "1 unread conversation below",
249+
}),
250+
).toBe(cue);
251+
expect(surface).not.toHaveAttribute("inert");
252+
expect(surface).toHaveAttribute("data-visible", "true");
233253
});

‎src/bundled/channels/SidebarUnread.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ export function SidebarUnread({
179179
</nav>
180180
{(["above", "below"] as const).map((edge) => {
181181
const count = edges[edge].length;
182-
if (!count) return null;
183182
const nearestFirst =
184183
edge === "above" ? [...edges[edge]].reverse() : edges[edge];
185184
const previews = nearestFirst
@@ -190,7 +189,14 @@ export function SidebarUnread({
190189
.slice(0, 3);
191190
const Icon = edge === "above" ? ArrowUpIcon : ArrowDownIcon;
192191
return (
193-
<div className={styles.unreadEdge} data-edge={edge} key={edge}>
192+
<div
193+
className={styles.unreadEdge}
194+
data-edge={edge}
195+
key={edge}
196+
data-visible={count > 0}
197+
inert={count === 0}
198+
aria-hidden={count === 0}
199+
>
194200
<Button
195201
variant="prominent"
196202
aria-label={`${count} unread ${count === 1 ? "conversation" : "conversations"} ${edge}`}

‎src/features/messages/ChannelTimeline.test.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,8 @@ function setup({
437437
!!child &&
438438
typeof child === "object" &&
439439
"type" in child &&
440-
child.type === JumpToLatestButton,
440+
child.type === JumpToLatestButton &&
441+
(child as ReactElement<{ visible: boolean }>).props.visible,
441442
) as ReactElement<{ onClick(): void }> | undefined;
442443
button?.props.onClick();
443444
},
@@ -447,7 +448,8 @@ function setup({
447448
!!child &&
448449
typeof child === "object" &&
449450
"type" in child &&
450-
child.type === JumpToLatestButton,
451+
child.type === JumpToLatestButton &&
452+
(child as ReactElement<{ visible: boolean }>).props.visible,
451453
);
452454
},
453455
unmount() {

‎src/features/messages/ChannelTimeline.tsx‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -744,12 +744,11 @@ function Timeline({
744744
</Button>
745745
) : null}
746746
</div>
747-
{showJumpToLatest && (
748-
<JumpToLatestButton
749-
newMessageCount={newMessageCount}
750-
onClick={jumpToLatest}
751-
/>
752-
)}
747+
<JumpToLatestButton
748+
visible={showJumpToLatest}
749+
newMessageCount={newMessageCount}
750+
onClick={jumpToLatest}
751+
/>
753752
{width > 0 && (
754753
<Virtualizer
755754
ref={handle}

‎src/features/messages/JumpToLatestButton.tsx‎

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import { Button } from "../../shared/design-system/ui/Button";
33
import styles from "./Messages.module.css";
44

55
export function JumpToLatestButton({
6+
visible,
67
newMessageCount,
78
onClick,
89
}: {
10+
visible: boolean;
911
newMessageCount: number;
1012
onClick(): void;
1113
}) {
@@ -14,16 +16,23 @@ export function JumpToLatestButton({
1416
? `${newMessageCount} new message${newMessageCount === 1 ? "" : "s"}`
1517
: "Jump to latest";
1618
return (
17-
<div className={styles.jumpToLatest}>
18-
<Button
19-
data-jump-to-latest=""
20-
size="sm"
21-
variant="outline"
22-
onClick={onClick}
23-
>
24-
<ArrowDownIcon size={16} aria-hidden="true" />
25-
{label}
26-
</Button>
19+
<div
20+
className={styles.jumpToLatest}
21+
inert={!visible}
22+
aria-hidden={!visible}
23+
data-visible={visible}
24+
>
25+
<div className={styles.jumpToLatestSurface}>
26+
<Button
27+
data-jump-to-latest=""
28+
size="sm"
29+
variant="ghost"
30+
onClick={onClick}
31+
>
32+
<ArrowDownIcon size={16} aria-hidden="true" />
33+
{label}
34+
</Button>
35+
</div>
2736
</div>
2837
);
2938
}

‎src/features/messages/Messages.module.css‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,16 +2241,44 @@ html[data-keyboard-navigation] .rawDiff:focus-visible {
22412241
}
22422242

22432243
.jumpToLatest {
2244+
align-items: flex-start;
22442245
position: sticky;
22452246
z-index: 2;
2246-
top: calc(100% - var(--size-control) - var(--space-2));
2247+
top: calc(100% - var(--size-control-sm));
22472248
height: 0;
22482249
display: flex;
22492250
justify-content: center;
22502251
pointer-events: none;
22512252
}
2252-
button[data-jump-to-latest] {
2253+
.jumpToLatestSurface {
2254+
@apply glass-secondary;
2255+
border-radius: var(--radius-pill);
2256+
visibility: hidden;
2257+
opacity: 0;
2258+
transform: translateY(2px) scale(0.97);
2259+
filter: blur(2px);
2260+
transition:
2261+
opacity var(--duration-fast) var(--easing-state),
2262+
transform var(--duration-fast) var(--easing-settle),
2263+
filter var(--duration-fast) var(--easing-state),
2264+
visibility 0s var(--duration-fast);
2265+
}
2266+
.jumpToLatest[data-visible="true"] .jumpToLatestSurface {
2267+
visibility: visible;
22532268
pointer-events: auto;
2269+
opacity: 1;
2270+
transform: translateY(0) scale(1);
2271+
filter: blur(0);
2272+
transition-duration: var(--duration-state);
2273+
transition-delay: 0s;
2274+
}
2275+
@media (prefers-reduced-motion: reduce) {
2276+
.jumpToLatestSurface,
2277+
.jumpToLatest[data-visible="true"] .jumpToLatestSurface {
2278+
transform: none;
2279+
filter: none;
2280+
transition-property: opacity, visibility;
2281+
}
22542282
}
22552283

22562284
.sentFromThread {

‎src/features/messages/ThreadPanel.tsx‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -975,12 +975,11 @@ function ThreadMessages({
975975
}}
976976
tabIndex={0}
977977
>
978-
{showJumpToLatest && (
979-
<JumpToLatestButton
980-
newMessageCount={newMessageCount}
981-
onClick={jumpToLatest}
982-
/>
983-
)}
978+
<JumpToLatestButton
979+
visible={showJumpToLatest}
980+
newMessageCount={newMessageCount}
981+
onClick={jumpToLatest}
982+
/>
984983
<div data-thread-rows="" inert={positioning}>
985984
{snapshot.root ? (
986985
<MessageRow

‎tests/browser/message-navigation.spec.mjs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,15 @@ test("loaded virtual rows reveal per attempt without thread reads or live-update
280280
await jump.focus();
281281
await page.keyboard.press("Enter");
282282
await expect(history).toBeFocused();
283-
await expect(jump).toHaveCount(0);
283+
await expect(jump).toHaveCount(1);
284+
await expect(
285+
jump.locator("xpath=ancestor::*[@data-visible][1]"),
286+
).toHaveAttribute("inert", "");
287+
await expect(
288+
jump.locator("xpath=ancestor::*[@data-visible][1]"),
289+
).toHaveAttribute("aria-hidden", "true");
290+
await expect(history.getByRole("button").and(jump)).toHaveCount(0);
291+
await expect(jump).toBeHidden();
284292
await composer.focus();
285293
app.append("primary", "alpha", "Live after exact timeline reveal");
286294
await expect(history).toContainText("Live after exact timeline reveal");

0 commit comments

Comments
 (0)