Skip to content

Commit 351f1ff

Browse files
Rearrange calculator results layout (#99)
- add reusable formatter to display deploy time with approximate prefix - show sub-minute deploy times in seconds and longer durations in minutes:seconds - update tooltip text to reflect the new formatting - rearrange the calculator results so final damage is highlighted first, with time, rank, and influence in a responsive row using compact styling ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_6946f6a1224883258e8317a22966d12c)
1 parent 85d56b1 commit 351f1ff

File tree

1 file changed

+56
-20
lines changed

1 file changed

+56
-20
lines changed

erepublik-air-damage-calculator.html

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
.result-display {
4747
display: flex;
4848
flex-direction: column;
49-
gap: 0.5rem;
49+
gap: 0.75rem;
5050
}
5151

5252
.result-value {
@@ -55,6 +55,23 @@
5555
letter-spacing: 0.01em;
5656
}
5757

58+
.result-metrics-grid {
59+
display: grid;
60+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
61+
gap: clamp(0.75rem, 2vw, 1.25rem);
62+
align-items: start;
63+
}
64+
65+
.result-value--compact {
66+
font-size: clamp(1.4rem, 3vw, 1.85rem);
67+
}
68+
69+
.result-group {
70+
display: flex;
71+
flex-direction: column;
72+
gap: 0.25rem;
73+
}
74+
5875
.result-with-tooltip {
5976
display: inline-flex;
6077
align-items: center;
@@ -197,24 +214,32 @@ <h1>eRepublik Air Damage Calculator</h1>
197214
<p class="helper-text">final damage</p>
198215
</div>
199216
<p class="helper-text" id="breakdown"></p>
200-
<div class="result-with-tooltip" id="influence-wrapper">
201-
<div class="result-value tooltip-target" id="influence" tabindex="0">0</div>
202-
<span class="tooltip-icon" aria-hidden="true">?</span>
203-
<p class="helper-text">influence</p>
204-
</div>
205-
<p class="helper-text" id="influence-breakdown"></p>
206-
<div class="result-with-tooltip" id="time-wrapper">
207-
<div class="result-value tooltip-target" id="time-estimate" tabindex="0">≈0s</div>
208-
<span class="tooltip-icon" aria-hidden="true">?</span>
209-
<p class="helper-text">time to deploy</p>
210-
</div>
211-
<p class="helper-text" id="time-breakdown"></p>
212-
<div class="result-with-tooltip" id="rank-wrapper">
213-
<div class="result-value tooltip-target" id="rank-value" tabindex="0">0</div>
214-
<span class="tooltip-icon" aria-hidden="true">?</span>
215-
<p class="helper-text">rank points</p>
217+
<div class="result-metrics-grid">
218+
<div class="result-group">
219+
<div class="result-with-tooltip result-with-tooltip--compact" id="time-wrapper">
220+
<div class="result-value result-value--compact tooltip-target" id="time-estimate" tabindex="0">≈0s</div>
221+
<span class="tooltip-icon" aria-hidden="true">?</span>
222+
<p class="helper-text">time to deploy</p>
223+
</div>
224+
<p class="helper-text" id="time-breakdown"></p>
225+
</div>
226+
<div class="result-group">
227+
<div class="result-with-tooltip result-with-tooltip--compact" id="rank-wrapper">
228+
<div class="result-value result-value--compact tooltip-target" id="rank-value" tabindex="0">0</div>
229+
<span class="tooltip-icon" aria-hidden="true">?</span>
230+
<p class="helper-text">rank points</p>
231+
</div>
232+
<p class="helper-text" id="rank-breakdown"></p>
233+
</div>
234+
<div class="result-group">
235+
<div class="result-with-tooltip result-with-tooltip--compact" id="influence-wrapper">
236+
<div class="result-value result-value--compact tooltip-target" id="influence" tabindex="0">0</div>
237+
<span class="tooltip-icon" aria-hidden="true">?</span>
238+
<p class="helper-text">influence</p>
239+
</div>
240+
<p class="helper-text" id="influence-breakdown"></p>
241+
</div>
216242
</div>
217-
<p class="helper-text" id="rank-breakdown"></p>
218243
</div>
219244
</section>
220245

@@ -593,6 +618,17 @@ <h1>eRepublik Air Damage Calculator</h1>
593618
return Number.isFinite(value) ? value.toLocaleString(undefined, { maximumFractionDigits: 2 }) : '0';
594619
};
595620

621+
const formatDeployTime = (seconds) => {
622+
const wholeSeconds = Math.max(0, Math.ceil(seconds));
623+
if (wholeSeconds < 60) {
624+
return `≈${formatNumber(wholeSeconds)}s`;
625+
}
626+
627+
const minutes = Math.floor(wholeSeconds / 60);
628+
const remainingSeconds = String(wholeSeconds % 60).padStart(2, '0');
629+
return `≈${formatNumber(minutes)}m:${remainingSeconds}s`;
630+
};
631+
596632
const clampNumber = (value, min, max) => {
597633
if (Number.isNaN(value)) return min;
598634
if (typeof max === 'number') {
@@ -708,12 +744,12 @@ <h1>eRepublik Air Damage Calculator</h1>
708744

709745
const timeSeconds = hits / actualHitsPerSecond;
710746
const timeSecondsRounded = Math.ceil(timeSeconds);
711-
timeEstimate.textContent = `≈${formatNumber(timeSecondsRounded)}s`;
747+
timeEstimate.textContent = formatDeployTime(timeSecondsRounded);
712748
const timeFormula = [
713749
'Time = ceil(hits ÷ (hits per second × accelerator))',
714750
`= ceil(${formatNumber(hits)} ÷ (${formatNumber(baseHitsPerSecond)} × ${formatNumber(damageAcceleratorMultiplier)}))`,
715751
`= ceil(${formatNumber(timeSeconds)} seconds)`,
716-
`= ${formatNumber(timeSecondsRounded)} seconds`
752+
`= ${formatDeployTime(timeSecondsRounded)}`
717753
].join('\n');
718754

719755
const rankFromDamage = result * 0.1;

0 commit comments

Comments
 (0)