Spaces:
Running
Running
Update pomodoro_forest.py
Browse files- pomodoro_forest.py +36 -8
pomodoro_forest.py
CHANGED
|
@@ -93,18 +93,34 @@ HTML_TEMPLATE = """
|
|
| 93 |
|
| 94 |
// Current growing tree (center)
|
| 95 |
if (mode === 'focus') {
|
|
|
|
| 96 |
let treeHTML = '<div class="growing-tree">';
|
| 97 |
-
|
| 98 |
-
if (
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
| 103 |
treeHTML += '<div class="fruit" style="left:-15px;top:-55px"></div>';
|
| 104 |
treeHTML += '<div class="fruit" style="left:18px;top:-45px"></div>';
|
| 105 |
treeHTML += '<div class="fruit" style="left:0px;top:-65px"></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
}
|
| 107 |
-
if (treeStage === 0) treeHTML += '<div class="seed">🌱</div>';
|
| 108 |
treeHTML += '</div>';
|
| 109 |
trees.push(treeHTML);
|
| 110 |
} else {
|
|
@@ -347,6 +363,18 @@ CSS_TEMPLATE = """
|
|
| 347 |
font-size: 40px;
|
| 348 |
animation: float 3s ease-in-out infinite;
|
| 349 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 350 |
@keyframes float {
|
| 351 |
0%, 100% { transform: translateX(-50%) translateY(0); }
|
| 352 |
50% { transform: translateX(-50%) translateY(-10px); }
|
|
@@ -695,4 +723,4 @@ with gr.Blocks(title="🍅 Pomodoro Forest") as demo:
|
|
| 695 |
|
| 696 |
|
| 697 |
if __name__ == "__main__":
|
| 698 |
-
demo.launch(theme=gr.themes.
|
|
|
|
| 93 |
|
| 94 |
// Current growing tree (center)
|
| 95 |
if (mode === 'focus') {
|
| 96 |
+
const isIdle = elapsed === 0 && !value?.running;
|
| 97 |
let treeHTML = '<div class="growing-tree">';
|
| 98 |
+
|
| 99 |
+
if (isIdle) {
|
| 100 |
+
// Show a full preview tree when idle so theme is visible
|
| 101 |
+
treeHTML += '<div class="trunk t4"></div>';
|
| 102 |
+
treeHTML += '<div class="branch-l b4"></div>';
|
| 103 |
+
treeHTML += '<div class="branch-r b4"></div>';
|
| 104 |
+
treeHTML += '<div class="crown c4"></div>';
|
| 105 |
+
treeHTML += '<div class="crown-top c4"></div>';
|
| 106 |
treeHTML += '<div class="fruit" style="left:-15px;top:-55px"></div>';
|
| 107 |
treeHTML += '<div class="fruit" style="left:18px;top:-45px"></div>';
|
| 108 |
treeHTML += '<div class="fruit" style="left:0px;top:-65px"></div>';
|
| 109 |
+
treeHTML += '<div class="preview-label">Press Start to grow!</div>';
|
| 110 |
+
} else {
|
| 111 |
+
// Show growing tree based on progress
|
| 112 |
+
if (treeStage >= 1) treeHTML += '<div class="trunk t' + Math.min(treeStage, 4) + '"></div>';
|
| 113 |
+
if (treeStage >= 1) treeHTML += '<div class="branch-l b' + Math.min(treeStage, 4) + '"></div>';
|
| 114 |
+
if (treeStage >= 2) treeHTML += '<div class="branch-r b' + Math.min(treeStage, 4) + '"></div>';
|
| 115 |
+
if (treeStage >= 2) treeHTML += '<div class="crown c' + Math.min(treeStage, 4) + '"></div>';
|
| 116 |
+
if (treeStage >= 3) treeHTML += '<div class="crown-top c' + Math.min(treeStage, 4) + '"></div>';
|
| 117 |
+
if (treeStage >= 4) {
|
| 118 |
+
treeHTML += '<div class="fruit" style="left:-15px;top:-55px"></div>';
|
| 119 |
+
treeHTML += '<div class="fruit" style="left:18px;top:-45px"></div>';
|
| 120 |
+
treeHTML += '<div class="fruit" style="left:0px;top:-65px"></div>';
|
| 121 |
+
}
|
| 122 |
+
if (treeStage === 0) treeHTML += '<div class="seed">🌱</div>';
|
| 123 |
}
|
|
|
|
| 124 |
treeHTML += '</div>';
|
| 125 |
trees.push(treeHTML);
|
| 126 |
} else {
|
|
|
|
| 363 |
font-size: 40px;
|
| 364 |
animation: float 3s ease-in-out infinite;
|
| 365 |
}
|
| 366 |
+
.preview-label {
|
| 367 |
+
position: absolute;
|
| 368 |
+
bottom: -30px;
|
| 369 |
+
left: 50%;
|
| 370 |
+
transform: translateX(-50%);
|
| 371 |
+
font-size: 10px;
|
| 372 |
+
color: #8899aa;
|
| 373 |
+
white-space: nowrap;
|
| 374 |
+
background: rgba(0,0,0,0.5);
|
| 375 |
+
padding: 2px 8px;
|
| 376 |
+
border-radius: 8px;
|
| 377 |
+
}
|
| 378 |
@keyframes float {
|
| 379 |
0%, 100% { transform: translateX(-50%) translateY(0); }
|
| 380 |
50% { transform: translateX(-50%) translateY(-10px); }
|
|
|
|
| 723 |
|
| 724 |
|
| 725 |
if __name__ == "__main__":
|
| 726 |
+
demo.launch(theme=gr.themes.Citrus(primary_hue="red"))
|