Skip to content
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

[김진희] Sprint 11 #326

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/BestBoard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Image from 'next/image';
import medal from '@/public/ic_medal.svg';
import heart from '@/public/ic_heart.svg';
import medal from '@/public/icons/ic_medal.svg';
import heart from '@/public/icons/ic_heart.svg';
import styles from '@/styles/BestBoard.module.css';

interface Writer {
Expand Down
2 changes: 1 addition & 1 deletion components/Comment.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Image from 'next/image';
import SelectBox from '@/components/common/SelectBox';
import Profile from '@/public/ic_profile.svg';
import Profile from '@/public/icons/ic_profile.svg';
import styles from '@/styles/Comment.module.css';

export default function Comment({ comment }) {
Expand Down
4 changes: 2 additions & 2 deletions components/EntireBoard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Image from 'next/image';
import heart from '@/public/ic_heart.svg';
import profile from '@/public/ic_profile.svg';
import heart from '@/public/icons/ic_heart.svg';
import profile from '@/public/icons/ic_profile.svg';
import styles from '@/styles/EntireBoard.module.css';

interface Writer {
Expand Down
2 changes: 1 addition & 1 deletion components/FileInput.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from 'react';
import Image from 'next/image';
import plus from '@/public/ic_plus.svg';
import plus from '@/public/icons/ic_plus.svg';
import styles from '@/styles/FileInput.module.css';

function FileInput({ name, value, onChange }) {
Expand Down
6 changes: 3 additions & 3 deletions components/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Image from 'next/image';
import Link from 'next/link';
import logo from '@/public/ic_logo.svg';
import login from '@/public/ic_login.svg';
import styles from '@/styles/Header.module.css'
import logo from '@/public/icons/ic_logo.svg';
import login from '@/public/icons/ic_login.svg';
import styles from '@/styles/Header.module.css'

function Header() {
return (
Expand Down
26 changes: 26 additions & 0 deletions components/common/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React, { ButtonHTMLAttributes, ReactNode } from 'react';
import styles from '@/styles/Common.module.css';
import classNames from 'classnames';

interface ButtonProp extends ButtonHTMLAttributes<HTMLButtonElement> {
children: ReactNode;
size: 'small' | 'medium' | 'large';
}

function Button({ children, size = 'small', ...rest }: ButtonProp) {
const buttonClass = classNames({
[styles.smallButton]: size === 'small',
[styles.mediumButton]: size === 'medium',
[styles.largeButton]: size === 'large',
});

return (
<>
<button className={buttonClass} {...rest}>
<div>{children}</div>
</button>
</>
);
}
Comment on lines +5 to +24
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

와우 ㄷㄷㄷ 👍👍👍

질문에 답변하려고 왔는데 .. 공용 컴포넌트로 손색이 없는데요 ..?


export default Button;
18 changes: 0 additions & 18 deletions components/common/SmallButton.tsx

This file was deleted.

17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"lint": "next lint"
},
"dependencies": {
"@types/classnames": "^2.3.0",
"axios": "^1.7.7",
"classnames": "^2.5.1",
"next": "13.5.6",
"react": "^18",
"react-dom": "^18"
Expand Down
8 changes: 7 additions & 1 deletion pages/_app.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
// import type { AppProps } from 'next/app'
import { useRouter } from 'next/router';
import Header from '../components/Header';
import '@/styles/globals.css';
import '@/styles/Home.module.css'
import '@/styles/JoinForm.module.css'
import '@/styles/Header.module.css';
import '@/styles/Boards.module.css';
import '@/styles/BestBoard.module.css';
import '@/styles/EntireBoard.module.css';

export default function App({ Component, pageProps }) {
const router = useRouter();
const noHeaderPages = ['/signup', '/login', '/'];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

크으 레이아웃도 조건부로 잘 작성하셨네요 👍

훌륭합니다. ㄷㄷㄷ👍👍 화이트리스트를 만들어서 특정 페이지는 노출되지 않게끔 잘 작성하셨네요 👍👍


return (
<>
<Header />
{!noHeaderPages.includes(router.pathname) && <Header />}
<Component {...pageProps} />
</>
);
Expand Down
6 changes: 3 additions & 3 deletions pages/addboard.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react';
import { useRouter } from 'next/router'; // Next.js의 useRouter를 사용해 페이지 이동 처리
import SmallButton from '@/components/common/SmallButton';
import Button from '@/components/common/Button';
import FileInput from '@/components/FileInput';
import axios from '@/pages/api/api';

Expand Down Expand Up @@ -52,9 +52,9 @@ export default function AddBoard() {
<main className="formBody">
<aside className="formTop">
<h2 className="formTheme">게시글 쓰기</h2>
<SmallButton type="submit" disabled={!isFormValid}>
<Button type="submit" disabled={!isFormValid}>
등록
</SmallButton>
</Button>
</aside>
<div className="formBody">
<section className="formSection">
Expand Down
16 changes: 8 additions & 8 deletions pages/board/[articleId].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import Link from 'next/link';
import Image from 'next/image';
import axios from '@/pages/api/api';
import SelectBox from '@/components/common/SelectBox';
import SmallButton from '@/components/common/SmallButton';
import Button from '@/components/common/Button';
import Comment from '@/components/Comment';
import Profile from '@/public/ic_profile.svg';
import Heart from '@/public/ic_heart.svg';
import EmptyComment from '@/public/img_empty_comment.svg';
import Back from '@/public/ic_back.svg';
import Profile from '@/public/icons/ic_profile.svg';
import Heart from '@/public/icons/ic_heart.svg';
import EmptyComment from '@/public/images/img_empty_comment.svg';
import Back from '@/public/icons/ic_back.svg';
import styles from '@/styles/DetailedBoard.module.css';

function formatDate(value) {
Expand Down Expand Up @@ -40,7 +40,7 @@ export async function getServerSideProps(context) {
}
}

export default function Board({ articleData, initialCommentData }) {
export default function Board({ articleData, commentData: initialCommentData }) {
const [comment, setComment] = useState('');
const [isFormValid, setIsFormValid] = useState(false);
const [commentData, setCommentData] = useState(initialCommentData || []);
Expand Down Expand Up @@ -123,9 +123,9 @@ export default function Board({ articleData, initialCommentData }) {
/>
</div>
<div className={styles.commentButton}>
<SmallButton type="submit" disabled={!isFormValid}>
<Button type="submit" disabled={!isFormValid}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isFormValid 상태는 없어도 될 것 같아요 !

Suggested change
<Button type="submit" disabled={!isFormValid}>
<Button type="submit" disabled={!(comment.trim() !== '')}>

isFormValid가 있기에 리렌더링을 한번 더 하게 됩니다. 이런 경우 그냥 조건부에 추가만 해주시면 불필요한 리렌더링 없이 잘 노출될거예요 !

등록
</SmallButton>
</Button>
</div>
</form>
</section>
Expand Down
6 changes: 3 additions & 3 deletions pages/boards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import Image from 'next/image';
import Link from 'next/link';
import BestBoard from '@/components/BestBoard'
import EntireBoard from '@/components/EntireBoard';
import SmallButton from '@/components/common/SmallButton';
import Button from '@/components/common/Button';
import axios from '@/pages/api/api';
import search from '@/public/ic_search.svg';
import search from '@/public/icons/ic_search.svg';
import styles from '@/styles/Boards.module.css';

export default function Boards() {
Expand Down Expand Up @@ -96,7 +96,7 @@ export default function Boards() {
<div className={styles.entireBoardHeader}>
<h2 className={styles.entireBoardTitle}>게시글</h2>
<Link href="/addboard">
<SmallButton type="button">글쓰기</SmallButton>
<Button type="button">글쓰기</Button>
</Link>
</div>
<div className={styles.entireBoardBody}>
Expand Down
Loading
Loading