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

[전소은]19주차 과제 업로드 #437

Open
wants to merge 1 commit into
base: part3-전소은
Choose a base branch
from
Open
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
18 changes: 17 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
{
"extends": "next/core-web-vitals"
"env": {
"browser": true,
"es2021": true
},
"extends": [
"google",
"plugin:react/recommended"
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
}
}
65 changes: 45 additions & 20 deletions components/Input/Input.jsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,55 @@
// Input.jsx

import React, { forwardRef } from "react";
import classNames from "classnames";
import styles from "./Input.module.css";
import Image from "next/image";

const Input = forwardRef(
({ state, type = "text", placeholder, errorMessage, ...props }, ref) => {
const combinedStyles = classNames(styles["input-base"], {
[styles["input-state"]]: state === "error",
});

return (
<>
const Input = ({
Copy link
Collaborator

Choose a reason for hiding this comment

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

컴포넌트를 만들 때, 아래의 요구사항같이 외부에서 해당 Input의 Native 이벤트를 핸들링할 수 있도록 만드는 것이 좋습니다.

(ex. 회원가입 폼에서 validation(유효성 검증)을 통과하지 못한 경우, Input을 강제 포커스)

forwardRef 를 꼭 찾아보시고 적용해주세요.

label,
type,
error,
placeholder,
id,
value,
onKeyPress,
onChangeType,
onChange,
defaultValue,
registerConfig,
}) => {
return (
<>
<label className={styles.label} htmlFor={id}>
{label}
</label>
<div className={styles.inputBox}>
<input
ref={ref}
className={classNames(styles.input, { [styles.error]: error })}
type={type}
className={combinedStyles}
id={id}
placeholder={placeholder}
{...props}
defaultValue={defaultValue}
value={value}
onChange={onChange}
{...registerConfig}
/>
{errorMessage && (
<p className={styles["error-message"]}>{errorMessage}</p>
{(type === "password" || type === "text") && onChangeType && (
<button
className={classNames(styles.imgWrapper)}
onClick={onChangeType}
type="button"
tabIndex={-1}
>
<Image
src={`/eye-${type === "password" ? "off" : "on"}.svg`}
alt="eye-icon"
width={24}
height={24}
/>
</button>
)}
</>
);
}
);
</div>
{error && <p className={styles.errorMessage}>{error}</p>}
</>
);
};

export default Input;
25 changes: 19 additions & 6 deletions components/Input/Input.module.css
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
.input-base {
.input {
border-radius: 8px;
border: 1px solid var(--Linkbrary-gray20, #ccd5e3);
background: var(--Linkbrary-white, #fff);
display: flex;
width: 350px;
width: 35rem;
padding: 18px 15px;
justify-content: center;
align-items: center;
}
.input-base::placeholder {
.input::placeholder {
color: #9fa6b2;
font-size: 16px;
font-weight: 400;
line-height: 24px;
}
.input-base:focus {
.input:focus {
outline: none;
border: 1px solid #6d6afe;
}
.input-base:focus::placeholder {
.input:focus::placeholder {
color: #373740;
font-size: 1.6rem;
font-weight: 400;
Expand All @@ -35,11 +35,24 @@
font-weight: 400;
line-height: 2.4rem;
}
.error-messgae {
.errorMessage {
color: #ff5b56;
font-size: 1.4rem;
font-weight: 400;
}
.input-base [data-iserror="true"] {
border: 1px solid #ff5b56;
}
.imgWrapper {
position: absolute;
top: 50%;
right: 1.5rem;
transform: translateY(-50%);
}
.inputBox {
margin: 0.8rem 0;
position: relative;
}
.input.error {
border-color: red;
}
38 changes: 27 additions & 11 deletions components/Nav/Nav.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
import Image from "next/image";
import styles from "./Nav.module.css";
export default function Nav() {
import Link from "next/link";

export default function Nav({ userProfile }) {
return (
<>
<div className={styles["nav-all"]}>
<div className={styles["nav-layout"]}>
<div className={styles["logo-img"]}>
<Image fill src="/Linkbrary.svg" alt="로고 이미지" />
</div>
<div className={styles["nav-all"]}>
<div className={styles["nav-layout"]}>
<div className={styles["logo-img"]}>
<Image
src="/Linkbrary.svg"
alt="로고 이미지"
width={100}
height={100}
/>
</div>
{userProfile ? (
<div className={styles["profile-layout"]}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

userProfile이 유효할 때 렌더링되는 html 엘리먼트들은 별도의 컴포넌트로 생성해주세요.

const UserInfo = () => {
  return ( 
    <div>....</div>
  )
}

const Nav = () => {
   return (
       { userProfile && <UserInfo/> }
   )
}

<div className={styles["profile-img"]}>
<Image fill src="/profile.svg" alt="프로필 이미지" />
<Image
src={userProfile.image_source}
alt="프로필 이미지"
width={50}
height={50}
/>
</div>
<div className={styles["profile-email"]}>[email protected]</div>
<div className={styles["profile-email"]}>{userProfile.email}</div>
</div>
</div>
) : (
<Link href="/signin">
<div className={styles["login-btn"]}>로그인</div>
</Link>
)}
</div>
</>
</div>
);
}
2 changes: 1 addition & 1 deletion components/SearchBar/SearchBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const SearchBar = ({ value, onChange, onCloseClick }) => {
<div className={styles["search-icon"]}>
<Image
fill
src="/serach.svg"
src="/search.svg"
alt="검색창인 것을 알려주는 돋보기 아이콘"
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions lib/axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const BASE_URL = " https://bootcamp-api.codeit.kr/api/linkbrary/v1";
7 changes: 0 additions & 7 deletions lib/axious.js

This file was deleted.

Loading