-
Notifications
You must be signed in to change notification settings - Fork 40
[김성종] Sprint9 #335
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
[김성종] Sprint9 #335
The head ref may contain hidden characters: "Next-\uAE40\uC131\uC885"
Conversation
|
스프리트 미션 하시느라 수고 많으셨어요. |
베스트 게시글은 좋아요 수를 기준으로 걸러 보여줘야 할 거 같은데, 해당 부분 구현 방법이 궁금합니다! 단순히 좋아요 순으로 정렬 후 3개만 잘라서 보여주면 될까요?
|
반응형 css 로 베스트 게시글 숫자 줄여서(?) 보여주는 방법 알고 싶습니다! grid, repeat 등으로 하는 거 같은데 다양하게 적용해봐도 잘 작동되지 않아 여쭙습니다.
|
commit 은 잘게 나눠보려 했는데, 중간부터 반영했습니다
|
| const instance = axios.create({ | ||
| // 환경변수 추가 & env.local에 지정 | ||
| baseURL: process.env.NEXT_PUBLIC_API_BASE_URL, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
크으 환경변수 지정 잘 하셨습니다 👍👍
| export default function Input({ | ||
| placeholder, | ||
| type = "text", | ||
| className = "", | ||
| src, | ||
| alt, | ||
| width, | ||
| height, | ||
| }: ImageProps) { | ||
| return ( | ||
| <> | ||
| <form className={`${styles.form} ${styles[className]}`}> | ||
| {src && ( | ||
| <Image src={src} alt={alt || "Image"} width={width} height={height} /> | ||
| )} | ||
| <input placeholder={placeholder} type={type}></input> | ||
| </form> | ||
| </> | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
form은 분리하면 어떨까요 ?
현재 해당 컴포넌트는 input을 의미하는 것으로 보이나, 최종적으로 form 내부에 input이 있는 것으로 보입니다.
예를 들어서 다음과 같은 상황에서 사용될 수 있을까요 ?:
<form>
<Input />
<Input />
<Input />
</form>위와 같은 상황일 때 중첩 form이 생기게 될거예요. 최종적으로 다음과 같이 input을 반환시키면 어떨지 제안드립니다.(의사 코드입니다 !):
function Input({image}: {image: ReactNode}) {
if (image) return (
// 이미지가 존재할 경우 컴포넌트
)
return (<input {...props} />)
}| interface ImageProps extends InputProps { | ||
| src?: string; | ||
| alt?: string; | ||
| width?: number; | ||
| height?: number; | ||
| } | ||
|
|
||
| export default function Input({ | ||
| placeholder, | ||
| type = "text", | ||
| className = "", | ||
| src, | ||
| alt, | ||
| width, | ||
| height, | ||
| }: ImageProps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위 코드에서 Image또한 props로 받는다면 다음과 같은 코드가 될 수 있습니다:
| interface ImageProps extends InputProps { | |
| src?: string; | |
| alt?: string; | |
| width?: number; | |
| height?: number; | |
| } | |
| export default function Input({ | |
| placeholder, | |
| type = "text", | |
| className = "", | |
| src, | |
| alt, | |
| width, | |
| height, | |
| }: ImageProps) { | |
| interface ImageProps extends React.InputHTMLAttributes<HTMLInputElement> {} | |
| export default function Input({ | |
| placeholder, | |
| type = "text", | |
| className = "", | |
| width, | |
| height, | |
| }: ImageProps) { |
| <span className={styles.date}> | ||
| {format(article.createdAt, "yyyy. MM. dd")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굳굳 날짜 포매팅 라이브러리를 사용 하셨군요? 👍👍
JS에서 날짜 포매팅은 정말 어렵죠 ㅠㅠㅠ
| <li key={article.id}> | ||
| <Image src={Badge} alt="Best Badge" width={102} height={30} /> | ||
| {/* 베스트 게시글 클릭했을 때 해당 게시글로 이동했으면 좋겠다 싶어서 임의로 경로 설정 */} | ||
| <Link href={`/articles/${article.id}`}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
훌륭합니다. Link를 통하여 내부 라우팅을 하셨군요 👍
| type ArticleList = Article[]; | ||
|
|
||
| export default function BestArticles({ articles }: { articles: ArticleList }) { | ||
| console.log(articles); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
콘솔은 지우셔도 될 듯 합니다 !
| console.log(articles); |
|
수고하셨습니다 성종님 ! |
요구사항
기본
심화
주요 변경사항
스크린샷
멘토에게