@@ -5,36 +5,41 @@ import TodoCount from "./components/TodoCount.js";
55import { setItem } from "./utils/storage.js" ;
66import { TodoCount as TodoCnt , TodoItem } from "./types/todo.js" ;
77
8- export default function App ( { $target, initialState, initialCount } ) {
9- new Header ( {
10- $target,
11- text : "Todo List" ,
12- } ) ;
8+ export default class App {
9+ // todoList: TodoList;
10+ // todoCount: TodoCount;
1311
14- new TodoForm ( {
15- $target,
16- onSubmit : ( text ) => {
17- const nextState = [ ...todoList . state , { text, isCompleted : false } ] ;
18- todoList . setState ( nextState ) ;
19- } ,
20- } ) ;
12+ constructor (
13+ protected readonly $target : HTMLElement ,
14+ protected readonly initialState : TodoItem [ ] ,
15+ protected readonly initialCount : TodoCnt
16+ ) {
2117
22- const todoList = new TodoList ( {
23- $target,
24- initialState,
25- updateCount : ( state ) => updateCount ( state ) ,
26- } ) ;
18+ // new TodoForm({
19+ // $target: this.$target,
20+ // onSubmit: (text: string) => {
21+ // const nextState = [...this.todoList.state, { text, isCompleted: false }];
22+ // this.todoList.setState(nextState);
23+ // },
24+ // });
2725
28- const todoCount = new TodoCount ( {
29- $target,
30- initialCount,
31- } ) ;
26+ // this.todoList = new TodoList({
27+ // $target: this.$target,
28+ // initialState: this.initialState,
29+ // updateCount: (state: TodoItem[]) => this.updateCount(state),
30+ // });
31+
32+ // this.todoCount = new TodoCount({
33+ // $target: this.$target,
34+ // initialCount: this.initialCount,
35+ // });
36+ }
3237
3338 // 카운트 업데이트
34- const updateCount = ( todoList ) => {
35- const done = todoList . filter ( ( todo ) => todo . isCompleted ) . length ;
36- const nextState = { total : todoList . length , done } ;
37- todoCount . setState ( nextState ) ;
38- setItem ( "count" , JSON . stringify ( nextState ) ) ;
39- } ;
39+ // updateCount(todoList: TodoItem[]) {
40+ // const done = todoList.filter((todo) => todo.isCompleted).length;
41+ // const nextState = { total: todoList.length, done };
42+ // this. todoCount.setState(nextState);
43+ // setItem("count", JSON.stringify(nextState));
44+ // };
4045}
0 commit comments