Skip to content

Commit f00dcf6

Browse files
committed
feat: add hideTabs option and fix styles
1 parent 92f561e commit f00dcf6

File tree

5 files changed

+37
-22
lines changed

5 files changed

+37
-22
lines changed

src/components/databrowser/components/databrowser-instance.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { KeysProvider } from "../hooks/use-keys"
99
export const DatabrowserInstance = ({ hidden }: { hidden?: boolean }) => {
1010
return (
1111
<KeysProvider>
12-
<div className={cn("h-full rounded-md bg-zinc-100", hidden && "hidden")}>
12+
<div className={cn("min-h-0 grow rounded-md bg-zinc-100", hidden && "hidden")}>
1313
<PanelGroup
1414
autoSaveId="persistence"
1515
direction="horizontal"

src/components/databrowser/components/databrowser-tabs.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const Tab = ({ id }: { id: TabId }) => {
1313
<div
1414
onClick={() => selectTab(id)}
1515
className={cn(
16-
"flex h-9 translate-y-[1px] cursor-pointer items-center gap-2 rounded-t-lg border border-zinc-200 px-3 text-[13px] transition-colors",
16+
"flex h-9 cursor-pointer items-center gap-2 rounded-t-lg border border-zinc-200 px-3 text-[13px] transition-colors",
1717
id === selectedTab
1818
? "border-b-white bg-white text-zinc-900"
1919
: "bg-zinc-100 hover:bg-zinc-50"
@@ -22,10 +22,10 @@ const Tab = ({ id }: { id: TabId }) => {
2222
{tabs[id].selectedKey ? (
2323
<>
2424
<TabTypeIcon selectedKey={tabs[id].selectedKey} />
25-
<span className="max-w-32 truncate">{tabs[id].selectedKey}</span>
25+
<span className="max-w-32 truncate whitespace-nowrap">{tabs[id].selectedKey}</span>
2626
</>
2727
) : (
28-
"New Tab"
28+
<span className="whitespace-nowrap">New Tab</span>
2929
)}
3030
{/* Only show close button if there's more than one tab */}
3131
{Object.keys(tabs).length > 1 && (
@@ -47,19 +47,23 @@ export const DatabrowserTabs = () => {
4747
const { tabs, addTab } = useDatabrowserStore()
4848

4949
return (
50-
<div className="mb-2 flex items-center gap-1 border-b border-zinc-200">
51-
{Object.keys(tabs).map((id) => (
52-
<Tab id={id as TabId} key={id} />
53-
))}
54-
<Button
55-
variant="secondary"
56-
size="icon-sm"
57-
onClick={addTab}
58-
className="mr-1 flex-shrink-0"
59-
title="Add new tab"
60-
>
61-
<IconPlus className="text-zinc-500" size={16} />
62-
</Button>
50+
<div className="relative mb-2 shrink-0">
51+
<div className="absolute bottom-0 left-0 right-0 -z-10 h-[1px] w-full bg-zinc-200" />
52+
53+
<div className="scrollbar-hide flex translate-y-[1px] items-center gap-1 overflow-x-scroll pb-[1px] [&::-webkit-scrollbar]:hidden">
54+
{Object.keys(tabs).map((id) => (
55+
<Tab id={id as TabId} key={id} />
56+
))}
57+
<Button
58+
variant="secondary"
59+
size="icon-sm"
60+
onClick={addTab}
61+
className="mr-1 flex-shrink-0"
62+
title="Add new tab"
63+
>
64+
<IconPlus className="text-zinc-500" size={16} />
65+
</Button>
66+
</div>
6367
</div>
6468
)
6569
}

src/components/databrowser/components/sidebar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function Sidebar() {
6868
<LoadingSkeleton />
6969
) : keys.length > 0 ? (
7070
// Infinite scroll already has a loader at the bottom
71-
<InfiniteScroll query={query} disableRoundedInherit>
71+
<InfiniteScroll query={query} disableRoundedInherit className="min-h-0">
7272
<KeysList />
7373
</InfiniteScroll>
7474
) : (

src/components/databrowser/components/sidebar/infinite-scroll.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { IconLoader2 } from "@tabler/icons-react"
33
import type { UseInfiniteQueryResult } from "@tanstack/react-query"
44

55
import { ScrollArea } from "@/components/ui/scroll-area"
6+
import { cn } from "@/lib/utils"
67

78
export const InfiniteScroll = ({
89
query,
@@ -25,9 +26,12 @@ export const InfiniteScroll = ({
2526
return (
2627
<ScrollArea
2728
type="always"
28-
className="block h-full w-full overflow-visible rounded-lg border border-zinc-200 bg-white p-1 pr-3 transition-all"
2929
onScroll={handleScroll}
3030
{...props}
31+
className={cn(
32+
"block h-full w-full overflow-visible rounded-lg border border-zinc-200 bg-white p-1 pr-3 transition-all",
33+
props.className
34+
)}
3135
>
3236
{children}
3337

src/components/databrowser/index.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import { DatabrowserInstance } from "./components/databrowser-instance"
1313
import { DatabrowserTabs } from "./components/databrowser-tabs"
1414
import { TabIdProvider } from "@/tab-provider"
1515

16-
export const RedisBrowser = ({ token, url }: RedisCredentials) => {
16+
export const RedisBrowser = ({
17+
token,
18+
url,
19+
hideTabs,
20+
}: RedisCredentials & { hideTabs?: boolean }) => {
1721
const credentials = useMemo(() => ({ token, url }), [token, url])
1822

1923
useEffect(() => {
@@ -26,8 +30,11 @@ export const RedisBrowser = ({ token, url }: RedisCredentials) => {
2630
<DatabrowserProvider>
2731
<TooltipProvider>
2832
{/* ups-db is the custom class used to prefix every style in the css bundle */}
29-
<div className="ups-db" style={{ height: "100%" }}>
30-
<DatabrowserTabs />
33+
<div
34+
className="ups-db"
35+
style={{ height: "100%", display: "flex", flexDirection: "column" }}
36+
>
37+
{!hideTabs && <DatabrowserTabs />}
3138
<DatabrowserInstances />
3239
</div>
3340
</TooltipProvider>

0 commit comments

Comments
 (0)