-
Notifications
You must be signed in to change notification settings - Fork 56
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
#40: Refactor UI search box component #56
Open
prashant67690
wants to merge
2
commits into
DiceDB:master
Choose a base branch
from
prashant67690:fix/ui-changes
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
2 commits
Select commit
Hold shift + click to select a range
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
This file contains 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 |
---|---|---|
@@ -1,45 +1,76 @@ | ||
'use client'; | ||
|
||
import Image from 'next/image'; | ||
import { Dice1, Dice3, Dice5, Info } from 'lucide-react'; | ||
|
||
// Components | ||
import Shell from '@/components/Shell/Shell'; | ||
import SearchBox from '@/components/Search/SearchBox'; | ||
import { TerminalUI } from './TerminalUI'; | ||
|
||
// utils | ||
import { formatTime } from '@/shared/utils/commonUtils'; | ||
import { usePlayground } from './hooks/usePlayground'; | ||
|
||
export default function Playground() { | ||
const { decreaseCommandsLeft, search, timeLeft, commandsLeft, setSearch } = | ||
usePlayground(); | ||
|
||
return ( | ||
<div className="container mx-auto flex flex-col flex-grow min-h-screen bg-white text-gray-900"> | ||
<Header /> | ||
<header className="navbar flex items-center justify-between py-5"> | ||
<div className="flex items-center"> | ||
<Image | ||
src="/images/dicedb-logo-light.png" | ||
width={110} | ||
height={110} | ||
priority={true} | ||
alt="DiceDB logo" | ||
className="object-contain" | ||
unoptimized | ||
/> | ||
<h2 className="font-light text-2xl ml-2">PlayGround</h2> | ||
</div> | ||
</header> | ||
|
||
<main className="flex flex-col lg:flex-row gap-10 flex-grow overflow-hidden px-4"> | ||
<div className="w-full lg:w-7/12 flex flex-col"> | ||
<TerminalUI /> | ||
<div className="bg-gray-900 rounded-lg"> | ||
<div className="bg-gray-900 px-4 py-4 flex items-center rounded-lg"> | ||
<div className="flex space-x-2"> | ||
<Dice5 className="w-4 h-4 bg-red-500" /> | ||
<Dice1 className="w-4 h-4 bg-yellow-500" /> | ||
<Dice3 className="w-4 h-4 bg-green-500" /> | ||
</div> | ||
</div> | ||
<div className="h-64 md:h-[30rem] bg-gray-100 rounded-lg overflow-hidden shadow-md"> | ||
<Shell decreaseCommandsLeft={decreaseCommandsLeft} /> | ||
</div> | ||
</div> | ||
|
||
<div className="flex flex-col"> | ||
<div className="flex flex-row justify-between text-gray-900 mt-4"> | ||
<div className="flex justify-between border border-gray-400 text-sm bg-transparent p-3 rounded-lg"> | ||
<span>Cleanup in : {formatTime(timeLeft)} mins</span> | ||
</div> | ||
<div className="flex justify-between border border-gray-400 text-sm bg-transparent p-3 rounded-lg"> | ||
<span>Commands left: {commandsLeft}</span> | ||
</div> | ||
</div> | ||
<div className="flex flex-row items-start mt-5"> | ||
<Info className="w-4 h-4 text-gray-500 mr-1" /> | ||
<p className="text-sm text-gray-500"> | ||
DiceDB instance is shared across all users. | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div className="w-full lg:w-5/12 flex flex-col"> | ||
<div className="flex-grow border border-gray-400 bg-gray-100 p-4 rounded-lg shadow-md mb-4"> | ||
<SearchBox /> | ||
<SearchBox search={search} setSearch={setSearch} /> | ||
</div> | ||
</div> | ||
</main> | ||
</div> | ||
); | ||
} | ||
|
||
function Header() { | ||
return ( | ||
<header className="navbar flex items-center justify-between py-5"> | ||
<div className="flex items-center"> | ||
<Image | ||
src="/images/dicedb-logo-light.png" | ||
width={110} | ||
height={110} | ||
priority={true} | ||
alt="DiceDB logo" | ||
className="object-contain" | ||
unoptimized | ||
/> | ||
<h2 className="font-light text-2xl ml-2">PlayGround</h2> | ||
</div> | ||
</header> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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,29 @@ | ||
import { useState, useEffect } from 'react'; | ||
|
||
export const usePlayground = () => { | ||
const [search, setSearch] = useState(''); | ||
const [timeLeft, setTimeLeft] = useState<number>(15 * 60); | ||
const [commandsLeft, setCommandsLeft] = useState<number>(1000); | ||
|
||
useEffect(() => { | ||
const timer = setInterval(() => { | ||
setTimeLeft((prev) => (prev > 0 ? prev - 1 : 0)); | ||
}, 1000); | ||
|
||
return () => clearInterval(timer); | ||
}, []); | ||
|
||
const decreaseCommandsLeft = () => { | ||
setCommandsLeft((prev) => (prev > 0 ? prev - 1 : 0)); | ||
}; | ||
|
||
return { | ||
decreaseCommandsLeft, | ||
search, | ||
timeLeft, | ||
commandsLeft, | ||
setSearch, | ||
setTimeLeft, | ||
setCommandsLeft, | ||
}; | ||
}; |
This file contains 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,28 @@ | ||
import React from 'react'; | ||
|
||
const NotFoundPage = ({ url }: { url: string }) => { | ||
return ( | ||
<div className="p-6 bg-gray-100 text-white rounded-lg shadow-lg border border-gray-700 mb-4"> | ||
<h2 className="text-gray-700 text-2xl font-semibold mb-4"> | ||
No matching data was found🥺 | ||
</h2> | ||
|
||
<div className="flex items-center justify-between mb-4 pt-4"> | ||
<h3 className="text-gray-700 text-2xl font-semibold"> | ||
Try refining your search or browse the documentation for common | ||
commands. | ||
</h3> | ||
</div> | ||
<a | ||
href={url} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="text-blue-400 hover:text-blue-300 underline font-medium transition-colors duration-200" | ||
> | ||
View Documentation | ||
</a> | ||
</div> | ||
); | ||
}; | ||
|
||
export default NotFoundPage; |
This file contains 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 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 was deleted.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we center this vertically?