diff --git a/apps/playground-web/components/Overlays/CommandPanel.tsx b/apps/playground-web/components/Overlays/CommandPanel.tsx new file mode 100644 index 0000000..d882a38 --- /dev/null +++ b/apps/playground-web/components/Overlays/CommandPanel.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import SearchBox from '../Search/SearchBox'; +import { Terminal, X } from 'lucide-react'; +import { useCommandContext } from '@/context/command'; + +const CommandPanel = () => { + const { setIsOpen, isOpen } = useCommandContext(); + + return ( +
+
+
+ +

DiceDB Commands

+
+ + +
+ +
+ ); +}; + +export default CommandPanel; diff --git a/apps/playground-web/components/Playground/Playground.tsx b/apps/playground-web/components/Playground/Playground.tsx index ca5b225..fe0c39c 100644 --- a/apps/playground-web/components/Playground/Playground.tsx +++ b/apps/playground-web/components/Playground/Playground.tsx @@ -6,47 +6,18 @@ import { TerminalUI } from './TerminalUI'; import Link from 'next/link'; import { Button } from '@dicedb/ui/button'; import GitHub from '@mui/icons-material/GitHub'; - -// utils - -export default function Playground() { - return ( -
-
- -
-
- -
-
-
- -
-
-
-
- ); -} +import { Terminal } from 'lucide-react'; +import CommandProvider, { useCommandContext } from '@/context/command'; +import CommandPanel from '../Overlays/CommandPanel'; function Header() { + const { setIsOpen } = useCommandContext(); return (
-
+
-

PlayGround

+

PlayGround

- +
+ + + - +
); } + +function Commands() { + return ( + <> +
+ +
+
+
+ +
+
+ + ); +} + +function PlaygroundUI() { + const { isOpen } = useCommandContext(); + return ( +
+
+ +
+
+ +
+ +
+
+ ); +} + +export default function Playground() { + return ( + + + + ); +} diff --git a/apps/playground-web/components/Playground/TerminalUI.tsx b/apps/playground-web/components/Playground/TerminalUI.tsx index 3311c53..5de599d 100644 --- a/apps/playground-web/components/Playground/TerminalUI.tsx +++ b/apps/playground-web/components/Playground/TerminalUI.tsx @@ -16,7 +16,7 @@ export function TerminalUI({ initialCommandsLeft = 1000 }) { return ( <>
@@ -27,7 +27,7 @@ export function TerminalUI({ initialCommandsLeft = 1000 }) {
@@ -50,8 +50,9 @@ function TerminalCounter({ }) { return (
-
-
+
+ +
-
- -
-
- -

- DiceDB instance is shared across all users. -

-
+
); } + +const InstanceMessage = ({ + extraClassname = '', +}: { + extraClassname?: string; +}) => { + return ( +
+ +

+ DiceDB instance is shared across all users. +

+
+ ); +}; diff --git a/apps/playground-web/components/Search/CommandPage.tsx b/apps/playground-web/components/Search/CommandPage.tsx index 123a580..e9ffbba 100644 --- a/apps/playground-web/components/Search/CommandPage.tsx +++ b/apps/playground-web/components/Search/CommandPage.tsx @@ -31,7 +31,7 @@ export default function CommandPage({ return (

-

Syntax

+

Syntax

{isCopied && (
-

+

Description

diff --git a/apps/playground-web/components/Search/SearchBox.tsx b/apps/playground-web/components/Search/SearchBox.tsx index 38bc99d..8bd4f6e 100644 --- a/apps/playground-web/components/Search/SearchBox.tsx +++ b/apps/playground-web/components/Search/SearchBox.tsx @@ -1,12 +1,13 @@ 'use client'; -import { useMemo, useState } from 'react'; +import { useMemo, useRef, useState } from 'react'; import { Search } from 'lucide-react'; import { DiceCmds, DiceCmdMeta } from '@/data/command'; import CommandPage from './CommandPage'; export default function SearchBox() { const [search, setSearch] = useState(''); + const scrollRef = useRef(null); const filteredCommands = useMemo( () => Object.values(DiceCmds).filter((cmd: DiceCmdMeta) => @@ -33,7 +34,10 @@ export default function SearchBox() { />
-
+
{filteredCommands.map((cmdMeta) => ( ))} + + {filteredCommands.length === 0 && }
diff --git a/apps/playground-web/context/command.tsx b/apps/playground-web/context/command.tsx new file mode 100644 index 0000000..9c5d204 --- /dev/null +++ b/apps/playground-web/context/command.tsx @@ -0,0 +1,23 @@ +import { createContext, useContext, useState } from 'react'; + +const CommandContext = createContext<{ + isOpen: boolean; + setIsOpen: (isOpen: boolean) => void; +}>({ + isOpen: true, + setIsOpen: () => {}, +}); + +export const useCommandContext = () => useContext(CommandContext); + +const CommandProvider = ({ children }: { children: React.ReactNode }) => { + const [isOpen, setIsOpen] = useState(false); + + return ( + + {children} + + ); +}; + +export default CommandProvider; diff --git a/apps/playground-web/styles/globals.css b/apps/playground-web/styles/globals.css index a6b1fdd..3404ba8 100644 --- a/apps/playground-web/styles/globals.css +++ b/apps/playground-web/styles/globals.css @@ -16,3 +16,22 @@ body { .width-absolute { width: 100%; } + +.mobile-scrollbar::-webkit-scrollbar { + width: 6px; +} + +.mobile-scrollbar::-webkit-scrollbar-track { + background: #f1f1f1; + cursor: pointer; +} + +.mobile-scrollbar::-webkit-scrollbar-thumb { + background: #88888888; + border-radius: 10px; + width: 5px; +} + +.mobile-scrollbar::-webkit-scrollbar-thumb:hover { + background: #555; +} \ No newline at end of file diff --git a/packages/ui/src/button.tsx b/packages/ui/src/button.tsx index f5a962d..2672a80 100644 --- a/packages/ui/src/button.tsx +++ b/packages/ui/src/button.tsx @@ -7,6 +7,7 @@ interface ButtonProps { className?: string; variant?: 'default' | 'outline'; 'data-testid'?: string; + onClick?: () => void; } const baseClasses = @@ -19,6 +20,7 @@ const variantClasses = { export function Button({ children, + onClick, className = '', variant = 'default', ...props @@ -26,6 +28,7 @@ export function Button({ return (