Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use fixed height for bottom bar #23

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 69 additions & 42 deletions src/components/bottom-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,60 +21,87 @@ export function BottomBar() {
const handleExpand = () => {
const panel = ref.current
if (panel) {
setCollapsed(panel.getSize() <= 3)
console.log(panel.getSize())
if (panel.getSize() <= 5) {
panel.collapse()
}
setCollapsed(panel.getSize() === 0)
}
}
const expandBottomBar = () => {
const panel = ref.current
if (panel) {
panel.resize(panel.getSize() > 3 ? 3 : 65)
panel.isCollapsed() ? panel.resize(65) : panel.collapse()
setCollapsed(panel.isCollapsed())
}
}

return (
<ResizablePanel
ref={ref}
defaultSize={3}
minSize={3}
maxSize={65}
onResize={handleExpand}
className="p-4 space-y-4"
>
<div className="flex items-center justify-between">
<p className="font-medium text-sm">Results</p>
<Button variant="outline" size="icon" className="size-8" onClick={expandBottomBar}>
{collapsed ? <ChevronsUp size={20} /> : <ChevronsDown size={20} />}
</Button>
</div>
<div className="h-[calc(100%-4rem)] overflow-y-auto bg-muted px-3 py-1 rounder border border-border">
{isError ? (
<div className="flex flex-col gap-4 items-center justify-center h-full">
<XCircle size={36} strokeWidth={2.5} className="text-muted-foreground flex-shrink-0" />
<div className="space-y-2 text-center">
<p className="text-muted-foreground text-sm">
Error fetching data.
<br />
{error.message}
</p>
<>
{collapsed && (
<div className="flex items-center justify-between px-4 py-2">
<p className="font-medium text-sm">Results</p>
<Button variant="outline" size="icon" className="size-8" onClick={expandBottomBar}>
{collapsed ? <ChevronsUp size={20} /> : <ChevronsDown size={20} />}
</Button>
</div>
)}
<ResizablePanel
collapsible
ref={ref}
defaultSize={0}
minSize={5}
maxSize={65}
onResize={handleExpand}
>
{!collapsed && (
<div className="px-4 py-2 space-y-4 h-full">
<div className="flex items-center justify-between">
<p className="font-medium text-sm">Results</p>
<Button variant="outline" size="icon" className="size-8" onClick={expandBottomBar}>
{collapsed ? <ChevronsUp size={20} /> : <ChevronsDown size={20} />}
</Button>
</div>
</div>
) : !data ? (
<div className="flex flex-col gap-4 items-center justify-center h-full">
<Braces size={36} strokeWidth={2.5} className="text-muted-foreground flex-shrink-0" />
<div className="space-y-2 text-center">
<p className="text-muted-foreground text-sm">
No results.
<br />
You can send messages and queries from the sidebar.
</p>
<div className="h-[calc(100%-4rem)] overflow-y-auto bg-muted px-3 py-1 rounder border border-border">
{isError ? (
<div className="flex flex-col gap-4 items-center justify-center h-full">
<XCircle
size={36}
strokeWidth={2.5}
className="text-muted-foreground flex-shrink-0"
/>
<div className="space-y-2 text-center">
<p className="text-muted-foreground text-sm">
Error fetching data.
<br />
{error.message}
</p>
</div>
</div>
) : !data ? (
<div className="flex flex-col gap-4 items-center justify-center h-full">
<Braces
size={36}
strokeWidth={2.5}
className="text-muted-foreground flex-shrink-0"
/>
<div className="space-y-2 text-center">
<p className="text-muted-foreground text-sm">
No results.
<br />
You can send messages and queries from the sidebar.
</p>
</div>
</div>
) : (
<div className="font-mono text-xs whitespace-pre-wrap">
{JSON.stringify(data, null, 2)}
</div>
)}
</div>
</div>
) : (
<div className="font-mono text-xs whitespace-pre-wrap">
{JSON.stringify(data, null, 2)}
</div>
)}
</div>
</ResizablePanel>
</ResizablePanel>
</>
)
}
2 changes: 1 addition & 1 deletion src/components/ui/toaster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function Toaster() {

return (
<ToastProvider>
{toasts.map(function({ id, title, description, action, ...props }) {
{toasts.map(function ({ id, title, description, action, ...props }) {
return (
<Toast key={id} {...props}>
<div className="grid gap-1">
Expand Down