Skip to content

Commit

Permalink
feat: add reset button
Browse files Browse the repository at this point in the history
  • Loading branch information
gimnathperera committed Sep 27, 2023
1 parent f006299 commit 959a4cf
Show file tree
Hide file tree
Showing 4 changed files with 9,459 additions and 7,400 deletions.
6 changes: 5 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const Home: FC = () => {
onOpen();
};

const handleOnReset = (): void => {
window.location.reload();
};

const handleOnCodeChange = (newCode: string): void => {
setCode(newCode);
};
Expand Down Expand Up @@ -60,7 +64,7 @@ const Home: FC = () => {

return (
<section className='h-full'>
<Header onGenerate={handleOnGenerate} />
<Header onGenerate={handleOnGenerate} onReset={handleOnReset} />
<div className='flex justify-center gap-6 h-[calc(100vh-12rem)]'>
<CodeEditor onCodeChange={handleOnCodeChange} initialCode={code} />
<Result
Expand Down
8 changes: 6 additions & 2 deletions components/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ import { Button } from '@nextui-org/react';

type Props = {
onGenerate: () => void;
onReset: () => void;
};

const Header: FC<Props> = ({ onGenerate }) => {
const Header: FC<Props> = ({ onGenerate, onReset }) => {
return (
<div className='pb-6 text-center flex items-center justify-between'>
<h1 className='tracking-tight inline font-semibold text-[2.3rem] lg:text-3xl'>
Generate 𝔽𝕒𝕜𝕖 Data
</h1>
<div className='flex items-center gap-4'>
<Button color='default' variant='shadow' onClick={onReset}>
Reset ↻
</Button>
<Button color='primary' variant='shadow' onClick={onGenerate}>
🪄 Generate
Generate 🪄
</Button>
</div>
</div>
Expand Down
Loading

0 comments on commit 959a4cf

Please sign in to comment.