add interface logic
This commit is contained in:
55
app.js
55
app.js
@@ -0,0 +1,55 @@
|
|||||||
|
const HabitTrackerApp = {
|
||||||
|
elements: {
|
||||||
|
habitGrid: null,
|
||||||
|
addHabitForm: null,
|
||||||
|
addHabbitButton: null
|
||||||
|
},
|
||||||
|
|
||||||
|
init: function() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
setupEventListeners: function() {
|
||||||
|
this.elements.addHabbitButton.addEventListener('click', () => {
|
||||||
|
this.elements.addHabitForm.style.display = 'block';
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
loadElements: function() {
|
||||||
|
this.elements.habitGrid = document.getElementById('habits-grid');
|
||||||
|
this.elements.addHabitForm = document.getElementById('add-habit-form');
|
||||||
|
this.elements.addHabbitButton = document.getElementById('add-habbit-button');
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
const habitsHTML = HabitManager.habits.map(habit => {
|
||||||
|
const cardClass = `habit-card ${habit.isCompleted ? 'habit-card--completed' : ''}`;
|
||||||
|
const progress = (habit.currentCount / habit.targetCount) * 100;
|
||||||
|
|
||||||
|
return `<div class="${cardClass}" data-habit-id="${habit.id}">
|
||||||
|
<div class="habit-card__header">
|
||||||
|
<div class="habit-card__icon">💧</div>
|
||||||
|
<h3 class="habit-card__title">${habit.name}</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="habit-card__description">${habit.description}</p>
|
||||||
|
|
||||||
|
<div class="habit-card__progress">
|
||||||
|
<div class="habit-card__progress-info">
|
||||||
|
<span>Прогресс</span>
|
||||||
|
<span>${progress}%</span>
|
||||||
|
</div>
|
||||||
|
<div class="habit-card__progress-bar">
|
||||||
|
<div class="habit-card__progress-fill" style="width: ${progress}%"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="habit-card__actions">
|
||||||
|
<button class="button button--primary">Отметить выполнение</button>
|
||||||
|
<button class="button button--secondary">Подробнее</button>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -235,7 +235,7 @@
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<!-- Сетка карточек привычек -->
|
<!-- Сетка карточек привычек -->
|
||||||
<div class="habits-grid">
|
<div class="habits-grid" id="habits-grid">
|
||||||
<!-- Карточка 1 -->
|
<!-- Карточка 1 -->
|
||||||
<div class="habit-card">
|
<div class="habit-card">
|
||||||
<div class="habit-card__header">
|
<div class="habit-card__header">
|
||||||
@@ -310,9 +310,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Форма добавления новой привычки -->
|
<!-- Форма добавления новой привычки -->
|
||||||
<div class="new-habit-form">
|
<div class="new-habit-form" id="new-habit-form">
|
||||||
<h2 class="new-habit-form__title">➕ Добавить новую привычку</h2>
|
<h2 class="new-habit-form__title" id="add-habbit-button">➕ Добавить новую привычку</h2>
|
||||||
<!-- Здесь студенты будут добавлять форму -->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="app.js"></script>
|
<script src="app.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user