Skip to content

Commit 9232cc8

Browse files
committed
feat(studio): make flat accordion group headers sticky top and bottom
1 parent fa4d579 commit 9232cc8

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎packages/studio/src/components/editor/propertyPanelFlatPrimitives.test.tsx‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ describe("FlatGroup", () => {
125125
</FlatGroup>,
126126
);
127127
expect(host.querySelector('[data-testid="body"]')).not.toBeNull();
128+
const header = host.querySelector('[data-flat-group-open="true"] > div');
129+
expect(header?.className).toContain("sticky");
130+
expect(header?.className).toContain("top-0");
131+
expect(header?.className).toContain("bottom-0");
132+
expect(header?.className).toContain("bg-panel-bg");
128133
const pin = host.querySelector<HTMLButtonElement>('[data-flat-group-pin="true"]');
129134
act(() => pin?.dispatchEvent(new MouseEvent("click", { bubbles: true })));
130135
expect(onTogglePin).toHaveBeenCalledTimes(1);
@@ -148,6 +153,10 @@ describe("FlatGroup", () => {
148153
expect(host.querySelector('[data-testid="body"]')).toBeNull();
149154
expect(host.textContent).toContain("fill none · 100%");
150155
const row = host.querySelector<HTMLButtonElement>('[data-flat-group-collapsed="true"]');
156+
expect(row?.className).toContain("sticky");
157+
expect(row?.className).toContain("top-0");
158+
expect(row?.className).toContain("bottom-0");
159+
expect(row?.className).toContain("bg-panel-bg");
151160
act(() => row?.dispatchEvent(new MouseEvent("click", { bubbles: true })));
152161
expect(onToggleOpen).toHaveBeenCalledTimes(1);
153162
act(() => root.unmount());
@@ -469,6 +478,11 @@ describe("PinnedGroupRow", () => {
469478
expect(host.textContent).toContain("Pinned");
470479
expect(host.textContent).toContain("Motion");
471480
expect(host.querySelector('[data-testid="body"]')).not.toBeNull();
481+
const header = host.querySelector('[data-pinned-group="true"] > div');
482+
expect(header?.className).toContain("sticky");
483+
expect(header?.className).toContain("top-0");
484+
expect(header?.className).toContain("bottom-0");
485+
expect(header?.className).toContain("bg-panel-bg");
472486
const unpin = host.querySelector<HTMLButtonElement>('[data-pinned-group-unpin="true"]');
473487
act(() => unpin?.dispatchEvent(new MouseEvent("click", { bubbles: true })));
474488
expect(onUnpin).toHaveBeenCalledTimes(1);

‎packages/studio/src/components/editor/propertyPanelFlatPrimitives.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export function FlatGroup({
161161
type="button"
162162
data-flat-group-collapsed="true"
163163
onClick={onToggleOpen}
164-
className="flex min-h-10 w-full items-center justify-between gap-2 border-b border-panel-hairline px-4 text-left"
164+
className="sticky top-0 bottom-0 z-10 flex min-h-10 w-full items-center justify-between gap-2 border-b border-panel-hairline bg-panel-bg px-4 text-left"
165165
>
166166
<span className="flex min-w-0 items-center gap-2">
167167
<span className="text-[12px] font-medium text-panel-text-2">{title}</span>
@@ -186,7 +186,7 @@ export function FlatGroup({
186186

187187
return (
188188
<div className="border-b border-panel-hairline px-4 py-3" data-flat-group-open="true">
189-
<div className="mb-2.5 flex items-center justify-between">
189+
<div className="sticky top-0 bottom-0 z-10 -mx-4 mb-2.5 flex items-center justify-between bg-panel-bg px-4">
190190
<span className="text-[12px] font-semibold text-panel-text-0">{title}</span>
191191
<span className="flex items-center gap-2.5 text-panel-text-5">
192192
{accessory}
@@ -467,7 +467,7 @@ export function PinnedGroupRow({
467467
}) {
468468
return (
469469
<div className="border-b border-panel-hairline px-4 py-3" data-pinned-group="true">
470-
<div className="mb-2.5 flex items-center justify-between">
470+
<div className="sticky top-0 bottom-0 z-10 -mx-4 mb-2.5 flex items-center justify-between bg-panel-bg px-4">
471471
<span className="flex items-center gap-1.5">
472472
<span className="text-[9px] font-semibold uppercase tracking-[0.08em] text-panel-accent">
473473
Pinned

0 commit comments

Comments
 (0)