Ron Au commited on
Commit
dbeba80
1 Parent(s): a58a288

feat(ux): Make several UX tweaks

Browse files
Files changed (3) hide show
  1. static/index.html +1 -1
  2. static/js/index.js +11 -0
  3. static/style.css +14 -0
static/index.html CHANGED
@@ -48,7 +48,7 @@
48
  <button class="toggle-name" data-include tabindex="-1">Trainer Name</button>
49
  <button class="generate-new" tabindex="-1">New Pokémon</button>
50
  </div>
51
- <div class="duration"><span class="elapsed">0.0</span>s (ETA: <span class="eta">40</span>s)</div>
52
  </div>
53
  <div class="scene">
54
  <div class="booster">
 
48
  <button class="toggle-name" data-include tabindex="-1">Trainer Name</button>
49
  <button class="generate-new" tabindex="-1">New Pokémon</button>
50
  </div>
51
+ <div class="duration"><span class="elapsed">0.0</span>s (ETA: <span class="eta">35</span>s)</div>
52
  </div>
53
  <div class="scene">
54
  <div class="booster">
static/js/index.js CHANGED
@@ -44,6 +44,10 @@ const generate = async () => {
44
  const timer = durationTimer(durationDisplay);
45
  const timerCleanup = timer().cleanup;
46
 
 
 
 
 
47
  // Theoretically, keep client waiting only an extra half interval once task is complete
48
  const interval = 5_000;
49
  await new Promise((resolve) => setTimeout(resolve, task.eta * 1_000 - interval / 2));
@@ -87,6 +91,13 @@ nameInput.addEventListener('input', (e) => {
87
 
88
  document.querySelector('form.trainer-name').addEventListener('submit', (e) => {
89
  e.preventDefault();
 
 
 
 
 
 
 
90
  generate();
91
  });
92
 
 
44
  const timer = durationTimer(durationDisplay);
45
  const timerCleanup = timer().cleanup;
46
 
47
+ if (window.innerWidth <= 500) {
48
+ durationDisplay.scrollIntoView({ behavior: 'smooth' });
49
+ }
50
+
51
  // Theoretically, keep client waiting only an extra half interval once task is complete
52
  const interval = 5_000;
53
  await new Promise((resolve) => setTimeout(resolve, task.eta * 1_000 - interval / 2));
 
91
 
92
  document.querySelector('form.trainer-name').addEventListener('submit', (e) => {
93
  e.preventDefault();
94
+
95
+ if (document.querySelector('.output').dataset.state === 'completed') {
96
+ if (!window.confirm('Generate new Pokémon?')) {
97
+ return;
98
+ }
99
+ }
100
+
101
  generate();
102
  });
103
 
static/style.css CHANGED
@@ -57,6 +57,19 @@ main {
57
  main {
58
  padding: 3rem 0;
59
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  }
61
 
62
  @media (max-width: 1280px) {
@@ -271,6 +284,7 @@ button.toggle-name.off {
271
  .scene {
272
  --scale: 0.9;
273
  height: 40rem;
 
274
  box-sizing: border-box;
275
  margin: 2rem;
276
  perspective: 100rem;
 
57
  main {
58
  padding: 3rem 0;
59
  }
60
+
61
+ .output .scene {
62
+ margin: -5rem 2rem 2rem;
63
+ }
64
+
65
+ .scene .booster {
66
+ --booster-scale: 0.5;
67
+ }
68
+
69
+ .scene .card-slot {
70
+ margin-top: 1rem;
71
+ }
72
+
73
  }
74
 
75
  @media (max-width: 1280px) {
 
284
  .scene {
285
  --scale: 0.9;
286
  height: 40rem;
287
+ overflow: hidden;
288
  box-sizing: border-box;
289
  margin: 2rem;
290
  perspective: 100rem;