Skip to content

Commit

Permalink
Merge pull request #17 from gimnathperera/15-feature-request-add-a-re…
Browse files Browse the repository at this point in the history
…set-button

feat: add reset button
  • Loading branch information
gimnathperera authored Sep 27, 2023
2 parents f006299 + 959a4cf commit eaa9522
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 eaa9522

Please sign in to comment.