44 import TodoItem from ' ./TodoItem.svelte'
55 import { todoItems } from ' ./store'
66 import { todoStats } from ' ./todoStatsStore'
7+ import { quintOut } from ' svelte/easing' ;
8+ import { crossfade } from ' svelte/transition' ;
9+
10+ const [send , receive ] = crossfade ({
11+ duration : d => Math .sqrt (d * 200 ),
12+
13+ fallback (node , params ) {
14+ const style = getComputedStyle (node);
15+ const transform = style .transform === ' none' ? ' ' : style .transform ;
16+
17+ return {
18+ duration: 600 ,
19+ easing: quintOut,
20+ css : t => `
21+ transform: ${ transform} scale(${ t} );
22+ opacity: ${ t}
23+ `
24+ };
25+ }
26+ });
727
828 let mounted = false
929 onMount (() => {
3151 />
3252</div >
3353
34- {#if mounted }
3554 {#if $todoStats .totalCount === 0 }
3655 No items yet
3756 {:else }
38- <div class =" todo-items-container" >
39- {#each $todoItems as { id, text, checked }, index (id )}
40- <div class =" todo-item-container" >
41- <TodoItem
42- text ={` ${index + 1 }: ${text } ` }
43- {checked }
44- on:checked ={event => handleItemChecked (id , event .detail )}
45- on:remove ={() => handleItemRemove (id )}
46- />
47- </div >
48- {/each }
57+ <div class =" todos-container" >
58+ <div class =" todo-items-container" >
59+ {#each $todoStats .notDoneItems as { id, text, checked }, index (id )}
60+ <div
61+ class =" todo-item-container"
62+ in:receive =" {{key : id }}"
63+ out:send =" {{key : id }}"
64+ >
65+ <TodoItem
66+ text ={` ${index + 1 }: ${text } ` }
67+ {checked }
68+ on:checked ={event => handleItemChecked (id , event .detail )}
69+ on:remove ={() => handleItemRemove (id )}
70+ />
71+ </div >
72+ {/each }
73+ </div >
74+ <div class =" todo-items-container" >
75+ {#each $todoStats .doneItems as { id, text, checked }, index (id )}
76+ <div
77+ class =" todo-item-container"
78+ in:receive =" {{key : id }}"
79+ out:send =" {{key : id }}"
80+ >
81+ <TodoItem
82+ text ={` ${index + 1 }: ${text } ` }
83+ {checked }
84+ on:checked ={event => handleItemChecked (id , event .detail )}
85+ on:remove ={() => handleItemRemove (id )}
86+ />
87+ </div >
88+ {/each }
89+ </div >
4990 </div >
5091 {/if }
51- {/if }
5292
5393<style >
5494 .add-todo-item-container {
5595 margin-bottom : 5px ;
5696 }
57- .todo-items-container :not (:last-child ) > .todo-item-container {
97+ .todo-items-container {
98+ flex : 1 ;
99+ padding : 5px ;
100+ box-sizing : border-box ;
101+ }
102+ .todo-items-container > .todo-item-container :not (:last-child ) {
58103 margin-bottom : 5px ;
59104 }
105+ .todos-container {
106+ width : 100% ;
107+ display : flex ;
108+ }
60109 </style >
0 commit comments