-
Notifications
You must be signed in to change notification settings - Fork 1
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
[4주차 기본/심화/공유 과제] 회원가입 & 로그인 #5
base: main
Are you sure you want to change the base?
Changes from 10 commits
ab8d28d
1b8513b
22cc604
b07487f
ce93bff
b54acb4
2949360
f6802bc
b275145
3eb1fc3
058b5cb
5c422da
509cbcd
be11af7
1029441
7fa1cd6
fe61db3
e2de37d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# React + TypeScript + Vite | ||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
|
||
Currently, two official plugins are available: | ||
|
||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
|
||
## Expanding the ESLint configuration | ||
|
||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: | ||
|
||
- Configure the top-level `parserOptions` property like this: | ||
|
||
```js | ||
export default tseslint.config({ | ||
languageOptions: { | ||
// other options... | ||
parserOptions: { | ||
project: ['./tsconfig.node.json', './tsconfig.app.json'], | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
}) | ||
``` | ||
|
||
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked` | ||
- Optionally add `...tseslint.configs.stylisticTypeChecked` | ||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config: | ||
|
||
```js | ||
// eslint.config.js | ||
import react from 'eslint-plugin-react' | ||
|
||
export default tseslint.config({ | ||
// Set the react version | ||
settings: { react: { version: '18.3' } }, | ||
plugins: { | ||
// Add the react plugin | ||
react, | ||
}, | ||
rules: { | ||
// other rules... | ||
// Enable its recommended rules | ||
...react.configs.recommended.rules, | ||
...react.configs['jsx-runtime'].rules, | ||
}, | ||
}) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import js from '@eslint/js' | ||
import globals from 'globals' | ||
import reactHooks from 'eslint-plugin-react-hooks' | ||
import reactRefresh from 'eslint-plugin-react-refresh' | ||
import tseslint from 'typescript-eslint' | ||
|
||
export default tseslint.config( | ||
{ ignores: ['dist'] }, | ||
{ | ||
extends: [js.configs.recommended, ...tseslint.configs.recommended], | ||
files: ['**/*.{ts,tsx}'], | ||
languageOptions: { | ||
ecmaVersion: 2020, | ||
globals: globals.browser, | ||
}, | ||
plugins: { | ||
'react-hooks': reactHooks, | ||
'react-refresh': reactRefresh, | ||
}, | ||
rules: { | ||
...reactHooks.configs.recommended.rules, | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
}, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="ko"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>회원가입 & 로그인</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "week4-assignment", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc -b && vite build", | ||
"lint": "eslint .", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"axios": "^1.7.7", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1", | ||
"react-icons": "^5.3.0", | ||
"react-router-dom": "^6.28.0", | ||
"styled-components": "^6.1.13" | ||
}, | ||
"devDependencies": { | ||
"@eslint/js": "^9.13.0", | ||
"@types/axios": "^0.14.4", | ||
"@types/react": "^18.3.12", | ||
"@types/react-dom": "^18.3.1", | ||
"@types/styled-components": "^5.1.34", | ||
"@vitejs/plugin-react": "^4.3.3", | ||
"eslint": "^9.13.0", | ||
"eslint-plugin-react-hooks": "^5.0.0", | ||
"eslint-plugin-react-refresh": "^0.4.14", | ||
"globals": "^15.11.0", | ||
"typescript": "~5.6.2", | ||
"typescript-eslint": "^8.11.0", | ||
"vite": "^5.4.10" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { createBrowserRouter, RouterProvider } from 'react-router-dom'; | ||
import { ThemeProvider } from 'styled-components'; | ||
import GlobalStyle from './styles/GlobalStyle'; | ||
import theme from './styles/theme'; | ||
|
||
import Login from './pages/LoginPage'; | ||
import Signup from './pages/SignupPage'; | ||
import MyPage from './pages/MypagePage'; | ||
|
||
const router = createBrowserRouter([ | ||
{ | ||
path: "/", | ||
element: <Login />, | ||
}, | ||
{ | ||
path: "/signup", | ||
element: <Signup />, | ||
}, | ||
{ | ||
path: "/mypage", | ||
element: <MyPage />, | ||
}, | ||
]); | ||
|
||
function App() { | ||
return ( | ||
<ThemeProvider theme={theme}> | ||
<GlobalStyle /> | ||
<RouterProvider router={router} /> | ||
</ThemeProvider> | ||
); | ||
} | ||
|
||
export default App; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { useState } from 'react'; | ||
import { Container, Title, InputWrapper, Input, Button, BottomButton } from './LoginStyles'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
interface LoginData { | ||
username: string; | ||
password: string; | ||
} | ||
|
||
interface LoginProps { | ||
onLogin: (loginData: LoginData) => void; | ||
} | ||
|
||
const Login = ({ onLogin }: LoginProps) => { | ||
const navigate = useNavigate(); | ||
const [loginData, setLoginData] = useState<LoginData>({ username: '', password: '' }); | ||
|
||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
const { name, value } = e.target; | ||
setLoginData((prevData) => ({ | ||
...prevData, | ||
[name]: value, | ||
})); | ||
}; | ||
|
||
const handleLogin = () => { | ||
if (loginData.username && loginData.password) { | ||
onLogin(loginData); | ||
} | ||
}; | ||
|
||
const handleSignup = () => { | ||
navigate('/signup'); | ||
}; | ||
|
||
return ( | ||
<Container> | ||
<Title>로그인</Title> | ||
<InputWrapper> | ||
<Input | ||
type="text" | ||
id="username" | ||
name="username" | ||
value={loginData.username} | ||
onChange={handleChange} | ||
placeholder="아이디" | ||
/> | ||
</InputWrapper> | ||
<InputWrapper> | ||
<Input | ||
type="password" | ||
id="password" | ||
name="password" | ||
value={loginData.password} | ||
onChange={handleChange} | ||
placeholder="비밀번호" | ||
/> | ||
</InputWrapper> | ||
<Button onClick={handleLogin}>로그인</Button> | ||
<BottomButton onClick={handleSignup}>회원가입</BottomButton> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default Login; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Container = styled.div` | ||
padding: 8rem 0; | ||
max-width: 40rem; | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
text-align: center; | ||
margin: 0 auto; | ||
`; | ||
|
||
export const Title = styled.h2` | ||
font-size: 3rem; | ||
font-weight: 700; | ||
text-align: center; | ||
margin: 3rem; | ||
color: ${({ theme }) => theme.colors.black}; | ||
`; | ||
|
||
export const InputWrapper = styled.div` | ||
margin-bottom: 15px; | ||
width: 100%; | ||
`; | ||
|
||
export const Input = styled.input` | ||
padding: 10px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. margin에는 rem, padding에는 px 등으로 단위를 섞어서 사용하시고 있는 것 같은데, 그게 아니라면 단위를 일관성이 있게 사용하시는것이 유지보수나 가독성 측면에서 더 좋을 것 같습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이유 없습니다.... 바봅니다. 수정하겠습니다. |
||
font-size: 1.6rem; | ||
width: 100%; | ||
box-sizing: border-box; | ||
border: 1px solid ${({ theme }) => theme.colors.gray}; | ||
border-radius: 4px; | ||
background-color: ${({ theme }) => theme.colors.white}; | ||
`; | ||
|
||
export const Button = styled.button` | ||
padding: 10px 15px; | ||
font-size: 1.6rem; | ||
background-color: ${({ theme }) => theme.colors.green}; | ||
color: white; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
width: 100%; | ||
transition: background-color 0.3s ease, color 0.3s ease; | ||
|
||
&:hover { | ||
background-color: ${({ theme }) => theme.colors.darkgreen}; | ||
} | ||
`; | ||
|
||
export const BottomButton = styled.button` | ||
background: none; | ||
border: none; | ||
color: ${({ theme }) => theme.colors.gray}; | ||
font-size: 14px; | ||
margin-top: 15px; | ||
cursor: pointer; | ||
text-decoration: underline; | ||
width: 100%; | ||
transition: color 0.3s ease; | ||
|
||
&:hover { | ||
color: ${({ theme }) => theme.colors.darkgray}; | ||
} | ||
`; |
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.
다른 이름으로 받아오는 것도 좋지만 파일명과 같은 이름으로 import해오는 것은 어떨까요?
특히 이 프로젝트같이, LoginPage와 Login 컴포넌트가 둘다 있는 경우에는, 헷갈릴 우려가 있을 것 같습니다!
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.
아.. 놓친 부분이 너무 많네요. 수정하겠습니다.