-
Notifications
You must be signed in to change notification settings - Fork 0
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
Study #6
base: main
Are you sure you want to change the base?
Study #6
Changes from all commits
9e565fd
b236449
e2501ba
2aeb78a
f330d29
95c04e1
a81d684
1c15668
6126103
34631b6
b211a76
62d221d
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,21 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:react/recommended', | ||
'plugin:react/jsx-runtime', | ||
'plugin:react-hooks/recommended', | ||
], | ||
ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, | ||
settings: { react: { version: '18.2' } }, | ||
plugins: ['react-refresh'], | ||
rules: { | ||
'react/jsx-no-target-blank': 'off', | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
} |
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,8 @@ | ||
# React + 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<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>Vite + React</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.jsx"></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "test", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"@emotion/react": "^11.11.4", | ||
"@emotion/styled": "^11.11.5", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.2.66", | ||
"@types/react-dom": "^18.2.22", | ||
"@vitejs/plugin-react-swc": "^3.5.0", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-react": "^7.34.1", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-react-refresh": "^0.4.6", | ||
"vite": "^5.2.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#root { | ||
max-width: 1280px; | ||
margin: 0 auto; | ||
padding: 2rem; | ||
text-align: center; | ||
} | ||
|
||
.logo { | ||
height: 6em; | ||
padding: 1.5em; | ||
will-change: filter; | ||
transition: filter 300ms; | ||
} | ||
.logo:hover { | ||
filter: drop-shadow(0 0 2em #646cffaa); | ||
} | ||
.logo.react:hover { | ||
filter: drop-shadow(0 0 2em #61dafbaa); | ||
} | ||
|
||
@keyframes logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
a:nth-of-type(2) .logo { | ||
animation: logo-spin infinite 20s linear; | ||
} | ||
} | ||
|
||
.card { | ||
padding: 2em; | ||
} | ||
|
||
.read-the-docs { | ||
color: #888; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
import styled from '@emotion/styled'; | ||
import { useState } from 'react'; | ||
|
||
const App = () => { | ||
const [recommend, setRecommend] = useState(''); | ||
const [foodType, setFoodType] = useState(false); | ||
const [selectedFoodType, setSelectedFoodType] = useState(''); | ||
const [category, setCategory] = useState(false); | ||
const [selectedCategory, setSelectedCategory] = useState(''); | ||
const [broth, setBroth] = useState(false); | ||
const [selectedBroth, setSelectedBroth] = useState(''); | ||
|
||
const handleSoupSelection = (brothOption) => { | ||
setSelectedBroth(brothOption); | ||
}; | ||
|
||
const handleRecommendation = (type) => { | ||
setRecommend(type); | ||
}; | ||
|
||
const handleStartButtonClick = () => { | ||
setFoodType(true); | ||
setRecommend(null); | ||
}; | ||
|
||
const handleFoodSelection = (food) => { | ||
setSelectedFoodType(food); | ||
setCategory(false); | ||
}; | ||
|
||
const handleNextClick = () => { | ||
setCategory(true); | ||
setFoodType(false); | ||
setRecommend(null); | ||
}; | ||
|
||
const handleCategorySelection = (category) => { | ||
setSelectedCategory(category); | ||
}; | ||
|
||
return ( | ||
<Body> | ||
<div> | ||
<h1>오늘의 점매추</h1> | ||
<h3>원하는 추천 방식을 골라줘</h3> | ||
</div> | ||
<ButtonWrapper> | ||
{/* 음식유형 화면 체크 =!foodType */} | ||
{!foodType && (!recommend || recommend === 'taste') &&( | ||
<Button selected={recommend === 'taste'} onClick={() => handleRecommendation('taste')}> | ||
취향대로 추천 | ||
</Button> | ||
) } | ||
<SmallButtonWrapper> | ||
{!foodType && (!recommend || recommend === 'random') && ( | ||
<Button selected={recommend === 'random'}onClick={() => handleRecommendation('random')}> | ||
랜덤 추천 | ||
</Button> | ||
) } | ||
</SmallButtonWrapper> | ||
</ButtonWrapper> | ||
{recommend && ( | ||
<StartButton onClick={handleStartButtonClick}> | ||
시작 | ||
</StartButton> | ||
)} | ||
{foodType && ( | ||
<div> | ||
<ButtonFoodType selected={selectedFoodType === 'Korean'} onClick={() => handleFoodSelection('Korean')}>한식</ButtonFoodType> | ||
<ButtonFoodType selected={selectedFoodType === 'Chinese'} onClick={() => handleFoodSelection('Chinese')}>중식</ButtonFoodType> | ||
<ButtonFoodType selected={selectedFoodType === 'Japanese'} onClick={() => handleFoodSelection('Japanese')}>일식</ButtonFoodType> | ||
</div> | ||
)} | ||
|
||
{selectedFoodType && ( | ||
<div> | ||
<Button onClick={handleNextClick}>다음으로</Button> | ||
</div> | ||
)} | ||
{category && ( | ||
<div> | ||
<ButtonFoodType selected={selectedCategory === 'Rice'} onClick={() => handleCategorySelection('Rice')}>밥</ButtonFoodType> | ||
<ButtonFoodType selected={selectedCategory === 'Noodle'} onClick={() => handleCategorySelection('Noodle')}>면</ButtonFoodType> | ||
<ButtonFoodType selected={selectedCategory === 'Mseafood'} onClick={() => handleCategorySelection('Mseafood')}>고기/해물</ButtonFoodType> | ||
</div> | ||
)} | ||
Comment on lines
+80
to
+86
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. 이부분을 선택해도 그대로 렌더링 되어있네요! 이건 step이라는 상태를 관리하면서 |
||
{selectedCategory && ( | ||
<div> | ||
<Button onClick={() => setBroth(true)}>다음으로</Button> | ||
</div> | ||
)} | ||
{broth && ( | ||
<div> | ||
<ButtonFoodType selected={selectedBroth === 'soup'} onClick={() => handleSoupSelection('soup')}>국물O</ButtonFoodType> | ||
<ButtonFoodType selected={selectedBroth === 'nosoup'} onClick={() => handleSoupSelection('nosoup')}>국물X</ButtonFoodType> | ||
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. nonSoup로 값을 정하면 더 좋을 것 같네요 soup가 없다 가 아니라 soup가 아니다 이니까요! |
||
</div> | ||
)} | ||
</Body> | ||
); | ||
}; | ||
|
||
export default App; | ||
|
||
const Button = styled.button` | ||
cursor: pointer; | ||
background: blue; | ||
color: black; | ||
padding: ${(props) => props.selected ? '3rem 4.5rem' : '2rem 3rem'}; | ||
margin: 0.8rem; | ||
font-weight: bold; | ||
&:hover { | ||
background-color: white; | ||
color: gray; | ||
} | ||
`; | ||
|
||
const StartButton = styled(Button)` | ||
padding: 1rem 2rem; | ||
background: red; | ||
`; | ||
|
||
const ButtonWrapper = styled.div` | ||
display: flex; | ||
gap: 1.5rem; | ||
`; | ||
|
||
const Body = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
const SmallButtonWrapper = styled.div` | ||
display: flex; | ||
`; | ||
|
||
const ButtonFoodType = styled(Button)` | ||
//선택시 색깔변경 | ||
background: ${(props) => props.selected ? 'white' : 'blue'}; | ||
color: ${(props) => props.selected ? 'gray' : 'black'}; | ||
`; |
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.
Body라는 컴포넌트명이 이 컴포넌트의 역할을 정확히 명시해주지 않는 것 같아요 ! 가독성있는 코드를 고려해보면 좋겠습니다!
예를 들면 MenuSelectWrapper ~