eloigil6 commited on
Commit
3bf1ce3
·
1 Parent(s): 1af28be

Add "play while waiting" feature to enhance user experience. Introduced a new button in index.html that allows users to engage with a garden mini-game while waiting. Updated main.js to handle the button's functionality, and modified ui.js to manage its visibility based on the current stage. Enhanced style.css with new styles for the button, ensuring it is visually appealing and interactive.

Browse files
Files changed (4) hide show
  1. frontend/index.html +24 -0
  2. frontend/main.js +7 -0
  3. frontend/style.css +55 -0
  4. frontend/ui.js +4 -0
frontend/index.html CHANGED
@@ -189,6 +189,30 @@
189
  </div>
190
  <button id="again-btn">MAKE ANOTHER</button>
191
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  </div>
193
 
194
  <div id="collection-panel" class="hidden">
 
189
  </div>
190
  <button id="again-btn">MAKE ANOTHER</button>
191
  </div>
192
+ <button
193
+ id="play-while-waiting"
194
+ class="hidden"
195
+ aria-label="play the garden game while you wait"
196
+ >
197
+ <svg
198
+ viewBox="0 0 24 24"
199
+ width="22"
200
+ height="22"
201
+ fill="none"
202
+ stroke="currentColor"
203
+ stroke-width="1.7"
204
+ stroke-linecap="round"
205
+ stroke-linejoin="round"
206
+ aria-hidden="true"
207
+ >
208
+ <rect x="5" y="2.5" width="14" height="19" rx="2.6" />
209
+ <rect x="8" y="5" width="8" height="6.5" rx="1" />
210
+ <path d="M9 16.6h2.4M10.2 15.4v2.4" />
211
+ <circle cx="15" cy="15.6" r="0.95" fill="currentColor" stroke="none" />
212
+ <circle cx="16.6" cy="17.1" r="0.95" fill="currentColor" stroke="none" />
213
+ </svg>
214
+ <span>play a relaxed game while waiting</span>
215
+ </button>
216
  </div>
217
 
218
  <div id="collection-panel" class="hidden">
frontend/main.js CHANGED
@@ -500,6 +500,13 @@ const ui = initUI({
500
  onRequestCloseGameboy: () => {
501
  if (view.mode === "gameboy") closeGameboyView();
502
  },
 
 
 
 
 
 
 
503
  onGeneratingChange: setMachineBusy,
504
  });
505
 
 
500
  onRequestCloseGameboy: () => {
501
  if (view.mode === "gameboy") closeGameboyView();
502
  },
503
+ // "play while waiting": leave the beat brewing in the background and fly
504
+ // from the machine over to the garden mini-game.
505
+ onPlayWhileWaiting: () => {
506
+ if (view.mode !== "machine") return;
507
+ ui.closeModal();
508
+ zoomToGameboy();
509
+ },
510
  onGeneratingChange: setMachineBusy,
511
  });
512
 
frontend/style.css CHANGED
@@ -197,6 +197,61 @@ body {
197
  display: none;
198
  }
199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  /* anime panel entrance: a thin slash from the corner that springs open */
201
  #machine-modal.opening {
202
  animation: modal-in 0.55s cubic-bezier(0.25, 0.9, 0.35, 1.2) both;
 
197
  display: none;
198
  }
199
 
200
+ /* "play while waiting" nudge — a frosted pill below the card, shown only while
201
+ the machine is brewing. Clicking it whisks you off to the garden mini-game. */
202
+ #play-while-waiting {
203
+ position: absolute;
204
+ top: calc(100% + 16px);
205
+ left: 50%;
206
+ transform: translateX(-50%);
207
+ display: inline-flex;
208
+ align-items: center;
209
+ gap: 9px;
210
+ white-space: nowrap;
211
+ padding: 9px 17px;
212
+ border-radius: 999px;
213
+ border: 1px solid rgba(255, 255, 255, 0.5);
214
+ background: rgba(255, 255, 255, 0.18);
215
+ backdrop-filter: blur(10px);
216
+ -webkit-backdrop-filter: blur(10px);
217
+ color: #fff;
218
+ font-family: "Baloo 2", sans-serif;
219
+ font-weight: 600;
220
+ font-size: 0.9rem;
221
+ cursor: pointer;
222
+ text-shadow: 0 1px 3px rgba(15, 40, 90, 0.45);
223
+ box-shadow: 0 8px 24px rgba(15, 40, 90, 0.28);
224
+ transition:
225
+ background 0.18s ease,
226
+ transform 0.18s ease;
227
+ animation: pww-in 0.4s ease;
228
+ }
229
+
230
+ #play-while-waiting svg {
231
+ flex: none;
232
+ opacity: 0.95;
233
+ }
234
+
235
+ #play-while-waiting:hover {
236
+ background: rgba(255, 255, 255, 0.32);
237
+ transform: translateX(-50%) translateY(-2px);
238
+ }
239
+
240
+ #play-while-waiting.hidden {
241
+ display: none;
242
+ }
243
+
244
+ @keyframes pww-in {
245
+ from {
246
+ opacity: 0;
247
+ transform: translateX(-50%) translateY(8px);
248
+ }
249
+ to {
250
+ opacity: 1;
251
+ transform: translateX(-50%) translateY(0);
252
+ }
253
+ }
254
+
255
  /* anime panel entrance: a thin slash from the corner that springs open */
256
  #machine-modal.opening {
257
  animation: modal-in 0.55s cubic-bezier(0.25, 0.9, 0.35, 1.2) both;
frontend/ui.js CHANGED
@@ -12,10 +12,12 @@ export function initUI({
12
  onRequestClose,
13
  onRequestCloseCollection,
14
  onRequestCloseGameboy,
 
15
  onGeneratingChange,
16
  }) {
17
  const modal = $("machine-modal");
18
  const gameboyModal = $("gameboy-modal");
 
19
  const input = $("prompt-input");
20
  const coinBtn = $("coin-button");
21
  const controlsRow = $("controls-row");
@@ -68,6 +70,7 @@ export function initUI({
68
  controlsRow.classList.toggle("hidden", stage !== "prompt");
69
  generating.classList.toggle("hidden", stage !== "generating");
70
  cassetteStage.classList.toggle("hidden", stage !== "cassette");
 
71
  input.classList.toggle("hidden", stage === "cassette");
72
  input.disabled = stage === "generating";
73
  if (stage === "prompt") {
@@ -416,6 +419,7 @@ export function initUI({
416
 
417
  $("collection-close").addEventListener("click", () => onRequestCloseCollection());
418
  $("gameboy-close").addEventListener("click", () => onRequestCloseGameboy());
 
419
  caroPrev.addEventListener("click", () => centerOn(centerIndex - 1, { load: true }));
420
  caroNext.addEventListener("click", () => centerOn(centerIndex + 1, { load: true }));
421
 
 
12
  onRequestClose,
13
  onRequestCloseCollection,
14
  onRequestCloseGameboy,
15
+ onPlayWhileWaiting,
16
  onGeneratingChange,
17
  }) {
18
  const modal = $("machine-modal");
19
  const gameboyModal = $("gameboy-modal");
20
+ const playWaitBtn = $("play-while-waiting");
21
  const input = $("prompt-input");
22
  const coinBtn = $("coin-button");
23
  const controlsRow = $("controls-row");
 
70
  controlsRow.classList.toggle("hidden", stage !== "prompt");
71
  generating.classList.toggle("hidden", stage !== "generating");
72
  cassetteStage.classList.toggle("hidden", stage !== "cassette");
73
+ playWaitBtn.classList.toggle("hidden", stage !== "generating");
74
  input.classList.toggle("hidden", stage === "cassette");
75
  input.disabled = stage === "generating";
76
  if (stage === "prompt") {
 
419
 
420
  $("collection-close").addEventListener("click", () => onRequestCloseCollection());
421
  $("gameboy-close").addEventListener("click", () => onRequestCloseGameboy());
422
+ playWaitBtn.addEventListener("click", () => onPlayWhileWaiting());
423
  caroPrev.addEventListener("click", () => centerOn(centerIndex - 1, { load: true }));
424
  caroNext.addEventListener("click", () => centerOn(centerIndex + 1, { load: true }));
425