Skip to content

Commit 7da7c8c

Browse files
Merge pull request steam-bell-92#1076 from anujsharma8d/fix/productive-pet
fix: improve the ui and functionality of productive pet project
2 parents 7b1a69a + 30dfdd5 commit 7da7c8c

1 file changed

Lines changed: 134 additions & 9 deletions

File tree

web-app/js/projects/productive-pet.js

Lines changed: 134 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,144 @@ function getProductivePetHTML() {
44
<h2 class="pet-title">🐱 Productive Pet</h2>
55
66
<div class="pet-card">
7-
<div id="petLevel">Level 1</div>
7+
8+
<div class="pet-box">
9+
10+
<div id="petLevel" class="pet-level">⭐Level 1</div>
811
912
<div class="pet-emoji">🐱</div>
1013
11-
<div id="petMood">Tired 🥱</div>
14+
</div>
15+
16+
<div id="petMood" class="pet-mood">Tired 🥱</div>
1217
1318
<div class="xp-bar">
1419
<div class="xp-fill"></div>
1520
</div>
1621
17-
<span id="xpText">0 / 100 XP</span>
22+
<div>
23+
<span class="xp">Experience: </span>
24+
<span id="xpText" class="xp">0 / 100 XP</span>
25+
</div>
1826
1927
<div class="task-input-area">
2028
<input id="taskInput" placeholder="Enter task..." />
2129
<button id="addTaskBtn">Add Task</button>
2230
</div>
2331
24-
<ul id="taskList"></ul>
25-
26-
<div id="streakText">🔥 Streak: 0</div>
32+
<div class="task-list">
33+
<h4>Your Task</h4>
34+
<ul id="taskList"></ul>
35+
</div>
36+
<div>
37+
<div id="streakText" class="streak">🔥 Streak: 0</div>
2738
</div>
28-
</div>
39+
</div>
40+
</div>
41+
<style>
42+
.pet-card{
43+
display:flex;
44+
flex-direction:column;
45+
gap:5px;
46+
justify-content:center;
47+
}
48+
.pet-title{
49+
font-family: var(--font-sans);
50+
font-size: 1.6rem;
51+
font-weight: 700;
52+
letter-spacing: -0.03em;
53+
margin-bottom: 16px;
54+
}
55+
.task-input-area input{
56+
padding: 10px;
57+
border-radius: 10px;
58+
border: 2px solid var(--border-color);
59+
background: var(--surface-color);
60+
color: var(--text-color);
61+
}
62+
.task-input-area button{
63+
background: var(--accent);
64+
color: var(--bg-on-accent, #fff);
65+
padding: 10px;
66+
padding-left:15px;
67+
padding-right:15px;
68+
border-radius: 30px;
69+
}
70+
71+
.pet-level{
72+
display:inline-flex;
73+
align-items:center;
74+
gap:8px;
75+
padding:10px 18px;
76+
border-radius:999px;
77+
background: #a7f3b5;
78+
color: #065F46;
79+
font-weight:600;
80+
}
81+
.pet-box{
82+
display:flex;
83+
gap:20px;
84+
align-items:center;
85+
}
86+
.pet-emoji{
87+
font-size:50px;
88+
}
89+
90+
.task-list{
91+
margin-top:20px;
92+
margin-bottom:20px;
93+
padding: 10px;
94+
padding-left:20px;
95+
height:150px;
96+
overflow:auto;
97+
border-radius: 10px;
98+
border: 2px solid var(--border-color);
99+
background: var(--surface-color);
100+
color: var(--text-color);
101+
}
102+
.streak{
103+
display:inline-flex;
104+
align-items:center;
105+
gap:8px;
106+
padding:10px 18px;
107+
border-radius:999px;
108+
background:#FEF3C7;
109+
color:#B45309;
110+
font-weight:600;
111+
border:1px solid #FCD34D;
112+
}
113+
.complete-btn{
114+
background: #c6f7cf;
115+
color: #065F46;
116+
padding:5px 13px;
117+
font-weight:600;
118+
border-radius:10px;
119+
}
120+
.delete-btn{
121+
background: #ffdbdb;
122+
color: #982424;
123+
padding:5px 13px;
124+
font-weight:600;
125+
border-radius:10px;
126+
}
127+
li{
128+
font-size:20px;
129+
margin:5px;
130+
}
131+
.task{
132+
margin-right:30px
133+
}
134+
.pet-mood{
135+
font-size:30px;
136+
}
137+
.xp{
138+
font-size:20px;
139+
font-weight:800;
140+
}
141+
.task-list h4{
142+
border-bottom:1px solid black;
143+
}
144+
</style>
29145
`;
30146
}
31147
function initProductivePet() {
@@ -47,6 +163,8 @@ function initProductivePet() {
47163
const streakText = document.getElementById("streakText");
48164

49165
if (!addTaskBtn || !taskInput) return;
166+
if (addTaskBtn.dataset.initialized) return;
167+
addTaskBtn.dataset.initialized = "true";
50168

51169
function getPetState(level) {
52170
if (level >= 10) return { emoji: "🐉", mood: "Mythic Beast 🔥" };
@@ -59,7 +177,7 @@ function initProductivePet() {
59177
function updatePetUI() {
60178
xpFill.style.width = `${xp}%`;
61179
xpText.innerText = `${xp} / 100 XP`;
62-
levelText.innerText = `Level ${level}`;
180+
levelText.innerText = `Level ${level}`;
63181
streakText.innerText = `🔥 Streak: ${streak}`;
64182

65183
const petState = getPetState(level);
@@ -75,14 +193,21 @@ function initProductivePet() {
75193

76194
const li = document.createElement("li");
77195
li.innerHTML = `
78-
<span>${task}</span>
196+
<span class="task">${task}</span>
79197
<button class="complete-btn">Complete</button>
198+
<button class="delete-btn">Delete</button>
80199
`;
81200

82201
taskList.appendChild(li);
83202
taskInput.value = "";
84203

85204
const completeBtn = li.querySelector(".complete-btn");
205+
const deleteBtn = li.querySelector(".delete-btn");
206+
207+
deleteBtn.addEventListener("click", () => {
208+
if (deleteBtn.disabled) return;
209+
li.remove();
210+
})
86211

87212
completeBtn.addEventListener("click", () => {
88213

0 commit comments

Comments
 (0)