-
Notifications
You must be signed in to change notification settings - Fork 1
DX-1485: Multi tabs and search history #17
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
Open
ytkimirti
wants to merge
8
commits into
master
Choose a base branch
from
DX-1485
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
65458ea
feat: add multiple tab support
ytkimirti ab3be4c
feat: add search history
ytkimirti ee65c53
feat: add keyboard support to the search
ytkimirti 669505b
chore: unused import
ytkimirti 076d253
chore: remove unusued hook
ytkimirti 2921747
chore: rename the custom scroll component argument
ytkimirti 92f561e
chore: update playground for easier debugging
ytkimirti f00dcf6
feat: add hideTabs option and fix styles
ytkimirti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/components/databrowser/components/databrowser-instance.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels" | ||
|
||
import { cn } from "@/lib/utils" | ||
import { Toaster } from "@/components/ui/toaster" | ||
import { DataDisplay } from "./display" | ||
import { Sidebar } from "./sidebar" | ||
import { KeysProvider } from "../hooks/use-keys" | ||
|
||
export const DatabrowserInstance = ({ hidden }: { hidden?: boolean }) => { | ||
return ( | ||
<KeysProvider> | ||
<div className={cn("min-h-0 grow rounded-md bg-zinc-100", hidden && "hidden")}> | ||
<PanelGroup | ||
autoSaveId="persistence" | ||
direction="horizontal" | ||
className="h-full w-full gap-0.5 text-sm antialiased" | ||
> | ||
<Panel defaultSize={30} minSize={30}> | ||
<Sidebar /> | ||
</Panel> | ||
<PanelResizeHandle className="group flex h-full w-1.5 justify-center"> | ||
<div className="h-full border-r border-dashed border-zinc-200 transition-colors group-hover:border-zinc-300" /> | ||
</PanelResizeHandle> | ||
<Panel minSize={40}> | ||
<DataDisplay /> | ||
</Panel> | ||
</PanelGroup> | ||
<Toaster /> | ||
</div> | ||
</KeysProvider> | ||
) | ||
} |
69 changes: 69 additions & 0 deletions
69
src/components/databrowser/components/databrowser-tabs.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { IconPlus, IconX } from "@tabler/icons-react" | ||
|
||
import { cn } from "@/lib/utils" | ||
import { Button } from "@/components/ui/button" | ||
import type { TabId } from "@/store" | ||
import { useDatabrowserStore } from "@/store" | ||
import { TabTypeIcon } from "./tab-type-icon" | ||
|
||
const Tab = ({ id }: { id: TabId }) => { | ||
const { selectTab, selectedTab, tabs, removeTab } = useDatabrowserStore() | ||
|
||
return ( | ||
<div | ||
onClick={() => selectTab(id)} | ||
className={cn( | ||
"flex h-9 cursor-pointer items-center gap-2 rounded-t-lg border border-zinc-200 px-3 text-[13px] transition-colors", | ||
id === selectedTab | ||
? "border-b-white bg-white text-zinc-900" | ||
: "bg-zinc-100 hover:bg-zinc-50" | ||
)} | ||
> | ||
{tabs[id].selectedKey ? ( | ||
<> | ||
<TabTypeIcon selectedKey={tabs[id].selectedKey} /> | ||
<span className="max-w-32 truncate whitespace-nowrap">{tabs[id].selectedKey}</span> | ||
</> | ||
) : ( | ||
<span className="whitespace-nowrap">New Tab</span> | ||
)} | ||
{/* Only show close button if there's more than one tab */} | ||
{Object.keys(tabs).length > 1 && ( | ||
<button | ||
onClick={(e) => { | ||
e.stopPropagation() | ||
removeTab(id) | ||
}} | ||
className="p-1 text-zinc-300 transition-colors hover:text-zinc-500" | ||
> | ||
<IconX size={16} /> | ||
</button> | ||
)} | ||
</div> | ||
) | ||
} | ||
|
||
export const DatabrowserTabs = () => { | ||
const { tabs, addTab } = useDatabrowserStore() | ||
|
||
return ( | ||
<div className="relative mb-2 shrink-0"> | ||
<div className="absolute bottom-0 left-0 right-0 -z-10 h-[1px] w-full bg-zinc-200" /> | ||
|
||
<div className="scrollbar-hide flex translate-y-[1px] items-center gap-1 overflow-x-scroll pb-[1px] [&::-webkit-scrollbar]:hidden"> | ||
{Object.keys(tabs).map((id) => ( | ||
<Tab id={id as TabId} key={id} /> | ||
))} | ||
<Button | ||
variant="secondary" | ||
size="icon-sm" | ||
onClick={addTab} | ||
className="mr-1 flex-shrink-0" | ||
title="Add new tab" | ||
> | ||
<IconPlus className="text-zinc-500" size={16} /> | ||
</Button> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.