diff --git a/app/page.tsx b/app/page.tsx index 5954e31..bb2a555 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,15 +1,36 @@ 'use client'; -import { FC } from 'react'; +import { FC, useState } from 'react'; import CodeEditor from '@/components/code-editor'; import Header from '@/components/header'; import Result from '@/components/result'; +const DEFAULT_INTERFACE = `// You can use typescript interfaces like following; + +interface Person { + id: number; + firstName: string; + lastName: string; + age: number; + bio: string; +} +`; + const Home: FC = () => { + const [code, setCode] = useState(DEFAULT_INTERFACE); + + const handleOnGenerate = (): void => { + console.log('*********', code); + }; + + const handleOnCodeChange = (newCode: string): void => { + setCode(newCode); + }; + return (
-
+
- +
diff --git a/components/code-editor/index.tsx b/components/code-editor/index.tsx index babddec..bd09670 100644 --- a/components/code-editor/index.tsx +++ b/components/code-editor/index.tsx @@ -1,26 +1,27 @@ 'use client'; -import { FC } from 'react'; +import { FC, useCallback, useState } from 'react'; import Editor from '@monaco-editor/react'; import { Spinner } from '@nextui-org/react'; -type Props = {}; +type Props = { onCodeChange: (code: string) => void; initialCode: string }; + +const CodeEditor: FC = ({ onCodeChange, initialCode }) => { + const [code, setCode] = useState(initialCode); + + const handleCodeChange = useCallback( + (value: string | undefined): void => { + const newCode = value ?? ''; + setCode(newCode); + onCodeChange(newCode); + }, + [onCodeChange], + ); -const CodeEditor: FC = ({}) => { return (
= ({}) => { fontSize: 14, }} loading={} + onChange={handleCodeChange} + value={code} />
diff --git a/components/header/index.tsx b/components/header/index.tsx index 641a5ca..cc970d3 100644 --- a/components/header/index.tsx +++ b/components/header/index.tsx @@ -1,9 +1,11 @@ import React, { FC } from 'react'; import { Dropdown, DropdownTrigger, DropdownMenu, DropdownItem, Button } from '@nextui-org/react'; -type Props = {}; +type Props = { + onGenerate: () => void; +}; -const Header: FC = () => { +const Header: FC = ({ onGenerate }) => { return (

@@ -20,7 +22,7 @@ const Header: FC = () => { 100 -

diff --git a/components/icons.tsx b/components/icons.tsx index c9ebc1b..e2800fd 100644 --- a/components/icons.tsx +++ b/components/icons.tsx @@ -1,39 +1,6 @@ import * as React from 'react'; import { IconSvgProps } from '@/types'; -export const Logo: React.FC = ({ size = 36, width, height, ...props }) => ( - - - -); - -export const DiscordIcon: React.FC = ({ size = 24, width, height, ...props }) => { - return ( - - - - ); -}; - -export const TwitterIcon: React.FC = ({ size = 24, width, height, ...props }) => { - return ( - - - - ); -}; - export const GithubIcon: React.FC = ({ size = 24, width, height, ...props }) => { return ( @@ -46,113 +13,3 @@ export const GithubIcon: React.FC = ({ size = 24, width, height, . ); }; - -export const MoonFilledIcon: React.FC = ({ size = 24, width, height, ...props }) => ( - -); - -export const SunFilledIcon: React.FC = ({ size = 24, width, height, ...props }) => ( - -); - -export const HeartFilledIcon: React.FC = ({ size = 24, width, height, ...props }) => ( - -); - -export const SearchIcon: React.FC = props => ( - -); - -export const NextUILogo: React.FC = props => { - const { width, height = 40 } = props; - - return ( - - - - - - ); -}; diff --git a/components/navbar/index.tsx b/components/navbar/index.tsx index b6959dd..e0baf2e 100644 --- a/components/navbar/index.tsx +++ b/components/navbar/index.tsx @@ -21,7 +21,7 @@ export const Navbar: FC = () => { - logo + logo Mocktopus