-
Notifications
You must be signed in to change notification settings - Fork 0
Dev branch #3
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
Open
GHeeJeon
wants to merge
6
commits into
pr-jihee
Choose a base branch
from
dev-branch
base: pr-jihee
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Dev branch #3
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c6bd058
ver1 create, delete 기능 완료
donysony eed167b
수정, 로컬스토리지에 저장
donysony 75ccbec
주석처리 및 로컬스토리지 key명 통합
donysony c83f5e2
React.memo적용 및 handleEdit처리
donysony 42c122f
List.js와 Lists.js로 분리하기
donysony 184cff4
Update .gitignore
donysony File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,14 @@ | ||
| .App { | ||
| } | ||
| @tailwind base; | ||
| @tailwind components; | ||
| @tailwind utilities; | ||
|
|
||
| @layer base { | ||
| h1 { | ||
| @apply text-2xl font-semibold | ||
| ; | ||
| } | ||
| h2 { | ||
| @apply text-xl; | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .diary-input{ | ||
| width:250px; | ||
| height: 30px; | ||
| padding:0px; | ||
| } | ||
| .diary-submit{ | ||
|
Member
Author
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.
|
||
| height: 30px; | ||
| margin-left: 10px; | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import React from 'react' | ||
| import './Form.css' | ||
| const Form = ({value, setValue, handleSubmit}) => { | ||
| console.log('Form Component') | ||
| const handleChange = (e) => { | ||
| setValue(e.target.value); | ||
| } | ||
|
|
||
|
|
||
| return ( | ||
| <form onSubmit={handleSubmit} className='flex space-x-4 mb-8'> | ||
| <input | ||
| type="text" | ||
| name="diary" | ||
| placeholder='오늘의 한줄 일기를 작성하세요' | ||
| onChange={handleChange} | ||
| className='w-5/6 h-14 indent-3 bg-rose-100 | ||
| focus:outline-none focus:border-rose-300 border | ||
| border-rose-200 rounded-md text-sm shadow-sm drop-shadow-lg' | ||
| value={value} | ||
| /> | ||
| <input | ||
| type="submit" | ||
| value="입력" | ||
| className='h-14 w-1/6 rounded-full bg-rose-100 hover:bg-rose-200 | ||
| drop-shadow-lg' | ||
| /> | ||
| </form> | ||
| ) | ||
| } | ||
|
|
||
| export default Form |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import React,{useState} from 'react' | ||
|
|
||
| const List = ({handleClick, DiaryData, setDiaryData, id, content, date}) => { | ||
| console.log('List Component') | ||
| console.log('DiaryData : ', DiaryData); | ||
| const [isEditing, setIsEditing] = useState(false); | ||
| const [editedContent, setEditedContent] = useState(content); | ||
|
|
||
| //넘기는 인자값이 많을 경우 함수를 생성해서 할수도 있음 | ||
| // const hanldeEdit = (data) => {setIsEditing(true); setId(data.id); setEditedContent(data.content); setDate(data.date)} | ||
|
|
||
| const hanldeEdit = (id) => {setIsEditing(true); }; | ||
| //글 수정 | ||
| const handleEditChange = (event) => { | ||
| setEditedContent(event.target.value); | ||
| } | ||
|
|
||
| //수정된 글 저장 | ||
| const handleSubmit = (event) =>{ | ||
| event.preventDefault(); | ||
| let newDiaryData = DiaryData.map(data =>{ | ||
| if(data.id === id){ | ||
| data.content = editedContent; | ||
| } | ||
| return data; | ||
| }) | ||
| setDiaryData(newDiaryData); | ||
| localStorage.setItem('Diary', JSON.stringify(newDiaryData)); | ||
| setIsEditing(false); | ||
| } | ||
|
|
||
|
|
||
| if(isEditing){ | ||
| //수정버튼을 눌렀을 때 | ||
| return ( | ||
| <div className='bg-rose-100 p-1'> | ||
| <div className='flex items-center justify-between w-full mt-2'> | ||
| <div className='flex w-5/6 items-center'> | ||
| <span className='w-1/6 text-center'>{date}</span> | ||
| <form onSubmit={handleSubmit} className='w-5/6'> | ||
| <input | ||
| value={editedContent} | ||
| onChange={handleEditChange} | ||
| className='w-full px-3 py-2 text-gray-500 rounded' | ||
| /> | ||
| </form> | ||
| </div> | ||
| <div className="w-1/6 " > | ||
| <button className="w-1/2" onClick={handleSubmit}> | ||
| 저장 | ||
| </button> | ||
| <button onClick={() => {setIsEditing(false); handleClick(id)}}> | ||
| 삭제 | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) | ||
| }else{ | ||
| return ( | ||
| <div className='bg-rose-100 p-1'> | ||
| <div className='flex items-center justify-between w-full mt-2'> | ||
| <div className='flex w-5/6 items-center'> | ||
| <span className='w-1/6 text-center'>{date}</span> | ||
| {/* <form onSubmit={handleSubmit} className='w-full'> */} | ||
| <div | ||
| className='w-5/6 h-14 text-gray-500 break-words inline-block align-middle ' | ||
| > | ||
| {content} | ||
| </div> | ||
| {/* </form> */} | ||
| </div> | ||
| <div className=" w-1/6" > | ||
| <button className="w-1/2" onClick={() => hanldeEdit(id)}> | ||
| 수정 | ||
| </button> | ||
| <button onClick={() => handleClick(id)}> | ||
| 삭제 | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
|
|
||
|
|
||
| )} | ||
| } | ||
|
|
||
| export default React.memo(List); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import React from 'react' | ||
| import List from './List' | ||
|
|
||
| const Lists = ({handleClick, DiaryData, setDiaryData}) => { | ||
| console.log("Lists DiaryData : ", DiaryData); | ||
| return ( | ||
| <div> | ||
| <div className='bg-rose-100 p-8'> | ||
| <div className='flex mb-3 '> | ||
| <span className='w-1/6 text-center'>날짜</span><span className='w-5/6 text-left'>내용</span> | ||
| </div> | ||
| <hr className='bg-gray-950 h-px border-0'/> | ||
| { DiaryData.map((data) => ( | ||
| <List | ||
| id={data.id} | ||
| date = {data.date} | ||
| content = {data.content} | ||
| setDiaryData={setDiaryData} | ||
| handleClick={handleClick} | ||
| DiaryData={DiaryData} | ||
| /> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default React.memo(Lists); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
함수의 재사용성을 위해
useCallback을 사용하셨군요!컴포넌트 최적화에 도움이 되는 방법이라고 생각합니다.
리팩토링 할 때 참고하겠습니다.
useCallback! 기억할게요!