open-swe/apps/web/src/utils/scroll-utils.tsx
Brace Sproul 9d7a74a976
Staging june24 (#319)
* empty state programmer planner tabs

* add scroll: on pageload, buttonclick, tabswitch

* format

* init step dark mode style

* format

* submit button styling

* improve to use brand variant

* increase to 8x8px and change padding to adjust btn pos

* minor format

* fix light theme repo hover styling

* bump deps

* fix input button styling

* fix styling for scroll to bottom

---------

Co-authored-by: starmorph <dylan@starmorph.com>
Co-authored-by: Dylan Boudro <121908331+starmorph@users.noreply.github.com>
2025-06-26 15:08:16 -06:00

45 lines
1.1 KiB
TypeScript

import { ReactNode } from "react";
import { Button } from "@/components/ui/button";
import { ArrowDown } from "lucide-react";
import { useStickToBottomContext } from "use-stick-to-bottom";
export function StickyToBottomContent(props: {
content: ReactNode;
footer?: ReactNode;
className?: string;
contentClassName?: string;
}) {
const context = useStickToBottomContext();
return (
<div
ref={context.scrollRef}
style={{ width: "100%", height: "100%" }}
className={props.className}
>
<div
ref={context.contentRef}
className={props.contentClassName}
>
{props.content}
</div>
{props.footer}
</div>
);
}
export function ScrollToBottom(props: { className?: string }) {
const { isAtBottom, scrollToBottom } = useStickToBottomContext();
if (isAtBottom) return null;
return (
<Button
variant="outline"
size="sm"
className={props.className}
onClick={() => scrollToBottom()}
>
<ArrowDown className="h-4 w-4" />
<span>Scroll to bottom</span>
</Button>
);
}