File tree Expand file tree Collapse file tree 3 files changed +34
-5
lines changed
Expand file tree Collapse file tree 3 files changed +34
-5
lines changed Original file line number Diff line number Diff line change 4141 position : absolute;
4242 left : 0 ;
4343 border-radius : 4px ;
44- width : 80% ;
4544 height : 5px ;
4645 background : var (--add-color-5 , # 5051F9 );
46+ transition-property : width;
47+ transition-duration : var (--short , 0.3s );
48+ transition-timing-function : ease-in-out;
49+ will-change : width;
4750}
4851
4952/* media queries, any-hover */
Original file line number Diff line number Diff line change 3535 </ aside >
3636 < main class ="content app__content " id ="content " aria-label ="Контент приложения ">
3737 < header class ="content__header ">
38- < h1 class ="content__title "> Отжимания </ h1 >
38+ < h1 class ="content__title " id =" header-title " > </ h1 >
3939 < div class ="progress-bar content__progress-bar ">
4040 < div class ="progress-bar__heading-wrap ">
4141 < span class ="progress-bar__text "> Прогресс</ span >
42- < span class ="progress-bar__percent "> 80% </ span >
42+ < span class ="progress-bar__percent " id =" progress-percent " > </ span >
4343 </ div >
4444 < div class ="progress-bar__scale-wrap ">
4545 < span class ="progress-bar__scale "> </ span >
46- < span class ="progress-bar__value "> </ span >
46+ < span class ="progress-bar__value " id =" progress-value " > </ span >
4747 </ div >
4848 </ div >
4949 </ header >
Original file line number Diff line number Diff line change @@ -6,6 +6,11 @@ const HABBITS_KEY = 'HABBITS';
66// app
77const app = {
88 'menu-list' : document . getElementById ( 'sidebar-list' ) ,
9+ header : {
10+ title : document . getElementById ( 'header-title' ) ,
11+ progressPercent : document . getElementById ( 'progress-percent' ) ,
12+ progressValue : document . getElementById ( 'progress-value' ) ,
13+ } ,
914} ;
1015
1116// ** utility **
@@ -64,10 +69,31 @@ function rerenderMenu(activeHabbit) {
6469 }
6570}
6671
67- // поиск элемента/привычки.. запуск отрисовки/переключение активности
72+ function rerenderHeaderContentEl ( activeHabbit ) {
73+ if ( ! activeHabbit ) {
74+ return ;
75+ }
76+
77+ app . header . title . textContent = activeHabbit . title ; // добавление/обновление заголовка
78+
79+ // подсчёт прогресса/выполнения (согласно "уже" отмеченных дней и "ранее" поставленной цели/дней)
80+ const progress =
81+ activeHabbit . days . length / activeHabbit . target > 1
82+ ? 100
83+ : ( activeHabbit . days . length / activeHabbit . target ) * 100 ;
84+
85+ app . header . progressPercent . textContent = `${ progress . toFixed ( 0 ) } %` ;
86+ app . header . progressValue . setAttribute (
87+ 'style' ,
88+ `width: ${ progress . toFixed ( 0 ) } %`
89+ ) ;
90+ }
91+
92+ // поиск/определение "активной" привычки.. запуск отрисовок элементов/переключение активностей
6893function rerender ( activeHabbitId ) {
6994 const activeHabbit = habbits . find ( ( habbit ) => habbit . id === activeHabbitId ) ;
7095 rerenderMenu ( activeHabbit ) ;
96+ rerenderHeaderContentEl ( activeHabbit ) ;
7197}
7298
7399// init
You can’t perform that action at this time.
0 commit comments