Showing
9 changed files
with
92 additions
and
36 deletions
1 | function Footer() { | 1 | function Footer() { |
2 | return ( | 2 | return ( |
3 | - <div>Copyright @ SungJin. All right reserved.</div> | 3 | + <div className="footer"> |
4 | + <span>Copyright @ </span> | ||
5 | + <a href="https://github.com/taintlesscupcake" className="to-blue-400">SungJin</a> | ||
6 | + <span>. All right reserved.</span> | ||
7 | + </div > | ||
4 | ) | 8 | ) |
5 | } | 9 | } |
6 | 10 | ... | ... |
... | @@ -12,6 +12,7 @@ import Islogin from "./islogin" | ... | @@ -12,6 +12,7 @@ import Islogin from "./islogin" |
12 | import Link from "next/link" | 12 | import Link from "next/link" |
13 | 13 | ||
14 | function Header() { | 14 | function Header() { |
15 | + | ||
15 | return ( | 16 | return ( |
16 | <header className="flex flex-col sm:flex-row m-5 justify-between items-center"> | 17 | <header className="flex flex-col sm:flex-row m-5 justify-between items-center"> |
17 | <Link href="/" passHref> | 18 | <Link href="/" passHref> |
... | @@ -20,14 +21,13 @@ function Header() { | ... | @@ -20,14 +21,13 @@ function Header() { |
20 | <p className="text-7xl font-extrabold" >Learn In Web</p> | 21 | <p className="text-7xl font-extrabold" >Learn In Web</p> |
21 | </div></Link> | 22 | </div></Link> |
22 | <div className="flex flex-grow justify-evenly max-w-sm"> | 23 | <div className="flex flex-grow justify-evenly max-w-sm"> |
23 | - <HeaderItem title='HOME' Icon={HomeIcon} /> | 24 | + <HeaderItem title='HOME' Icon={HomeIcon} link="/" /> |
24 | - <HeaderItem title='STAR' Icon={StarIcon} /> | 25 | + <HeaderItem title='STAR' Icon={StarIcon} link="/" /> |
25 | - <HeaderItem title='SEARCH' Icon={SearchIcon} /> | 26 | + <HeaderItem title='SEARCH' Icon={SearchIcon} link="/" /> |
26 | - <HeaderItem title='ACCOUNT' Icon={UserIcon} /> | 27 | + <HeaderItem title='ACCOUNT' Icon={UserIcon} link="/" /> |
28 | + <Islogin /> | ||
27 | </div> | 29 | </div> |
28 | - <Islogin /> | ||
29 | </header> | 30 | </header> |
30 | - | ||
31 | ) | 31 | ) |
32 | } | 32 | } |
33 | 33 | ... | ... |
1 | -function HeaderItem({ Icon, title }) { | 1 | +import Link from "next/link" |
2 | + | ||
3 | +function HeaderItem({ Icon, title, link }) { | ||
2 | return ( | 4 | return ( |
3 | - <div className="flex flex-col items-center cursor-pointer group w-12 sm:w-20 hover:text-white"> | 5 | + <Link href={link}> |
4 | - <Icon className="h-8 mb-1 group-hover:animate-bounce"/> | 6 | + <div className="flex flex-col items-center cursor-pointer group w-12 sm:w-20 hover:text-white"> |
5 | - <p className="opacity-0 group-hover:opacity-100 tracking-widest">{title}</p> | 7 | + <Icon className="h-8 mb-1 group-hover:animate-bounce" /> |
6 | - </div> | 8 | + <p className="opacity-0 group-hover:opacity-100 tracking-widest">{title}</p> |
9 | + </div> | ||
10 | + </Link> | ||
7 | ) | 11 | ) |
8 | } | 12 | } |
9 | 13 | ... | ... |
... | @@ -8,14 +8,24 @@ export default function Popular() { | ... | @@ -8,14 +8,24 @@ export default function Popular() { |
8 | useEffect(() => { | 8 | useEffect(() => { |
9 | getPosts(10).then(setPosts); | 9 | getPosts(10).then(setPosts); |
10 | }, []); | 10 | }, []); |
11 | + | ||
12 | + const DateType = (date) => { | ||
13 | + console.log(date); | ||
14 | + const dateObj = new Date(date); | ||
15 | + const month = dateObj.toLocaleString("default", { month: "long" }); | ||
16 | + const day = dateObj.getDate(); | ||
17 | + const year = dateObj.getFullYear(); | ||
18 | + return dateObj.toLocaleString(); | ||
19 | + } | ||
11 | return ( | 20 | return ( |
12 | <div> | 21 | <div> |
13 | <ul> | 22 | <ul> |
14 | {posts.map(post => ( | 23 | {posts.map(post => ( |
15 | <li key={post.id}> | 24 | <li key={post.id}> |
16 | - <Link href={`/post/${post.id}`}> | 25 | + <Link href={`/post/${post.id}`} className="text-xl"> |
17 | <a>{post.title}</a> | 26 | <a>{post.title}</a> |
18 | </Link> | 27 | </Link> |
28 | + <span className="float-right">{DateType(post.createdAt)}</span> | ||
19 | </li> | 29 | </li> |
20 | ))} | 30 | ))} |
21 | </ul> | 31 | </ul> | ... | ... |
... | @@ -6,8 +6,10 @@ import Footer from '../components/Footer' | ... | @@ -6,8 +6,10 @@ import Footer from '../components/Footer' |
6 | function MyApp({ Component, pageProps }) { | 6 | function MyApp({ Component, pageProps }) { |
7 | return ( | 7 | return ( |
8 | <div> | 8 | <div> |
9 | - <Header /> | 9 | + <div className="main"> |
10 | - <Nav /> | 10 | + <Header /> |
11 | + <Nav /> | ||
12 | + </div> | ||
11 | <Component {...pageProps} /> | 13 | <Component {...pageProps} /> |
12 | <Footer /> | 14 | <Footer /> |
13 | </div> | 15 | </div> | ... | ... |
... | @@ -11,8 +11,10 @@ export default function Home() { | ... | @@ -11,8 +11,10 @@ export default function Home() { |
11 | <link rel="icon" href="/favicon.ico" /> | 11 | <link rel="icon" href="/favicon.ico" /> |
12 | </Head> | 12 | </Head> |
13 | {/* 기본 컨텐츠 */} | 13 | {/* 기본 컨텐츠 */} |
14 | - <Header as='h3' textAlign='center'>인기 문제</Header> | 14 | + <div className='ui container fixed left-10'> |
15 | - <Popular /> | 15 | + <h3 className="text-3xl font-bold">인기 문제</h3> |
16 | + <Popular /> | ||
17 | + </div> | ||
16 | </div> | 18 | </div> |
17 | ) | 19 | ) |
18 | } | 20 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -4,6 +4,7 @@ import "@uiw/react-textarea-code-editor/dist.css"; | ... | @@ -4,6 +4,7 @@ import "@uiw/react-textarea-code-editor/dist.css"; |
4 | import dynamic from "next/dynamic"; | 4 | import dynamic from "next/dynamic"; |
5 | import { useEffect, useState } from "react"; | 5 | import { useEffect, useState } from "react"; |
6 | import { Button } from "semantic-ui-react"; | 6 | import { Button } from "semantic-ui-react"; |
7 | +import { run } from "../../api/runner"; | ||
7 | 8 | ||
8 | const CodeEditor = dynamic( | 9 | const CodeEditor = dynamic( |
9 | () => import("@uiw/react-textarea-code-editor").then((mod) => mod.default), | 10 | () => import("@uiw/react-textarea-code-editor").then((mod) => mod.default), |
... | @@ -29,14 +30,17 @@ export default function Post() { | ... | @@ -29,14 +30,17 @@ export default function Post() { |
29 | 30 | ||
30 | const [code, setCode] = useState(""); | 31 | const [code, setCode] = useState(""); |
31 | 32 | ||
32 | - const runCode = () => { | 33 | + const [answer, setAnswer] = useState("asdf"); |
33 | - Runner.run(code, value); | 34 | + |
35 | + const runCode = async function () { | ||
36 | + var result = await run(code, value); | ||
37 | + console.log(result); | ||
38 | + setAnswer(`출력 : ${result}`); | ||
34 | } | 39 | } |
35 | 40 | ||
36 | return ( | 41 | return ( |
37 | <div> | 42 | <div> |
38 | - <h1>{post.title}</h1> | 43 | + <h3 className="text-3xl font-bold">{post.title}</h3> |
39 | - <p>{post.explain}</p> | ||
40 | <p>{post.testinput}</p> | 44 | <p>{post.testinput}</p> |
41 | <p>{post.testoutput}</p> | 45 | <p>{post.testoutput}</p> |
42 | <select value={value} onChange={(e) => setValue(e.target.value)}> | 46 | <select value={value} onChange={(e) => setValue(e.target.value)}> |
... | @@ -44,20 +48,29 @@ export default function Post() { | ... | @@ -44,20 +48,29 @@ export default function Post() { |
44 | <option value="cpp">cpp</option> | 48 | <option value="cpp">cpp</option> |
45 | <option value="js">javascript</option> | 49 | <option value="js">javascript</option> |
46 | </select> | 50 | </select> |
47 | - <CodeEditor | 51 | + <span className="left-100 fixed text-2xl font-semibold">문제 설명</span> |
48 | - value={code} | 52 | + <br></br> |
49 | - language={value} | 53 | + <div className="w-6/12 inline-block"> |
50 | - placeholder="Please Enter the Code." | 54 | + <CodeEditor |
51 | - onChange={(e) => setCode(e.target.value)} | 55 | + value={code} |
52 | - padding={15} | 56 | + language={value} |
53 | - style={{ | 57 | + placeholder="Please Enter the Code." |
54 | - fontSize: 12, | 58 | + onChange={(e) => setCode(e.target.value)} |
55 | - backgroundColor: "#f5f5f5", | 59 | + padding={15} |
56 | - fontFamily: | 60 | + style={{ |
57 | - "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace" | 61 | + fontSize: 15, |
58 | - }} | 62 | + backgroundColor: "#f5f5f5", |
59 | - /> | 63 | + fontFamily: |
60 | - <Button onClick={runCode}>Run</Button> | 64 | + "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace" |
65 | + }} | ||
66 | + className="w-8/12 h-96 rounded" | ||
67 | + | ||
68 | + /> | ||
69 | + </div> | ||
70 | + <div className="w-6/12 inline-block align-top">{post.explain}</div> | ||
71 | + <Button onClick={runCode} className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Run</Button> | ||
72 | + <p>{runCode}</p> | ||
73 | + | ||
61 | <p>{post.example}</p> | 74 | <p>{post.example}</p> |
62 | </div> | 75 | </div> |
63 | ) | 76 | ) | ... | ... |
... | @@ -16,6 +16,27 @@ body { | ... | @@ -16,6 +16,27 @@ body { |
16 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; | 16 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; |
17 | } | 17 | } |
18 | 18 | ||
19 | +h3{ | ||
20 | + font-size: 1.5rem; | ||
21 | + font-weight: 500; | ||
22 | + line-height: 1.5; | ||
23 | + margin-bottom: 0.5rem; | ||
24 | +} | ||
25 | + | ||
26 | +.main { | ||
27 | + margin-bottom: 2rem; | ||
28 | +} | ||
29 | + | ||
30 | +span.left-100.fixed { | ||
31 | + left: 50%; | ||
32 | +} | ||
33 | + | ||
34 | +.footer { | ||
35 | + position: absolute; | ||
36 | + bottom: 0; | ||
37 | + left: 0; | ||
38 | +} | ||
39 | + | ||
19 | a { | 40 | a { |
20 | color: inherit; | 41 | color: inherit; |
21 | text-decoration: none; | 42 | text-decoration: none; | ... | ... |
-
Please register or login to post a comment