mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 19:43:15 +00:00
46 lines
1.1 KiB
TypeScript
46 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>
|
||
|
|
);
|
||
|
|
}
|