@@ -21,20 +21,20 @@ function displayAssignedHomework() {
2121 }
2222
2323 const container = document . getElementById ( 'uncompleted-homework' ) ;
24- // Store previous IDs to detect new items
24+ // store previous IDs to detect new items
2525 const prevItems = Array . from ( container . querySelectorAll ( '.homework-item' ) ) ;
2626 const prevIds = prevItems . map ( div => div . dataset . id ) ;
2727
2828 container . innerHTML = '' ;
2929
3030 if ( homework . length === 0 ) {
3131 const msgDiv = document . createElement ( 'div' ) ;
32- msgDiv . innerHTML = ' <h1 style="text-align: center;" >No homework assigned. </h1>' ;
32+ msgDiv . innerHTML = ` <h1>No assignments due. You're all caught up! </h1>` ;
3333 msgDiv . style . opacity = '0' ;
3434 msgDiv . style . height = '60px' ;
3535 container . appendChild ( msgDiv ) ;
3636 setTimeout ( ( ) => {
37- msgDiv . style . transition = 'opacity 0.5s ' ;
37+ msgDiv . style . transition = 'opacity 0.2s ' ;
3838 msgDiv . style . opacity = '1' ;
3939 } , 10 ) ;
4040 return ;
@@ -56,17 +56,18 @@ function displayAssignedHomework() {
5656 ` ;
5757
5858 if ( new Date ( hw . dueDate ) < new Date ( ) ) {
59- div . getElementsByClassName ( 'hw-dueDate' ) [ 0 ] . style . color = '#ffcccc' ;
59+ div . getElementsByClassName ( 'hw-dueDate' ) [ 0 ] . style . color = '#ffbbbb' ;
60+ div . getElementsByClassName ( 'hw-dueDate' ) [ 0 ] . style . fontWeight = 'bold' ;
6061 }
6162
62- // Fade in if it's a new item
63+ // fade in if it's a new item
6364 if ( ! prevIds . includes ( String ( hw . id ) ) ) {
6465 div . style . opacity = '0' ;
65- div . style . transition = 'opacity 0.5s ' ;
66+ div . style . transition = 'opacity 0.2s ' ;
6667 container . appendChild ( div ) ;
6768 setTimeout ( ( ) => {
6869 div . style . opacity = '1' ;
69- } , 500 ) ;
70+ } , 200 ) ;
7071 } else {
7172 container . appendChild ( div ) ;
7273 }
@@ -95,12 +96,12 @@ function displayCompletedHomework() {
9596 // Fade out if toggled off
9697 if ( showCompleted === false && prevItems . length ) {
9798 prevItems . forEach ( div => {
98- div . style . transition = 'opacity 0.5s ' ;
99+ div . style . transition = 'opacity 0.2s ' ;
99100 div . style . opacity = '0' ;
100101 } ) ;
101102 setTimeout ( ( ) => {
102103 container . innerHTML = '' ;
103- } , 500 ) ;
104+ } , 200 ) ;
104105 return ;
105106 }
106107
@@ -110,16 +111,15 @@ function displayCompletedHomework() {
110111 if ( showCompleted == true ) {
111112 const completedContainer = document . getElementById ( 'completed-homework' ) ;
112113 const msgDiv = document . createElement ( 'div' ) ;
113- msgDiv . innerHTML = ' <h1 style="text-align: center;" >No homework completed.</h1>' ;
114+ msgDiv . innerHTML = ` <h1>No assignments completed.</h1>` ;
114115 msgDiv . style . opacity = '0' ;
115116 msgDiv . style . height = '60px' ;
116117 completedContainer . innerHTML = '' ;
117118 completedContainer . appendChild ( msgDiv ) ;
118119 setTimeout ( ( ) => {
119- msgDiv . style . transition = 'opacity 0.5s ' ;
120+ msgDiv . style . transition = 'opacity 0.2s ' ;
120121 msgDiv . style . opacity = '1' ;
121122 } , 10 ) ;
122-
123123 }
124124 return ;
125125 }
@@ -146,16 +146,16 @@ function displayCompletedHomework() {
146146 div . style . opacity = '0' ;
147147 container . appendChild ( div ) ;
148148 setTimeout ( ( ) => {
149- div . style . transition = 'opacity 0.5s ' ;
149+ div . style . transition = 'opacity 0.2s ' ;
150150 div . style . opacity = '1' ;
151151 } , 10 ) ;
152152 } else if ( ! prevIds . includes ( String ( hw . id ) ) && showCompleted == true ) {
153153 div . style . opacity = '0' ;
154154 container . appendChild ( div ) ;
155155 setTimeout ( ( ) => {
156- div . style . transition = 'opacity 0.5s ' ;
156+ div . style . transition = 'opacity 0.2s ' ;
157157 div . style . opacity = '1' ;
158- } , 500 ) ;
158+ } , 200 ) ;
159159 } else {
160160 container . appendChild ( div ) ;
161161 }
@@ -262,7 +262,13 @@ document.getElementById('homework-container').addEventListener('click', event =>
262262 finishedHomework . splice ( idx , 1 ) ;
263263 localStorage . setItem ( 'homework' , JSON . stringify ( homework ) ) ;
264264 localStorage . setItem ( 'finishedHomework' , JSON . stringify ( finishedHomework ) ) ;
265- displayCompletedHomework ( ) ;
265+ item . style . transition = 'opacity 0.2s' ;
266+ item . style . opacity = '0' ;
267+ setTimeout ( ( ) => {
268+ item . remove ( ) ;
269+ displayCompletedHomework ( ) ;
270+ } , 200 ) ;
271+
266272 }
267273 return ;
268274 }
0 commit comments