Skip to content

Commit d75de19

Browse files
authored
feat: add fullscreen button (#31)
* feat: add fullscreen button * chore: update playwright * chore: remove pnpm lock
1 parent a299363 commit d75de19

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

bun.lockb

3.82 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"zustand": "5.0.0"
5959
},
6060
"devDependencies": {
61-
"@playwright/test": "^1.53.1",
61+
"@playwright/test": "^1.56.1",
6262
"@types/node": "^22.8.4",
6363
"@types/react": "^18.3.12",
6464
"@types/react-dom": "^18.3.1",

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
import { restrictToHorizontalAxis } from "@dnd-kit/modifiers"
1515
import { horizontalListSortingStrategy, SortableContext, useSortable } from "@dnd-kit/sortable"
1616
import { CSS } from "@dnd-kit/utilities"
17-
import { IconChevronDown, IconPlus } from "@tabler/icons-react"
17+
import { IconChevronDown, IconMaximize, IconPlus } from "@tabler/icons-react"
1818

1919
import { Button } from "@/components/ui/button"
2020
import {
@@ -122,7 +122,7 @@ const SortableTab = ({ id }: { id: TabId }) => {
122122
)
123123
}
124124

125-
export const DatabrowserTabs = () => {
125+
export const DatabrowserTabs = ({ onFullScreenClick }: { onFullScreenClick?: () => void }) => {
126126
const { tabs, reorderTabs, selectedTab, selectTab } = useDatabrowserStore()
127127

128128
// Sort tabs with pinned tabs first
@@ -262,6 +262,17 @@ export const DatabrowserTabs = () => {
262262
<div className="flex items-center gap-1 pl-1">
263263
{isOverflow && <AddTabButton />}
264264
{tabs.length > 1 && <TabsListButton tabs={tabs} onSelectTab={selectTab} />}
265+
{onFullScreenClick && (
266+
<Button
267+
aria-label="Toggle fullscreen"
268+
variant="secondary"
269+
size="icon-sm"
270+
onClick={onFullScreenClick}
271+
className="flex-shrink-0 bg-blue-100 hover:bg-blue-600 hover:text-white"
272+
>
273+
<IconMaximize size={16} />
274+
</Button>
275+
)}
265276
</div>
266277
</div>
267278
</div>

src/components/databrowser/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,17 @@ export const RedisBrowser = ({
2626
url,
2727
hideTabs,
2828
storage,
29+
onFullScreenClick,
2930
}: RedisCredentials & {
3031
hideTabs?: boolean
3132

33+
/**
34+
* If defined, the databrowser will have a full screen button in the tab bar.
35+
* Clicking on the button will call this function.
36+
* @returns
37+
*/
38+
onFullScreenClick?: () => void
39+
3240
/**
3341
* Persistence storage for the Databrowser.
3442
*
@@ -60,7 +68,7 @@ export const RedisBrowser = ({
6068
style={{ height: "100%", display: "flex", flexDirection: "column" }}
6169
ref={rootRef}
6270
>
63-
{!hideTabs && <DatabrowserTabs />}
71+
{!hideTabs && <DatabrowserTabs onFullScreenClick={onFullScreenClick} />}
6472
<DatabrowserInstances />
6573
</div>
6674
</TooltipProvider>

src/playground/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ const App = () => {
4040
>
4141
{credentials ? (
4242
<RedisBrowser
43+
onFullScreenClick={() => {
44+
// eslint-disable-next-line no-console
45+
console.log("Fullscreen button clicked")
46+
}}
4347
storage={{
4448
get: () => localStorage.getItem("redis-browser-data") || "",
4549
set: (value) => localStorage.setItem("redis-browser-data", value),

0 commit comments

Comments
 (0)