Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
02dace5
test and setting
timothypark33 Dec 7, 2021
aa464b8
사용할 컴포넌트 미리 구성하기
timothypark33 Dec 7, 2021
d4605cb
form 입력값 작동 확인
timothypark33 Dec 7, 2021
9a5f272
입력된 습관들 배열에 넣기
timothypark33 Dec 7, 2021
00643a9
입력한 습관을 화면에 띄운다.
timothypark33 Dec 7, 2021
23224a9
삭제버튼 함수에 연결
timothypark33 Dec 7, 2021
ab796b3
삭제 버튼에 연결된 함수로 해당 습관 인덱스 확인
timothypark33 Dec 7, 2021
f73a7db
삭제 버튼 구현 완료
timothypark33 Dec 7, 2021
93eca22
삭제를 완료로 수정
timothypark33 Dec 7, 2021
ae89ec2
할 일이 없어요! 추가
timothypark33 Dec 7, 2021
a092f6f
[refactor] App을 컴포넌트로 분리
timothypark33 Dec 8, 2021
d0ad15d
[refactor] Page를 컴포넌트로 분리
timothypark33 Dec 8, 2021
6907d03
[refactor] Input을 컴포넌트로 분리
timothypark33 Dec 8, 2021
9429144
[refactor] Habits를 컴포넌트로 분리
timothypark33 Dec 8, 2021
d0ac3eb
[refactor] Habit을 컴포넌트로 분리
timothypark33 Dec 8, 2021
cf96cb5
[chore] import 오류 수정후 작동 확인
timothypark33 Dec 8, 2021
c1e1917
[chore] keyValue를 id 로 변경
timothypark33 Dec 8, 2021
1555225
[fix] 제출할 때 사용되는 setState에 넣을 객체에 ...state 추가
timothypark33 Dec 8, 2021
50120d8
[chore] onDelete를 onClickDelete로 이름 변경
timothypark33 Dec 8, 2021
51bc13d
[refactor] habit 데이터와 다루는 함수를 Page 컴포넌트에 옮김
timothypark33 Dec 8, 2021
415b8d1
[chore] handleDelete함수에서 key를 id로 변경
timothypark33 Dec 8, 2021
0399cd6
[fix] eslint 수정
timothypark33 Dec 9, 2021
39097c9
[fix] eslint 완전 해결
timothypark33 Dec 10, 2021
c6d0331
[refactor] 습관이 있는 지 없는지를 변수로 따로 뺴서 확인
timothypark33 Dec 10, 2021
19e250e
[refactor] 컴포넌트 줄바꿈으로 가독성 향상
timothypark33 Dec 10, 2021
9e7b143
[fix] habits의 원자들을 객체로 사용
timothypark33 Dec 10, 2021
7945b1a
[refactor] id프롭 제거, onClickDelete에 직접적으로 id변수 사용
timothypark33 Dec 10, 2021
eb82045
[refactor] onClickSubmit이벤트 객체를 Input 컴포넌트에서 처리
timothypark33 Dec 10, 2021
b968fc5
[refactor] input태그에 value 속성 사용
timothypark33 Dec 10, 2021
d1eece9
[refactor] 라이브러리 임포트와 컴포넌트 임포트 구분
timothypark33 Dec 10, 2021
122ba21
[refactor] habits 태그 page태그로 옮김
timothypark33 Dec 12, 2021
465b045
[refactor] 사라진 할일이 없어요! 추가
timothypark33 Dec 12, 2021
93e3c64
[refactor] 입력받은 상태도 Page 컴포넌트에서 관리
timothypark33 Dec 12, 2021
fd4968f
[refactor] 입력받은 상태도 Page 컴포넌트에서 관리
timothypark33 Dec 12, 2021
ba1adac
[refactor] 뒤늦은 eslint 적용
timothypark33 Dec 12, 2021
335f252
[refactor] 머지 전 충돌 해결
timothypark33 Dec 12, 2021
f92a868
[refactor] 할 일을 추가를 누르면 input의 텍스트가 지워진다.
timothypark33 Dec 12, 2021
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
13 changes: 11 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@ module.exports = {
'react',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
actor: 'readonly',
Feature: 'readonly',
Scenario: 'readonly',
},
rules: {
'react/function-component-definition': [2, {
namedComponents: 'function-declaration',
}],
'react/prop-types': 'off',
'react/jsx-no-bind': ['error', {
ignoreRefs: true,
allowArrowFunctions: true,
allowFunctions: false,
allowBind: false,
ignoreDOMComponents: true,
}],
indent: ['error', 2],
'no-trailing-spaces': 'error',
curly: 'error',
Expand Down
12,452 changes: 11,846 additions & 606 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"@codeceptjs/configure": "^0.6.2",
"babel-loader": "^8.2.2",
"codeceptjs": "^3.0.6",
"eslint": "^7.25.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.23.2",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint": "^8.4.1",
"eslint-config-airbnb": "^19.0.2",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.27.1",
"eslint-plugin-react-hooks": "^4.3.0",
"puppeteer": "^9.0.0",
"start-server-and-test": "^1.12.1",
"webpack": "^5.36.2",
Expand Down
9 changes: 9 additions & 0 deletions src/component/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

import Page from './Page';

export default function App() {
return (
<Page />
);
}
16 changes: 16 additions & 0 deletions src/component/Habit.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';

function Habit({ onClickDelete, text }) {
return (
<div>
{text}
<button
onClick={onClickDelete}
type="button"
>
완료
</button>
</div>
);
}
export default Habit;
28 changes: 28 additions & 0 deletions src/component/Habits.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';

import Habit from './Habit';

function Habits({ onClickDelete, habits }) {
if (habits.length === 0) {
return (
<div>
할 일이 없어요!
</div>
);
}
return (
<div>
{
habits.map((habit) => (
<Habit
onClickDelete={() => onClickDelete(habit.id)}
text={habit.text}
key={habit.id}
/>
))
}
</div>
);
}

export default Habits;
36 changes: 36 additions & 0 deletions src/component/Input.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';

function Input({ onSubmit, onChangeHabitToAdd, habitToAdd }) {
const onChanageHandler = (event) => {
onChangeHabitToAdd(event.target.value);
};

const onClickSubmitHabit = (event) => {
event.preventDefault();
const habit = {
id: Date.now() + habitToAdd,
text: habitToAdd,
};
onSubmit(habit);
};

return (
<div>
<form onSubmit={onClickSubmitHabit}>
<input
type="text"
name="content"
value={habitToAdd}
onChange={onChanageHandler}
placeholder="할 일을 입력해 주세요"
/>
<input
type="submit"
value="추가"
/>
</form>
</div>
);
}

export default Input;
52 changes: 52 additions & 0 deletions src/component/Page.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React, { useState } from 'react';

import Input from './Input';
import Habits from './Habits';

function Page() {
const [state, setState] = useState({
habits: [],
habitToAdd: '',
});
const { habits, habitToAdd } = state;

const handleHabitToAdd = (value) => {
setState({
...state,
habitToAdd: value,
});
};

const handleDelete = (id) => {
setState({
...state,
habits: habits.filter((habit) => habit.id !== id),
});
};

const handleSubmit = (habit) => {
setState({
habits: [
habit,
...habits,
],
habitToAdd: '',
});
};
return (
<div>
<Input
onSubmit={handleSubmit}
onChangeHabitToAdd={handleHabitToAdd}
habitToAdd={habitToAdd}
/>
<Habits
onClickDelete={handleDelete}
habits={habits}
/>
</div>

);
}

export default Page;
6 changes: 6 additions & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';

import App from './component/App';

ReactDOM.render(<App />, document.getElementById('app'));
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path');

module.exports = {
mode: 'development',
entry: path.resolve(__dirname, 'src/index.jsx'),
module: {
rules: [
Expand Down